compat: also import datestr from dateutil
authorAnton Shestakov <av6@dwimlabs.net>
Wed, 15 Jan 2020 15:28:44 +0700
changeset 5073 609ff25fce29
parent 5072 3c1a5754d983
child 5075 fbe614cae40c
compat: also import datestr from dateutil
hgext3rd/evolve/cmdrewrite.py
hgext3rd/evolve/compat.py
--- a/hgext3rd/evolve/cmdrewrite.py	Mon Jan 13 15:36:24 2020 +0700
+++ b/hgext3rd/evolve/cmdrewrite.py	Wed Jan 15 15:28:44 2020 +0700
@@ -35,11 +35,6 @@
 
 from mercurial.i18n import _
 
-try:
-    from mercurial.utils.dateutil import datestr
-except ImportError: # hg <= 4.5
-    from mercurial.util import datestr
-
 from . import (
     compat,
     state,
@@ -272,7 +267,7 @@
     fp.write(b"# HG changeset patch\n")
     fp.write(b"# User %s\n" % ctx.user())
     fp.write(b"# Date %d %d\n" % ctx.date())
-    fp.write(b"#      %s\n" % datestr(ctx.date()))
+    fp.write(b"#      %s\n" % compat.datestr(ctx.date()))
     if branch and branch != b'default':
         fp.write(b"# Branch %s\n" % branch)
     fp.write(b"# Node ID %s\n" % node.hex(nodeval))
--- a/hgext3rd/evolve/compat.py	Mon Jan 13 15:36:24 2020 +0700
+++ b/hgext3rd/evolve/compat.py	Wed Jan 15 15:28:44 2020 +0700
@@ -130,10 +130,12 @@
 # hg <= 4.5 (c6061cadb400)
 try:
     import mercurial.utils.dateutil
+    datestr = mercurial.utils.dateutil.datestr
     makedate = mercurial.utils.dateutil.makedate
     parsedate = mercurial.utils.dateutil.parsedate
 except ImportError:
     import mercurial.util
+    datestr = mercurial.util.datestr  # pytype: disable=module-attr
     makedate = mercurial.util.makedate  # pytype: disable=module-attr
     parsedate = mercurial.util.parsedate  # pytype: disable=module-attr