##// END OF EJS Templates
diff: better detection of renames when comparing with the working dir.
Alexis S. L. Carvalho -
r3696:562a6563 default
parent child Browse files
Show More
@@ -467,6 +467,9 b' def diff(repo, node1=None, node2=None, f'
467 if not modified and not added and not removed:
467 if not modified and not added and not removed:
468 return
468 return
469
469
470 # returns False if there was no rename between n1 and n2
471 # returns None if the file was created between n1 and n2
472 # returns the (file, node) present in n1 that was renamed to f in n2
470 def renamedbetween(f, n1, n2):
473 def renamedbetween(f, n1, n2):
471 r1, r2 = map(repo.changelog.rev, (n1, n2))
474 r1, r2 = map(repo.changelog.rev, (n1, n2))
472 orig = f
475 orig = f
@@ -483,12 +486,12 b' def diff(repo, node1=None, node2=None, f'
483 f = src[0]
486 f = src[0]
484 n2 = repo.changelog.parents(n2)[0]
487 n2 = repo.changelog.parents(n2)[0]
485 r2 = repo.changelog.rev(n2)
488 r2 = repo.changelog.rev(n2)
486 if orig == f:
487 return None
488 cl = getchangelog(n1)
489 cl = getchangelog(n1)
489 m = getmanifest(cl[0])
490 m = getmanifest(cl[0])
490 if f not in m:
491 if f not in m:
491 return None
492 return None
493 if f == orig:
494 return False
492 return f, m[f]
495 return f, m[f]
493
496
494 if node2:
497 if node2:
@@ -518,7 +521,7 b' def diff(repo, node1=None, node2=None, f'
518 if src:
521 if src:
519 f = src
522 f = src
520 of = renamedbetween(f, node1, parent)
523 of = renamedbetween(f, node1, parent)
521 if of:
524 if of or of is None:
522 return of
525 return of
523 elif src:
526 elif src:
524 cl = getchangelog(parent)[0]
527 cl = getchangelog(parent)[0]
@@ -112,3 +112,18 b' hg diff --git'
112 echo
112 echo
113 echo "% ...but there's another copy between the original rev and the wd"
113 echo "% ...but there's another copy between the original rev and the wd"
114 hg diff --git -r -2
114 hg diff --git -r -2
115 echo
116 echo "% ...but the source of the copy was created after the original rev"
117 hg diff --git -r -3
118 hg ci -m 'mv created2 created3'
119
120 echo > brand-new
121 hg add brand-new
122 hg ci -m 'add brand-new'
123 hg mv brand-new brand-new2
124 echo '% created in parent of wd; renamed in the wd'
125 hg diff --git
126
127 echo
128 echo '% created between r1 and parent of wd; renamed in the wd'
129 hg diff --git -r -2
@@ -113,3 +113,23 b' rename to created3'
113 diff --git a/created b/created3
113 diff --git a/created b/created3
114 rename from created
114 rename from created
115 rename to created3
115 rename to created3
116
117 % ...but the source of the copy was created after the original rev
118 diff --git a/created3 b/created3
119 new file mode 100644
120 --- /dev/null
121 +++ b/created3
122 @@ -0,0 +1,1 @@
123 +
124 % created in parent of wd; renamed in the wd
125 diff --git a/brand-new b/brand-new2
126 rename from brand-new
127 rename to brand-new2
128
129 % created between r1 and parent of wd; renamed in the wd
130 diff --git a/brand-new2 b/brand-new2
131 new file mode 100644
132 --- /dev/null
133 +++ b/brand-new2
134 @@ -0,0 +1,1 @@
135 +
General Comments 0
You need to be logged in to leave comments. Login now