[PATCH 11 of 13] obsolete: allow multiple predecessors in createmarkers

Boris Feld boris.feld at octobus.net
Thu Sep 27 13:08:43 EDT 2018


# HG changeset patch
# User Boris Feld <boris.feld at octobus.net>
# Date 1537620033 -7200
#      Sat Sep 22 14:40:33 2018 +0200
# Node ID 84585c803b4156717b397e3753fc59e9dc3785d8
# Parent  b3bd71652d1258de723a667a6f1210a27b86b019
# EXP-Topic trackfold
# Available At https://bitbucket.org/octobus/mercurial-devel/
#              hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 84585c803b41
obsolete: allow multiple predecessors in createmarkers

The logic for this change is similar to the change to `cleanupnodes` that we
did earlier. Now that the rebase code is trying to record a fold, we need to
actually record it in the markers. The first step is to have the markers
creation API able to receive such fold data.

To keep things sane, we restrict fold to on successors.

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -959,7 +959,7 @@ def createmarkers(repo, relations, flag=
                   operation=None):
     """Add obsolete markers between changesets in a repo
 
-    <relations> must be an iterable of (<old>, (<new>, ...)[,{metadata}])
+    <relations> must be an iterable of ((<old>,...), (<new>, ...)[,{metadata}])
     tuple. `old` and `news` are changectx. metadata is an optional dictionary
     containing metadata for this marker only. It is merged with the global
     metadata specified through the `metadata` argument of this function.
@@ -993,8 +993,14 @@ def createmarkers(repo, relations, flag=
     with repo.transaction('add-obsolescence-marker') as tr:
         markerargs = []
         for rel in relations:
-            prec = rel[0]
-            if True:
+            predecessors = rel[0]
+            if not isinstance(predecessors, tuple):
+                # preserve compat with old API until all caller are migrated
+                predecessors = (predecessors,)
+            if 1 < len(predecessors) and len(rel[1]) != 1:
+                msg = 'Fold markers can only have 1 successors, not %d'
+                raise error.ProgrammingError(msg % len(rel[1]))
+            for prec in predecessors:
                 sucs = rel[1]
                 localmetadata = metadata.copy()
                 if 2 < len(rel):


More information about the Mercurial-devel mailing list