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

login
register
mail settings
Submitter Bryan O'Sullivan
Date May 28, 2013, 11:28 p.m.
Message ID <11fce4dc68f060e96cc0.1369783736@australite.thefacebook.com>
Download mbox | patch
Permalink /patch/1670/
State Accepted
Commit 8b04e1344111ba696ff7cfaa59a48966b43332ee
Headers show

Comments

Bryan O'Sullivan - May 28, 2013, 11:28 p.m.
# HG changeset patch
# User Bryan O'Sullivan <bryano@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.

Patch

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)