##// END OF EJS Templates
copies: follow copies across merge base without source file (issue6163)...
Martin von Zweigbergk -
r42798:819712de default
parent child Browse files
Show More
@@ -150,7 +150,7 b' def _chain(a, b):'
150 t[k] = v
150 t[k] = v
151 return t
151 return t
152
152
153 def _tracefile(fctx, am, limit):
153 def _tracefile(fctx, am, basemf, limit):
154 """return file context that is the ancestor of fctx present in ancestor
154 """return file context that is the ancestor of fctx present in ancestor
155 manifest am, stopping after the first ancestor lower than limit"""
155 manifest am, stopping after the first ancestor lower than limit"""
156
156
@@ -158,6 +158,8 b' def _tracefile(fctx, am, limit):'
158 path = f.path()
158 path = f.path()
159 if am.get(path, None) == f.filenode():
159 if am.get(path, None) == f.filenode():
160 return path
160 return path
161 if basemf and basemf.get(path, None) == f.filenode():
162 return path
161 if not f.isintroducedafter(limit):
163 if not f.isintroducedafter(limit):
162 return None
164 return None
163
165
@@ -183,7 +185,7 b' def usechangesetcentricalgo(repo):'
183 return (repo.ui.config('experimental', 'copies.read-from') in
185 return (repo.ui.config('experimental', 'copies.read-from') in
184 ('changeset-only', 'compatibility'))
186 ('changeset-only', 'compatibility'))
185
187
186 def _committedforwardcopies(a, b, match):
188 def _committedforwardcopies(a, b, base, match):
187 """Like _forwardcopies(), but b.rev() cannot be None (working copy)"""
189 """Like _forwardcopies(), but b.rev() cannot be None (working copy)"""
188 # files might have to be traced back to the fctx parent of the last
190 # files might have to be traced back to the fctx parent of the last
189 # one-side-only changeset, but not further back than that
191 # one-side-only changeset, but not further back than that
@@ -201,6 +203,7 b' def _committedforwardcopies(a, b, match)'
201 if debug:
203 if debug:
202 dbg('debug.copies: search limit: %d\n' % limit)
204 dbg('debug.copies: search limit: %d\n' % limit)
203 am = a.manifest()
205 am = a.manifest()
206 basemf = None if base is None else base.manifest()
204
207
205 # find where new files came from
208 # find where new files came from
206 # we currently don't try to find where old files went, too expensive
209 # we currently don't try to find where old files went, too expensive
@@ -232,7 +235,7 b' def _committedforwardcopies(a, b, match)'
232
235
233 if debug:
236 if debug:
234 start = util.timer()
237 start = util.timer()
235 opath = _tracefile(fctx, am, limit)
238 opath = _tracefile(fctx, am, basemf, limit)
236 if opath:
239 if opath:
237 if debug:
240 if debug:
238 dbg('debug.copies: rename of: %s\n' % opath)
241 dbg('debug.copies: rename of: %s\n' % opath)
@@ -311,17 +314,19 b' def _changesetforwardcopies(a, b, match)'
311 heapq.heappush(work, (c, parent, newcopies))
314 heapq.heappush(work, (c, parent, newcopies))
312 assert False
315 assert False
313
316
314 def _forwardcopies(a, b, match=None):
317 def _forwardcopies(a, b, base=None, match=None):
315 """find {dst@b: src@a} copy mapping where a is an ancestor of b"""
318 """find {dst@b: src@a} copy mapping where a is an ancestor of b"""
316
319
320 if base is None:
321 base = a
317 match = a.repo().narrowmatch(match)
322 match = a.repo().narrowmatch(match)
318 # check for working copy
323 # check for working copy
319 if b.rev() is None:
324 if b.rev() is None:
320 cm = _committedforwardcopies(a, b.p1(), match)
325 cm = _committedforwardcopies(a, b.p1(), base, match)
321 # combine copies from dirstate if necessary
326 # combine copies from dirstate if necessary
322 copies = _chain(cm, _dirstatecopies(b._repo, match))
327 copies = _chain(cm, _dirstatecopies(b._repo, match))
323 else:
328 else:
324 copies = _committedforwardcopies(a, b, match)
329 copies = _committedforwardcopies(a, b, base, match)
325 return copies
330 return copies
326
331
327 def _backwardrenames(a, b, match):
332 def _backwardrenames(a, b, match):
@@ -369,8 +374,11 b' def pathcopies(x, y, match=None):'
369 else:
374 else:
370 if debug:
375 if debug:
371 repo.ui.debug('debug.copies: search mode: combined\n')
376 repo.ui.debug('debug.copies: search mode: combined\n')
377 base = None
378 if a.rev() != node.nullrev:
379 base = x
372 copies = _chain(_backwardrenames(x, a, match=match),
380 copies = _chain(_backwardrenames(x, a, match=match),
373 _forwardcopies(a, y, match=match))
381 _forwardcopies(a, y, base, match=match))
374 _filter(x, y, copies)
382 _filter(x, y, copies)
375 return copies
383 return copies
376
384
@@ -299,22 +299,10 b' above, but here the break in history is '
299 o 0 base
299 o 0 base
300 a
300 a
301 $ hg debugpathcopies 1 4
301 $ hg debugpathcopies 1 4
302 x -> y (no-filelog !)
302 x -> y
303 #if filelog
304 BROKEN: This should succeed and merge the changes from x into y
305 $ hg graft -r 2
306 grafting 2:* "modify x" (glob)
307 file 'x' was deleted in local [local] but was modified in other [graft].
308 What do you want to do?
309 use (c)hanged version, leave (d)eleted, or leave (u)nresolved? u
310 abort: unresolved conflicts, can't continue
311 (use 'hg resolve' and 'hg graft --continue')
312 [255]
313 #else
314 $ hg graft -r 2
303 $ hg graft -r 2
315 grafting 2:* "modify x" (glob)
304 grafting 2:* "modify x" (glob)
316 merging y and x to y
305 merging y and x to y
317 #endif
318 $ hg co -qC 2
306 $ hg co -qC 2
319 $ hg graft -r 4
307 $ hg graft -r 4
320 grafting 4:* "rename x to y"* (glob)
308 grafting 4:* "rename x to y"* (glob)
General Comments 0
You need to be logged in to leave comments. Login now