changeset 1130:80664524802b

compat: add compatibility for 4.6 mercurial.utils
author Sean Farley <sean@farley.io>
date Thu, 24 May 2018 11:26:15 +0200
parents 5edabf9db748
children 9cbf81bb5e27
files hggit/_ssh.py hggit/compat.py hggit/overlay.py
diffstat 3 files changed, 19 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/hggit/_ssh.py	Thu May 24 09:50:04 2018 +0200
+++ b/hggit/_ssh.py	Thu May 24 11:26:15 2018 +0200
@@ -1,9 +1,6 @@
 from dulwich.client import SubprocessWrapper
 import subprocess
-
-from mercurial import (
-    util,
-)
+import compat
 
 
 class SSHVendor(object):
@@ -27,11 +24,11 @@
                 # expects (e.g. "command 'arg1 arg2'")
                 command = ["%s '%s'" % (command[0], ' '.join(command[1:]))]
             sshcmd = ui.config("ui", "ssh", "ssh")
-            args = util.sshargs(sshcmd, host, username, port)
+            args = compat.sshargs(sshcmd, host, username, port)
             cmd = '%s %s %s' % (sshcmd, args,
-                                util.shellquote(' '.join(command)))
+                                compat.shellquote(' '.join(command)))
             ui.debug('calling ssh: %s\n' % cmd)
-            proc = subprocess.Popen(util.quotecommand(cmd), shell=True,
+            proc = subprocess.Popen(compat.quotecommand(cmd), shell=True,
                                     stdin=subprocess.PIPE,
                                     stdout=subprocess.PIPE)
             return SubprocessWrapper(proc)
--- a/hggit/compat.py	Thu May 24 09:50:04 2018 +0200
+++ b/hggit/compat.py	Thu May 24 11:26:15 2018 +0200
@@ -37,6 +37,19 @@
     from mercurial import scmutil
     hgvfs = scmutil.vfs
 
+try:
+    from mercurial.utils import procutil, stringutil
+    sshargs = procutil.sshargs
+    shellquote = procutil.shellquote
+    quotecommand = procutil.quotecommand
+    binary = stringutil.binary
+except ImportError:
+    # these were moved in 4.6
+    sshargs = hgutil.sshargs
+    shellquote = hgutil.shellquote
+    quotecommand = hgutil.quotecommand
+    binary = hgutil.binary
+
 
 def gitvfs(repo):
     """return a vfs suitable to read git related data"""
--- a/hggit/overlay.py	Thu May 24 09:50:04 2018 +0200
+++ b/hggit/overlay.py	Thu May 24 11:26:15 2018 +0200
@@ -14,6 +14,7 @@
 )
 from mercurial.node import bin, hex, nullid
 
+import compat
 
 def _maybehex(n):
     if len(n) == 20:
@@ -207,7 +208,7 @@
         return blob.data
 
     def isbinary(self):
-        return util.binary(self.data())
+        return compat.binary(self.data())
 
 
 class overlaychangectx(context.changectx):