# HG changeset patch # User Boris Feld # Date 1520137046 18000 # Node ID 498f782ccb4b614b82becd2aa4a256747fb2936f # Parent b1cc19e5ef2404a166803afb887e0d228f357d77 compat: add compat layer for date related functions diff -r b1cc19e5ef24 -r 498f782ccb4b hgext3rd/evolve/cmdrewrite.py --- a/hgext3rd/evolve/cmdrewrite.py Sat Mar 03 22:25:24 2018 -0500 +++ b/hgext3rd/evolve/cmdrewrite.py Sat Mar 03 23:17:26 2018 -0500 @@ -74,7 +74,7 @@ """ # N.B. this is extremely similar to setupheaderopts() in mq.py if not opts.get('date') and opts.get('current_date'): - opts['date'] = '%d %d' % util.makedate() + opts['date'] = '%d %d' % compat.makedate() if not opts.get('user') and opts.get('current_user'): opts['user'] = ui.username() @@ -771,7 +771,7 @@ date = opts.get('date') user = opts.get('user') if date: - metadata['date'] = '%i %i' % util.parsedate(date) + metadata['date'] = '%i %i' % compat.parsedate(date) if user: metadata['user'] = user return metadata diff -r b1cc19e5ef24 -r 498f782ccb4b hgext3rd/evolve/compat.py --- a/hgext3rd/evolve/compat.py Sat Mar 03 22:25:24 2018 -0500 +++ b/hgext3rd/evolve/compat.py Sat Mar 03 23:17:26 2018 -0500 @@ -254,3 +254,14 @@ args.append(False) return mdiff.unidiff(*args) + +# date related + +try: + import mercurial.utils.dateutil + makedate = mercurial.utils.dateutil.makedate + parsedate = mercurial.utils.dateutil.parsedate +except ImportError as e: + import mercurial.util + makedate = mercurial.util.makedate + parsedate = mercurial.util.parsedate diff -r b1cc19e5ef24 -r 498f782ccb4b hgext3rd/evolve/legacy.py --- a/hgext3rd/evolve/legacy.py Sat Mar 03 22:25:24 2018 -0500 +++ b/hgext3rd/evolve/legacy.py Sat Mar 03 23:17:26 2018 -0500 @@ -30,6 +30,12 @@ from mercurial import registrar from mercurial import util +try: + from mercurial.utils.dateutil import makedate +except ImportError as e: + # compat with hg < 4.6 + from mercurial.util import makedate + if util.safehasattr(registrar, 'command'): commandfunc = registrar.command else: # compat with hg < 4.3 @@ -105,7 +111,7 @@ prec = bin(objhex) sucs = (suc == nullid) and [] or [suc] meta = { - 'date': '%i %i' % util.makedate(), + 'date': '%i %i' % makedate(), 'user': ui.username(), } try: