[PATCH 1 of 2] obsstore: `create` method return True if a marker is actually added
pierre-yves.david at ens-lyon.org
pierre-yves.david at ens-lyon.org
Thu Feb 27 03:28:22 UTC 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1393352514 28800
# Tue Feb 25 10:21:54 2014 -0800
# Node ID 2553363489703ae22fbdb3b979be0bd34d9370c5
# Parent 0ad353831461516132f57ccda8e8e0515213ec60
obsstore: `create` method return True if a marker is actually added
The obsstore method now have a return value. This informs caller about the
actual creation of a new markers. No new markers are created if it would have
been a duplicate.
diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -257,10 +257,13 @@ class obsstore(object):
* check mandatory metadata
* encode metadata
If you are a human writing code creating marker you want to use the
`createmarkers` function in this module instead.
+
+ return True if a new marker have been added, False if the markers
+ already existed (no op).
"""
if metadata is None:
metadata = {}
if 'date' not in metadata:
metadata['date'] = "%d %d" % util.makedate()
@@ -268,11 +271,11 @@ class obsstore(object):
raise ValueError(prec)
for succ in succs:
if len(succ) != 20:
raise ValueError(succ)
marker = (str(prec), tuple(succs), int(flag), encodemeta(metadata))
- self.add(transaction, [marker])
+ return bool(self.add(transaction, [marker]))
def add(self, transaction, markers):
"""Add new markers to the store
Take care of filtering duplicate.
More information about the Mercurial-devel
mailing list