# HG changeset patch # User Pierre-Yves David # Date 2014-02-14 01:34:09 # Node ID 2158e8f3cbd29513486bb1eaa48b484c1db27269 # Parent 3af218cf20079a51bfb9df393b3bac334b77b6f9 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) diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py --- a/mercurial/obsolete.py +++ b/mercurial/obsolete.py @@ -811,8 +811,10 @@ def _computedivergentset(repo): def createmarkers(repo, relations, flag=0, metadata=None): """Add obsolete markers between changesets in a repo - must be an iterable of (, (, ...)) tuple. - `old` and `news` are changectx. + must be an iterable of (, (, ...)[,{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. @@ -831,7 +833,13 @@ def createmarkers(repo, relations, flag= 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) @@ -839,7 +847,7 @@ def createmarkers(repo, relations, flag= 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: