[PATCH 1 of 2] obsolete: allow creating local prune markers that is not exchanged

Jun Wu quark at fb.com
Mon Mar 27 10:29:06 UTC 2017


# HG changeset patch
# User Jun Wu <quark at fb.com>
# Date 1490609835 25200
#      Mon Mar 27 03:17:15 2017 -0700
# Node ID a3e835b04db41230b02233d5c7c3f4dee49407d3
# Parent  e86eb75e74ce1b0803c26d86a229b9b711f6d76a
# Available At https://bitbucket.org/quark-zju/hg-draft
#              hg pull https://bitbucket.org/quark-zju/hg-draft -r a3e835b04db4
obsolete: allow creating local prune markers that is not exchanged

This allows us to do "safe strip" without worrying about the markers being
incorrectly exchanged to others.

This is supposed to be transitional. Once we have root-based hidden, we
could switch to writing hidden roots.

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -1213,4 +1213,7 @@ def createmarkers(repo, relations, flag=
     metadata specified through the `metadata` argument of this function,
 
+    The (<new>, ...) part could also be None, in that case, a local prune
+    marker will be created and it won't be exchanged.
+
     Trying to obsolete a public changeset will raise an exception.
 
@@ -1241,8 +1244,12 @@ def createmarkers(repo, relations, flag=
                                  hint="see 'hg help phases' for details")
             nprec = prec.node()
-            nsucs = tuple(s.node() for s in sucs)
             npare = None
-            if not nsucs:
-                npare = tuple(p.node() for p in prec.parents())
+            if sucs is None:
+                # a local "prune" marker that will not be exchanged
+                nsucs = ()
+            else:
+                nsucs = tuple(s.node() for s in sucs)
+                if not nsucs:
+                    npare = tuple(p.node() for p in prec.parents())
             if nprec in nsucs:
                 raise error.Abort(_("changeset %s cannot obsolete itself")


More information about the Mercurial-devel mailing list