Commits

Pierre-Yves David  committed e29561d

createmarkers: adapt to f85816af6294 in core

The createmarkers function is now in core. Fallback on our function if not
available

  • Participants
  • Parent commits f7e54d4
  • Branches stable

Comments (0)

Files changed (2)

File hgext/evolve.py

 # - function to find useful changeset to stabilize
 
 ### Marker Create
+# NOW IN CORE f85816af6294
+try:
+    createmarkers = obsolete.createmarkers
+except AttributeError:
+    def createmarkers(repo, relations, metadata=None, flag=0):
+        """Add obsolete markers between changeset in a repo
 
-def createmarkers(repo, relations, metadata=None, flag=0):
-    """Add obsolete markers between changeset in a repo
+        <relations> must be an iterable of (<old>, (<new>, ...)) tuple.
+        `old` and `news` are changectx.
 
-    <relations> must be an iterable of (<old>, (<new>, ...)) tuple.
-    `old` and `news` are changectx.
+        Current user and date are used except if specified otherwise in the
+        metadata attribute.
 
-    Current user and date are used except if specified otherwise in the
-    metadata attribute.
-
-    /!\ assume the repo have been locked by the user /!\
-    """
-    # prepare metadata
-    if metadata is None:
-        metadata = {}
-    if 'date' not in metadata:
-        metadata['date'] = '%i %i' % util.makedate()
-    if 'user' not in metadata:
-        metadata['user'] = repo.ui.username()
-    # check future marker
-    tr = repo.transaction('add-obsolescence-marker')
-    try:
-        for prec, sucs in relations:
-            if not prec.mutable():
-                raise util.Abort("Cannot obsolete immutable changeset: %s" % prec)
-            nprec = prec.node()
-            nsucs = tuple(s.node() for s in sucs)
-            if nprec in nsucs:
-                raise util.Abort("Changeset %s cannot obsolete himself" % prec)
-            repo.obsstore.create(tr, nprec, nsucs, flag, metadata)
-            clearobscaches(repo)
-        tr.close()
-    finally:
-        tr.release()
+        /!\ assume the repo have been locked by the user /!\
+        """
+        # prepare metadata
+        if metadata is None:
+            metadata = {}
+        if 'date' not in metadata:
+            metadata['date'] = '%i %i' % util.makedate()
+        if 'user' not in metadata:
+            metadata['user'] = repo.ui.username()
+        # check future marker
+        tr = repo.transaction('add-obsolescence-marker')
+        try:
+            for prec, sucs in relations:
+                if not prec.mutable():
+                    raise util.Abort("cannot obsolete immutable changeset: %s" % prec)
+                nprec = prec.node()
+                nsucs = tuple(s.node() for s in sucs)
+                if nprec in nsucs:
+                    raise util.Abort("changeset %s cannot obsolete himself" % prec)
+                repo.obsstore.create(tr, nprec, nsucs, flag, metadata)
+                clearobscaches(repo)
+            tr.close()
+        finally:
+            tr.release()
 
 
 ### Useful alias

File tests/test-evolve.t

   $ hg log -r 1 --template '{rev} {phase} {obsolete}\n'
   1 public stable
   $ hg kill 1
-  abort: Cannot obsolete immutable changeset: 7c3bad9141dc
+  abort: cannot obsolete immutable changeset: 7c3bad9141dc
   [255]
   $ hg log -r 1 --template '{rev} {phase} {obsolete}\n'
   1 public stable