copies: group wdir-handling in one place
authorMartin von Zweigbergk <martinvonz@google.com>
Thu, 14 Dec 2017 00:25:03 -0800
changeset 35423 e54f02ec6a05
parent 35422 8801cdcea01f
child 35424 702e6d2642e7
copies: group wdir-handling in one place I think this makes it both easier to follow and shorter. Differential Revision: https://phab.mercurial-scm.org/D1698
mercurial/copies.py
--- a/mercurial/copies.py	Thu Dec 14 00:18:38 2017 -0800
+++ b/mercurial/copies.py	Thu Dec 14 00:25:03 2017 -0800
@@ -195,21 +195,15 @@
     """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))
+    return _committedforwardcopies(a, b, match)
 
 def _backwardrenames(a, b):
     if a._repo.ui.config('experimental', 'copytrace') == 'off':