[PATCH 3 of 4] util: add an optional timestamp parameter to makedate

Bryan O'Sullivan bos at serpentine.com
Tue May 28 18:28:56 CDT 2013


# HG changeset patch
# User Bryan O'Sullivan <bryano at fb.com>
# Date 1369782696 25200
#      Tue May 28 16:11:36 2013 -0700
# Node ID 11fce4dc68f060e96cc06cc88da72e2c9da1022b
# Parent  bda65f9dee92fa105cc79061e01c172044ac6a2f
util: add an optional timestamp parameter to makedate

This will be used by the upcoming shelve extension.

diff --git a/mercurial/util.py b/mercurial/util.py
--- a/mercurial/util.py
+++ b/mercurial/util.py
@@ -997,10 +997,11 @@ def filechunkiter(f, size=65536, limit=N
             limit -= len(s)
         yield s
 
-def makedate():
-    '''Return the current time as a (unixtime, offset) tuple based off
-    the local timezone.'''
-    timestamp = time.time()
+def makedate(timestamp=None):
+    '''Return a unix timestamp (or the current time) as a (unixtime,
+    offset) tuple based off the local timezone.'''
+    if timestamp is None:
+        timestamp = time.time()
     if timestamp < 0:
         hint = _("check your clock")
         raise Abort(_("negative timestamp: %d") % timestamp, hint=hint)


More information about the Mercurial-devel mailing list