[PATCH 3 of 8] obsstore: add an explicit `date` argument to obsstore.create

Pierre-Yves David pierre-yves.david at ens-lyon.org
Fri Aug 15 19:33:25 CDT 2014


# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1407995087 25200
#      Wed Aug 13 22:44:47 2014 -0700
# Node ID 545b8965d9e13e4f81a61f5fd4715d2916b3a167
# Parent  543cc6d8c5bb067d4a41bb72516ef2933ce6bb77
obsstore: add an explicit `date` argument to obsstore.create

The date will become an official field in the markers (and ultimately in the on
disk format) We start by making it an official argument for the function.

diff --git a/mercurial/obsolete.py b/mercurial/obsolete.py
--- a/mercurial/obsolete.py
+++ b/mercurial/obsolete.py
@@ -257,11 +257,12 @@ class obsstore(object):
         return len(self._all)
 
     def __nonzero__(self):
         return bool(self._all)
 
-    def create(self, transaction, prec, succs=(), flag=0, metadata=None):
+    def create(self, transaction, prec, succs=(), flag=0, date=None,
+               metadata=None):
         """obsolete: add a new obsolete marker
 
         * ensuring it is hashable
         * check mandatory metadata
         * encode metadata
@@ -273,11 +274,13 @@ class obsstore(object):
         already existed (no op).
         """
         if metadata is None:
             metadata = {}
         if 'date' not in metadata:
-            metadata['date'] = "%d %d" % util.makedate()
+            if date is None:
+                date = util.makedate()
+            metadata['date'] = "%d %d" % date
         if len(prec) != 20:
             raise ValueError(prec)
         for succ in succs:
             if len(succ) != 20:
                 raise ValueError(succ)


More information about the Mercurial-devel mailing list