Patchwork [1,of,2] obsstore: `create` method return True if a marker is actually added

login
register
mail settings
Submitter Pierre-Yves David
Date Feb. 27, 2014, 3:28 a.m.
Message ID <2553363489703ae22fbd.1393471702@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/3783/
State Accepted
Commit 224a058f7cd10e0f17a7b31f3c2a63f9dfece5bd
Headers show

Comments

Pierre-Yves David - Feb. 27, 2014, 3:28 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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.
Matt Mackall - Feb. 27, 2014, 9:58 p.m.
On Wed, 2014-02-26 at 19:28 -0800, pierre-yves.david@ens-lyon.org wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@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

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
@@ -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.