Patchwork D6600: copies: move short-circuiting of dirstate copies out of _forwardcopies()

login
register
mail settings
Submitter phabricator
Date July 4, 2019, 3 p.m.
Message ID <differential-rev-PHID-DREV-aod52orcfblfy3xetnnl-req@mercurial-scm.org>
Download mbox | patch
Permalink /patch/40759/
State Superseded
Headers show

Comments

phabricator - July 4, 2019, 3 p.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  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.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6600

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel

Patch

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -324,10 +324,6 @@ 
     match = a.repo().narrowmatch(match)
     # check for working copy
     if b.rev() is None:
-        if a == b.p1():
-            # short-circuit to avoid issues with merge states
-            return _dirstatecopies(b._repo, match)
-
         cm = _committedforwardcopies(a, b.p1(), match)
         # combine copies from dirstate if necessary
         return _chainandfilter(a, b, cm, _dirstatecopies(b._repo, match))
@@ -367,6 +363,9 @@ 
     if a == x:
         if debug:
             repo.ui.debug('debug.copies: search mode: forward\n')
+        if y.rev() is None and x == y.p1():
+            # short-circuit to avoid issues with merge states
+            return _dirstatecopies(repo, match)
         return _forwardcopies(x, y, match=match)
     if a == y:
         if debug: