Patchwork D1698: copies: group wdir-handling in one place

login
register
mail settings
Submitter phabricator
Date Dec. 15, 2017, 1:02 a.m.
Message ID <differential-rev-PHID-DREV-yq2ttmr3iac5lh2x6uwz-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26294/
State Superseded
Headers show

Comments

phabricator - Dec. 15, 2017, 1:02 a.m.
martinvonz created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  I think this makes it both easier to follow and shorter.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  mercurial/copies.py

CHANGE DETAILS




To: martinvonz, #hg-reviewers
Cc: mercurial-devel
phabricator - Dec. 15, 2017, 1:39 p.m.
yuja added a comment.


  Nice. Queued, thanks.

REPOSITORY
  rHG Mercurial

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

To: martinvonz, #hg-reviewers, yuja
Cc: mercurial-devel
phabricator - Dec. 15, 2017, 4:26 p.m.
krbullock added inline comments.

INLINE COMMENTS

> copies.py:206
> +        return _chain(a, b, cm, _dirstatecopies(b, match))
> +    else:
> +        return _committedforwardcopies(a, b, match)

Post-queue nitpick: unnecessary `else:`.

REPOSITORY
  rHG Mercurial

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

To: martinvonz, #hg-reviewers, yuja
Cc: krbullock, mercurial-devel
phabricator - Dec. 15, 2017, 4:41 p.m.
martinvonz added inline comments.

INLINE COMMENTS

> krbullock wrote in copies.py:206
> Post-queue nitpick: unnecessary `else:`.

Feel free to update

REPOSITORY
  rHG Mercurial

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

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

Patch

diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -195,21 +195,16 @@ 
     """find {dst@b: src@a} copy mapping where a is an ancestor of b"""
 
     # check for working copy
-    w = None
     if b.rev() is None:
-        w = b
-        b = w.p1()
-        if a == b:
+        if a == b.p1():
             # short-circuit to avoid issues with merge states
-            return _dirstatecopies(w, match)
+            return _dirstatecopies(b, match)
 
-    cm = _committedforwardcopies(a, b, match)
-
-    # combine copies from dirstate if necessary
-    if w is not None:
-        cm = _chain(a, w, cm, _dirstatecopies(w, match))
-
-    return cm
+        cm = _committedforwardcopies(a, b.p1(), match)
+        # combine copies from dirstate if necessary
+        return _chain(a, b, cm, _dirstatecopies(b, match))
+    else:
+        return _committedforwardcopies(a, b, match)
 
 def _backwardrenames(a, b):
     if a._repo.ui.config('experimental', 'copytrace') == 'off':