D5078: py3: fix infinitepush extension tests

mbthomas (Mark Thomas) phabricator at mercurial-scm.org
Sat Oct 13 09:04:38 EDT 2018


mbthomas updated this revision to Diff 12075.
mbthomas added a comment.


  Use a different function for getting hexdigest as bytes

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D5078?vs=12067&id=12075

BRANCH
  default

REVISION DETAIL
  https://phab.mercurial-scm.org/D5078

AFFECTED FILES
  contrib/python3-whitelist
  hgext/infinitepush/__init__.py
  hgext/infinitepush/common.py
  hgext/infinitepush/store.py

CHANGE DETAILS

diff --git a/hgext/infinitepush/store.py b/hgext/infinitepush/store.py
--- a/hgext/infinitepush/store.py
+++ b/hgext/infinitepush/store.py
@@ -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):
diff --git a/hgext/infinitepush/common.py b/hgext/infinitepush/common.py
--- a/hgext/infinitepush/common.py
+++ b/hgext/infinitepush/common.py
@@ -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()
diff --git a/hgext/infinitepush/__init__.py b/hgext/infinitepush/__init__.py
--- a/hgext/infinitepush/__init__.py
+++ b/hgext/infinitepush/__init__.py
@@ -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)
 
diff --git a/contrib/python3-whitelist b/contrib/python3-whitelist
--- a/contrib/python3-whitelist
+++ b/contrib/python3-whitelist
@@ -239,6 +239,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



To: mbthomas, pulkit, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list