-
Notifications
You must be signed in to change notification settings - Fork 362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Apply patches when dealing with repositories via an OCaml implementation of patch #5892
base: master
Are you sure you want to change the base?
Apply patches when dealing with repositories via an OCaml implementation of patch #5892
Conversation
let internal_patch ~dir p = | ||
let fmt = Printf.sprintf in | ||
let get_path file = | ||
let dir = real_path dir in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let dir = real_path dir in | |
(* NOTE: Important to keep this `concat dir ""` to ensure the | |
is_prefix_of doesn't match another directory *) | |
let dir = Filename.concat (real_path dir) "" in |
Could be coupled with ocaml-patch's implementation of diff via hannesm/patch#12 |
47f9c1e
to
d83fd0b
Compare
@@ -36,6 +36,7 @@ depends: [ | |||
"sha" {>= "1.13"} | |||
"jsonm" | |||
"swhid_core" | |||
"patch" {>= "1.0.1"} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"patch" {>= "1.0.1"} | |
"patch" {>= "2.0.0"} |
log "Internal diff (empty) done in %.2fs." (chrono ()); | ||
None | ||
| diffs -> | ||
log "Internal diff (non-empty) done in %.2fs." (chrono ()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: add a benchmark to show improvement before and after #5896
src/repository/opamGit.ml
Outdated
@@ -205,7 +205,7 @@ module VCS : OpamVCS.VCS = struct | |||
else if OpamSystem.file_is_empty patch_file then | |||
(finalise (); Done None) | |||
else | |||
Done (Some (OpamFilename.of_string patch_file)) | |||
Done (Some (OpamFilename.of_string patch_file, Patch.to_diffs ~p:1 (String.concat "\n" r.r_stdout))) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the use of Patch.to_diffs
should be avoided in opam as long as the diff parser isn't complete and well tested.
Instead we can use OpamRepositoryBackend.get_diff
, ignore all the changes in .git
/.hg
/.darcs
and voilà (hopefully)
src/repository/opamVCS.mli
Outdated
@@ -42,8 +42,9 @@ module type VCS = sig | |||
val patch_applied: dirname -> url -> unit OpamProcess.job | |||
|
|||
(** Returns the pending modifications in the form of a patch file, or None if | |||
val diff: dirname -> url -> (filename * Patch.t list) option OpamProcess.job |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
val diff: dirname -> url -> (filename * Patch.t list) option OpamProcess.job |
2841797
to
6a05509
Compare
WIP
Fixes #6019
Fixes #3782
requires hannesm/patch#9
requires hannesm/patch#7
see #5891
cc @hannesm
TODO: