py3: fix infinitepush extension tests
authorMark Thomas <mbthomas@fb.com>
Sat, 13 Oct 2018 12:58:24 +0000
changeset 40252 090e5f3900b7
parent 40251 3c89227788a2
child 40253 682f73fa924a
py3: fix infinitepush extension tests Differential Revision: https://phab.mercurial-scm.org/D5078
contrib/python3-whitelist
hgext/infinitepush/__init__.py
hgext/infinitepush/common.py
hgext/infinitepush/store.py
--- a/contrib/python3-whitelist	Sat Oct 13 14:17:25 2018 +0200
+++ b/contrib/python3-whitelist	Sat Oct 13 12:58:24 2018 +0000
@@ -255,6 +255,9 @@
 test-import.t
 test-imports-checker.t
 test-incoming-outgoing.t
+test-infinitepush-bundlestore.t
+test-infinitepush-ci.t
+test-infinitepush.t
 test-inherit-mode.t
 test-init.t
 test-issue1089.t
--- a/hgext/infinitepush/__init__.py	Sat Oct 13 14:17:25 2018 +0200
+++ b/hgext/infinitepush/__init__.py	Sat Oct 13 12:58:24 2018 +0000
@@ -357,8 +357,7 @@
     if not self.capable('pushkey'):
         yield {}, None
     f = wireprotov1peer.future()
-    self.ui.debug('preparing listkeys for "%s" with pattern "%s"\n' %
-                  (namespace, patterns))
+    self.ui.debug('preparing listkeys for "%s"\n' % namespace)
     yield {
         'namespace': encoding.fromlocal(namespace),
         'patterns': wireprototypes.encodelist(patterns)
@@ -696,8 +695,8 @@
     return common, True, remoteheads
 
 def _push(orig, ui, repo, dest=None, *args, **opts):
-
-    bookmark = opts.get(r'bookmark')
+    opts = pycompat.byteskwargs(opts)
+    bookmark = opts.get('bookmark')
     # we only support pushing one infinitepush bookmark at once
     if len(bookmark) == 1:
         bookmark = bookmark[0]
@@ -718,7 +717,7 @@
         if scratchpush:
             # this is an infinitepush, we don't want the bookmark to be applied
             # rather that should be stored in the bundlestore
-            opts[r'bookmark'] = []
+            opts['bookmark'] = []
             ui.setconfig(experimental, configscratchpush, True)
             oldphasemove = extensions.wrapfunction(exchange,
                                                    '_localphasemove',
@@ -732,7 +731,7 @@
         # Remote scratch bookmarks will be deleted because remotenames doesn't
         # know about them. Let's save it before push and restore after
         remotescratchbookmarks = _readscratchremotebookmarks(ui, repo, destpath)
-        result = orig(ui, repo, dest, *args, **opts)
+        result = orig(ui, repo, dest, *args, **pycompat.strkwargs(opts))
         if common.isremotebooksenabled(ui):
             if bookmark and scratchpush:
                 other = hg.peer(repo, opts, destpath)
@@ -899,7 +898,7 @@
                 if part.type in ('pushkey', 'changegroup'):
                     if op.reply is not None:
                         rpart = op.reply.newpart('reply:%s' % part.type)
-                        rpart.addparam('in-reply-to', str(part.id),
+                        rpart.addparam('in-reply-to', b'%d' % part.id,
                                        mandatory=False)
                         rpart.addparam('return', '1', mandatory=False)
 
--- a/hgext/infinitepush/common.py	Sat Oct 13 14:17:25 2018 +0200
+++ b/hgext/infinitepush/common.py	Sat Oct 13 12:58:24 2018 +0000
@@ -33,7 +33,7 @@
     fd, bundlefile = pycompat.mkstemp()
     try:  # guards bundlefile
         try:  # guards fp
-            fp = os.fdopen(fd, 'wb')
+            fp = os.fdopen(fd, r'wb')
             fp.write(data)
         finally:
             fp.close()
--- a/hgext/infinitepush/store.py	Sat Oct 13 14:17:25 2018 +0200
+++ b/hgext/infinitepush/store.py	Sat Oct 13 12:58:24 2018 +0000
@@ -12,6 +12,7 @@
 import tempfile
 
 from mercurial import (
+    node,
     pycompat,
 )
 from mercurial.utils import (
@@ -80,7 +81,7 @@
         return os.path.join(self._dirpath(filename), filename)
 
     def write(self, data):
-        filename = hashlib.sha1(data).hexdigest()
+        filename = node.hex(hashlib.sha1(data).digest())
         dirpath = self._dirpath(filename)
 
         if not os.path.exists(dirpath):