Patchwork [2,of,2] createmarkers: allow to pass metadata for a marker only

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 14, 2014, 11:47 p.m.
Message ID <9e01ab2a3ba9cd5df2bb.1392421673@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/3663/
State Accepted
Commit 2158e8f3cbd29513486bb1eaa48b484c1db27269
Headers show

Comments

Pierre-Yves David - Feb. 14, 2014, 11:47 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@logilab.fr>
# Date 1392341649 28800
#      Thu Feb 13 17:34:09 2014 -0800
# Node ID 9e01ab2a3ba9cd5df2bb3da8efa28df92e7b5ab5
# Parent  1bfd796fc968827d75b20abb7ef9d8d27d7d8e68
createmarkers: allow to pass metadata for a marker only

The `metadata` argument only allow to specify metadata for all new markers. We
extension the format of the `relations` argument to support optional metadata
argument.

The first user of this should be the evolve extension who want to store parent
information of pruned changeset in extra (until we make a second version of the
format)
Matt Mackall - Feb. 16, 2014, 3:58 a.m.
On Fri, 2014-02-14 at 15:47 -0800, pierre-yves.david@ens-lyon.org wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@logilab.fr>
> # Date 1392341649 28800
> #      Thu Feb 13 17:34:09 2014 -0800
> # Node ID 9e01ab2a3ba9cd5df2bb3da8efa28df92e7b5ab5
> # Parent  1bfd796fc968827d75b20abb7ef9d8d27d7d8e68
> createmarkers: allow to pass metadata for a marker only

These are queued for default, thanks.

Patch

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -809,12 +809,14 @@  def _computedivergentset(repo):
 
 
 def createmarkers(repo, relations, flag=0, metadata=None):
     """Add obsolete markers between changesets 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>, ...)[,{metadata}])
+    tuple. `old` and `news` are changectx. metadata is an optional dictionnary
+    containing metadata for this marker only. It is merged with the global
+    metadata specified through the `metadata` argument of this function,
 
     Trying to obsolete a public changeset will raise an exception.
 
     Current user and date are used except if specified otherwise in the
     metadata attribute.
@@ -829,18 +831,24 @@  def createmarkers(repo, relations, flag=
         metadata['date'] = '%i %i' % util.makedate()
     if 'user' not in metadata:
         metadata['user'] = repo.ui.username()
     tr = repo.transaction('add-obsolescence-marker')
     try:
-        for prec, sucs in relations:
+        for rel in relations:
+            prec = rel[0]
+            sucs = rel[1]
+            localmetadata = metadata.copy()
+            if 2 < len(rel):
+                localmetadata.update(rel[2])
+
             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 itself" % prec)
-            repo.obsstore.create(tr, nprec, nsucs, flag, metadata)
+            repo.obsstore.create(tr, nprec, nsucs, flag, localmetadata)
             repo.filteredrevcache.clear()
         tr.close()
     finally:
         tr.release()