Patchwork [2,of,3,STABLE] adjustlinkrev: handle 'None' value as source

login
register
mail settings
Submitter Pierre-Yves David
Date March 20, 2015, 7:41 a.m.
Message ID <2863d21af964d0ff594f.1426837294@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/8200/
State Accepted
Commit 5a12ef618c03fc06ad1728e2df7481b20ad656ba
Headers show

Comments

Pierre-Yves David - March 20, 2015, 7:41 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1426834654 25200
#      Thu Mar 19 23:57:34 2015 -0700
# Branch stable
# Node ID 2863d21af964d0ff594f9cfb7e2411280716398e
# Parent  0bfd0d3ee74a21535874ca4d8cd71cd877366f78
adjustlinkrev: handle 'None' value as source

When the source rev value is 'None', the ctx is a working context. We cannot
compute the ancestors from there so we directly skip to its parents. This will
be necessary to allow 'None' value for '_descendantrev' itself necessary to make
all contexts used in 'mergecopies' reuse the same '_ancestrycontext'.

Patch

diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -772,13 +772,19 @@  class basefilectx(object):
         fr = filelog.rev(fnode)
         lkr = filelog.linkrev(fr)
         # hack to reuse ancestor computation when searching for renames
         memberanc = getattr(self, '_ancestrycontext', None)
         iteranc = None
-        revs = [srcrev]
+        if srcrev is None:
+            # wctx case, used by workingfilectx during mergecopy
+            revs = [p.rev() for p in self._repo[None].parents()]
+            inclusive = True # we skipped the real (revless) source
+        else:
+            revs = [srcrev]
         if memberanc is None:
-            memberanc = iteranc = cl.ancestors(revs, lkr, inclusive=inclusive)
+            memberanc = iteranc = cl.ancestors(revs, lkr,
+                                               inclusive=inclusive)
         # check if this linkrev is an ancestor of srcrev
         if lkr not in memberanc:
             if iteranc is None:
                 iteranc = cl.ancestors(revs, lkr, inclusive=inclusive)
             for a in iteranc: