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

login
register
mail settings
Submitter Jun Wu
Date March 27, 2017, 10:29 a.m.
Message ID <a3e835b04db41230b022.1490610546@localhost.localdomain>
Download mbox | patch
Permalink /patch/19753/
State Deferred
Headers show

Comments

Jun Wu - March 27, 2017, 10:29 a.m.
# HG changeset patch
# User Jun Wu <quark@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.

Patch

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")