changeset 1572:51e105c7f0c6

compathacks: deal with removed aliases in mercurial.util
author Augie Fackler <raf@durin42.com>
date Sun, 27 May 2018 00:29:38 -0400
parents f8ca09a97492
children bb09e8a230d6
files hgsubversion/compathacks.py hgsubversion/pushmod.py hgsubversion/svncommands.py
diffstat 3 files changed, 19 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/hgsubversion/compathacks.py
+++ b/hgsubversion/compathacks.py
@@ -152,3 +152,15 @@ class _funcregistrarbase(object):
         """Execute exra setup for registered function, if needed
         """
         pass
+
+try:
+    binary = util.binary
+except AttributeError:
+    from mercurial.utils import stringutil
+    binary = stringutil.binary
+
+try:
+    datestr = util.datestr
+except AttributeError:
+    from mercurial.utils import dateutil
+    datestr = dateutil.datestr
--- a/hgsubversion/pushmod.py
+++ b/hgsubversion/pushmod.py
@@ -1,6 +1,7 @@
 from mercurial import error as hgerror
 from mercurial import util as hgutil
 
+import compathacks
 import svnwrap
 import svnexternals
 import util
@@ -123,7 +124,7 @@ def commit(ui, repo, rev_ctx, meta, base
                 props.setdefault(file, {})['svn:executable'] = '*'
             if 'l' in fctx.flags():
                 props.setdefault(file, {})['svn:special'] = '*'
-            isbinary = hgutil.binary(new_data)
+            isbinary = compathacks.binary(new_data)
             if isbinary:
                 props.setdefault(file, {})['svn:mime-type'] = 'application/octet-stream'
 
@@ -151,7 +152,7 @@ def commit(ui, repo, rev_ctx, meta, base
                     base_data = 'link ' + base_data
                     if 'l' not in rev_ctx.filectx(file).flags():
                         props.setdefault(file, {})['svn:special'] = None
-                if hgutil.binary(base_data) and not isbinary:
+                if compathacks.binary(base_data) and not isbinary:
                     props.setdefault(file, {})['svn:mime-type'] = None
                 action = 'modify'
         else:
--- a/hgsubversion/svncommands.py
+++ b/hgsubversion/svncommands.py
@@ -9,6 +9,7 @@ from mercurial import node
 from mercurial import util as hgutil
 from mercurial import error
 
+import compathacks
 import svnwrap
 import svnrepo
 import util
@@ -403,8 +404,9 @@ Last Changed Date: %(date)s\n''' %
                'author': author,
                'revision': r,
                # TODO I'd like to format this to the user's local TZ if possible
-               'date': hgutil.datestr(parent.date(),
-                                      '%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)')
+               'date': compathacks.datestr(
+                   parent.date(),
+                   '%Y-%m-%d %H:%M:%S %1%2 (%a, %d %b %Y)')
               })