compat: access datestr in a way compatible with verison prior to 4.6
authorPierre-Yves David <pierre-yves.david@octobus.net>
Tue, 17 Apr 2018 19:42:46 +0200
changeset 3675 1dccccde82bb
parent 3674 51adc7e6a617
child 3676 cded30ad25e4
compat: access datestr in a way compatible with verison prior to 4.6
hgext3rd/evolve/cmdrewrite.py
--- a/hgext3rd/evolve/cmdrewrite.py	Tue Apr 17 19:42:26 2018 +0200
+++ b/hgext3rd/evolve/cmdrewrite.py	Tue Apr 17 19:42:46 2018 +0200
@@ -34,7 +34,10 @@
 
 from mercurial.i18n import _
 
-from mercurial.utils import dateutil
+try:
+    from mercurial.utils.dateutil import datestr
+except ImportError: # hg <= 4.5
+    from mercurial.util import datestr
 
 from . import (
     compat,
@@ -277,7 +280,7 @@
     fp.write("# HG changeset patch\n")
     fp.write("# User %s\n" % ctx.user())
     fp.write("# Date %d %d\n" % ctx.date())
-    fp.write("#      %s\n" % dateutil.datestr(ctx.date()))
+    fp.write("#      %s\n" % datestr(ctx.date()))
     if branch and branch != 'default':
         fp.write("# Branch %s\n" % branch)
     fp.write("# Node ID %s\n" % node.hex(nodeval))