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

login
register
mail settings
Submitter Pierre-Yves David
Date Aug. 16, 2014, 12:33 a.m.
Message ID <545b8965d9e13e4f81a6.1408149205@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/5440/
State Accepted
Headers show

Comments

Pierre-Yves David - Aug. 16, 2014, 12:33 a.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@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.

Patch

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)