##// END OF EJS Templates
diff: search beyond ancestor when detecting renames...
Mads Kiilerich -
r20294:243ea5ff default
parent child Browse files
Show More
@@ -98,15 +98,14 b' def _chain(src, dst, a, b):'
98
98
99 return t
99 return t
100
100
101 def _tracefile(fctx, actx):
101 def _tracefile(fctx, am, limit=-1):
102 '''return file context that is the ancestor of fctx present in actx'''
102 '''return file context that is the ancestor of fctx present in ancestor
103 stop = actx.rev()
103 manifest am, stopping after the first ancestor lower than limit'''
104 am = actx.manifest()
105
104
106 for f in fctx.ancestors():
105 for f in fctx.ancestors():
107 if am.get(f.path(), None) == f.filenode():
106 if am.get(f.path(), None) == f.filenode():
108 return f
107 return f
109 if f.rev() < stop:
108 if f.rev() < limit:
110 return None
109 return None
111
110
112 def _dirstatecopies(d):
111 def _dirstatecopies(d):
@@ -129,6 +128,13 b' def _forwardcopies(a, b):'
129 # short-circuit to avoid issues with merge states
128 # short-circuit to avoid issues with merge states
130 return _dirstatecopies(w)
129 return _dirstatecopies(w)
131
130
131 # files might have to be traced back to the fctx parent of the last
132 # one-side-only changeset, but not further back than that
133 limit = _findlimit(a._repo, a.rev(), b.rev())
134 if limit is None:
135 limit = -1
136 am = a.manifest()
137
132 # find where new files came from
138 # find where new files came from
133 # we currently don't try to find where old files went, too expensive
139 # we currently don't try to find where old files went, too expensive
134 # this means we can miss a case like 'hg rm b; hg cp a b'
140 # this means we can miss a case like 'hg rm b; hg cp a b'
@@ -137,7 +143,7 b' def _forwardcopies(a, b):'
137 missing.difference_update(a.manifest().iterkeys())
143 missing.difference_update(a.manifest().iterkeys())
138
144
139 for f in missing:
145 for f in missing:
140 ofctx = _tracefile(b[f], a)
146 ofctx = _tracefile(b[f], am, limit)
141 if ofctx:
147 if ofctx:
142 cm[f] = ofctx.path()
148 cm[f] = ofctx.path()
143
149
@@ -147,11 +147,13 b' Check patcha is still a git patch:'
147 -b
147 -b
148 +a
148 +a
149 +c
149 +c
150 diff --git a/aa b/aa
150 diff --git a/a b/aa
151 new file mode 100644
151 copy from a
152 --- /dev/null
152 copy to aa
153 --- a/a
153 +++ b/aa
154 +++ b/aa
154 @@ -0,0 +1,1 @@
155 @@ -1,1 +1,1 @@
156 -b
155 +a
157 +a
156
158
157 Check patcha2 is still a regular patch:
159 Check patcha2 is still a regular patch:
@@ -1567,3 +1567,41 b' unrelated branch diff'
1567 @@ -0,0 +1,1 @@
1567 @@ -0,0 +1,1 @@
1568 +a
1568 +a
1569 $ cd ..
1569 $ cd ..
1570
1571
1572 test for case where we didn't look sufficiently far back to find rename ancestor
1573
1574 $ hg init diffstop
1575 $ cd diffstop
1576 $ echo > f
1577 $ hg ci -qAmf
1578 $ hg mv f g
1579 $ hg ci -m'f->g'
1580 $ hg up -qr0
1581 $ touch x
1582 $ hg ci -qAmx
1583 $ echo f > f
1584 $ hg ci -qmf=f
1585 $ hg merge -q
1586 $ hg ci -mmerge
1587 $ hg log -G --template '{rev} {desc}'
1588 @ 4 merge
1589 |\
1590 | o 3 f=f
1591 | |
1592 | o 2 x
1593 | |
1594 o | 1 f->g
1595 |/
1596 o 0 f
1597
1598 $ hg diff --git -r 2
1599 diff --git a/f b/g
1600 rename from f
1601 rename to g
1602 --- a/f
1603 +++ b/g
1604 @@ -1,1 +1,1 @@
1605 -
1606 +f
1607 $ cd ..
General Comments 0
You need to be logged in to leave comments. Login now