comparison mercurial/copies.py @ 42591:bcb4b5c5964b

copies: move short-circuiting of dirstate copies out of _forwardcopies() I'd like to move the filtering of copies we do after chaining to the end of all chaining (in a single place in pathcopies()). One problem that came up when trying that was that we allow things like `hg cp -f <file> <existing file>` so the user can later amend that in. Filtering at the end would mean that we remove those copies. That would break `hg st -C`. This patch therefore moves the short-circuiting of dirstate copies into pathcopies() so we can more easily handle the dirstate-only case differently. I initially thought this might change some behavior when the user does `hg status --rev 'wdir()' --rev .` during an uncommitted merge, since _backwardrenames() would reverse the copies in that case. However, I couldn't come up with a test case where it made a difference. Differential Revision: https://phab.mercurial-scm.org/D6600
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 28 Jun 2019 09:01:45 -0700
parents 4ebbd7c4a3c5
children a48f6f18dc6d
comparison
equal deleted inserted replaced
42590:ab416b5d9b91 42591:bcb4b5c5964b
322 """find {dst@b: src@a} copy mapping where a is an ancestor of b""" 322 """find {dst@b: src@a} copy mapping where a is an ancestor of b"""
323 323
324 match = a.repo().narrowmatch(match) 324 match = a.repo().narrowmatch(match)
325 # check for working copy 325 # check for working copy
326 if b.rev() is None: 326 if b.rev() is None:
327 if a == b.p1():
328 # short-circuit to avoid issues with merge states
329 return _dirstatecopies(b._repo, match)
330
331 cm = _committedforwardcopies(a, b.p1(), match) 327 cm = _committedforwardcopies(a, b.p1(), match)
332 # combine copies from dirstate if necessary 328 # combine copies from dirstate if necessary
333 return _chainandfilter(a, b, cm, _dirstatecopies(b._repo, match)) 329 return _chainandfilter(a, b, cm, _dirstatecopies(b._repo, match))
334 return _committedforwardcopies(a, b, match) 330 return _committedforwardcopies(a, b, match)
335 331
365 return {} 361 return {}
366 a = y.ancestor(x) 362 a = y.ancestor(x)
367 if a == x: 363 if a == x:
368 if debug: 364 if debug:
369 repo.ui.debug('debug.copies: search mode: forward\n') 365 repo.ui.debug('debug.copies: search mode: forward\n')
366 if y.rev() is None and x == y.p1():
367 # short-circuit to avoid issues with merge states
368 return _dirstatecopies(repo, match)
370 return _forwardcopies(x, y, match=match) 369 return _forwardcopies(x, y, match=match)
371 if a == y: 370 if a == y:
372 if debug: 371 if debug:
373 repo.ui.debug('debug.copies: search mode: backward\n') 372 repo.ui.debug('debug.copies: search mode: backward\n')
374 return _backwardrenames(x, y, match=match) 373 return _backwardrenames(x, y, match=match)