changeset 28585:a3f3fdac8433

node: use byte literals to construct nullid and wdirid Python 3's hex() insists on operating on bytes. This patch gives it what it wants. '' and b'' in Python 2 are equivalent, so this has no impact on Python 2.
author Gregory Szorc <gregory.szorc@gmail.com>
date Sat, 12 Mar 2016 14:04:57 -0800
parents d69172ddfdca
children 82cee85d5274
files mercurial/node.py tests/test-check-py3-compat.t
diffstat 2 files changed, 48 insertions(+), 55 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/node.py	Sat Mar 12 14:05:23 2016 -0800
+++ b/mercurial/node.py	Sat Mar 12 14:04:57 2016 -0800
@@ -14,13 +14,13 @@
 bin = binascii.unhexlify
 
 nullrev = -1
-nullid = "\0" * 20
+nullid = b"\0" * 20
 nullhex = hex(nullid)
 
 # pseudo identifiers for working directory
 # (they are experimental, so don't add too many dependencies on them)
 wdirrev = 0x7fffffff
-wdirid = "\xff" * 20
+wdirid = b"\xff" * 20
 
 def short(node):
     return hex(node[:6])
--- a/tests/test-check-py3-compat.t	Sat Mar 12 14:05:23 2016 -0800
+++ b/tests/test-check-py3-compat.t	Sat Mar 12 14:04:57 2016 -0800
@@ -127,9 +127,9 @@
   doc/hgmanpage.py: invalid syntax: invalid syntax (<unknown>, line 286)
   hgext/acl.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   hgext/automv.py: error importing module: <SyntaxError> invalid syntax (commands.py, line 3324) (line 29)
-  hgext/blackbox.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  hgext/blackbox.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
   hgext/bugzilla.py: error importing module: <ImportError> No module named 'urlparse' (line 284)
-  hgext/censor.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  hgext/censor.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
   hgext/chgserver.py: error importing module: <ImportError> No module named 'SocketServer' (line 43)
   hgext/children.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
   hgext/churn.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
@@ -137,7 +137,7 @@
   hgext/color.py: invalid syntax: invalid syntax (<unknown>, line 551)
   hgext/convert/bzr.py: error importing module: <SystemError> Parent module 'hgext.convert' not loaded, cannot perform relative import (line 18)
   hgext/convert/common.py: error importing module: <ImportError> No module named 'cPickle' (line 10)
-  hgext/convert/convcmd.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  hgext/convert/convcmd.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   hgext/convert/cvs.py: error importing module: <ImportError> No module named 'cStringIO' (line 9)
   hgext/convert/cvsps.py: error importing module: <ImportError> No module named 'cPickle' (line 9)
   hgext/convert/darcs.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
@@ -150,73 +150,70 @@
   hgext/convert/subversion.py: error importing module: <ImportError> No module named 'cPickle' (line 6)
   hgext/convert/transport.py: error importing module: <ImportError> No module named 'svn.client' (line 21)
   hgext/eol.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
-  hgext/extdiff.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  hgext/extdiff.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
   hgext/factotum.py: error importing: <ImportError> No module named 'cStringIO' (error at url.py:13)
-  hgext/fetch.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  hgext/fetch.py: error importing module: <SyntaxError> invalid syntax (commands.py, line 3324) (line 12)
   hgext/fsmonitor/state.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   hgext/fsmonitor/watchmanclient.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   hgext/gpg.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   hgext/graphlog.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
-  hgext/hgcia.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  hgext/hgcia.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
   hgext/hgk.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
   hgext/highlight/highlight.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   hgext/histedit.py: error importing module: <SyntaxError> invalid syntax (bundle2.py, line 977) (line 177)
   hgext/keyword.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   hgext/largefiles/basestore.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   hgext/largefiles/lfcommands.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
-  hgext/largefiles/lfutil.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  hgext/largefiles/lfutil.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   hgext/largefiles/localstore.py: error importing module: <ImportError> No module named 'lfutil' (line 13)
-  hgext/largefiles/overrides.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  hgext/largefiles/overrides.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   hgext/largefiles/proto.py: error importing module: <ImportError> No module named 'urllib2' (line 7)
   hgext/largefiles/remotestore.py: error importing module: <ImportError> No module named 'urllib2' (line 9)
   hgext/largefiles/reposetup.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   hgext/largefiles/uisetup.py: error importing module: <SyntaxError> invalid syntax (archival.py, line 234) (line 11)
   hgext/largefiles/wirestore.py: error importing module: <ImportError> No module named 'lfutil' (line 8)
-  hgext/mq.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  hgext/mq.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   hgext/notify.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
   hgext/pager.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
   hgext/patchbomb.py: error importing module: <ImportError> No module named 'cStringIO' (line 68)
   hgext/purge.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
-  hgext/rebase.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  hgext/rebase.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   hgext/record.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
   hgext/relink.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
   hgext/schemes.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
   hgext/share.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
   hgext/shelve.py: error importing module: <SyntaxError> invalid syntax (bundle2.py, line 977) (line 28)
-  hgext/strip.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  hgext/transplant.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  hgext/win32text.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  mercurial/ancestor.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  hgext/strip.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
+  hgext/transplant.py: error importing: <SyntaxError> invalid syntax (bundle2.py, line 977) (error at bundlerepo.py:23)
+  hgext/win32text.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   mercurial/archival.py: invalid syntax: invalid syntax (<unknown>, line 234)
-  mercurial/bookmarks.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  mercurial/branchmap.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  mercurial/bookmarks.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
+  mercurial/branchmap.py: error importing: <ImportError> No module named 'Queue' (error at scmutil.py:10)
   mercurial/bundle2.py: invalid syntax: invalid syntax (<unknown>, line 977)
-  mercurial/bundlerepo.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  mercurial/bundlerepo.py: error importing module: <SyntaxError> invalid syntax (bundle2.py, line 977) (line 23)
   mercurial/byterange.py: error importing module: <ImportError> No module named 'urllib2' (line 30)
-  mercurial/changegroup.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  mercurial/changelog.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  mercurial/changegroup.py: error importing: <ImportError> No module named 'Queue' (error at scmutil.py:10)
+  mercurial/changelog.py: error importing: <ImportError> No module named 'cStringIO' (error at mpatch.py:10)
   mercurial/cmdutil.py: error importing module: <ImportError> No module named 'cStringIO' (line 10)
   mercurial/commands.py: invalid syntax: invalid syntax (<unknown>, line 3324)
   mercurial/commandserver.py: error importing module: <ImportError> No module named 'SocketServer' (line 10)
   mercurial/config.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
-  mercurial/context.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  mercurial/copies.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  mercurial/context.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
+  mercurial/copies.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   mercurial/crecord.py: error importing module: <ImportError> No module named 'cStringIO' (line 13)
-  mercurial/dagutil.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  mercurial/destutil.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  mercurial/dirstate.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  mercurial/discovery.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  mercurial/destutil.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
+  mercurial/dirstate.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
+  mercurial/discovery.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   mercurial/dispatch.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
   mercurial/exchange.py: error importing module: <ImportError> No module named 'urllib2' (line 12)
   mercurial/extensions.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
   mercurial/filelog.py: error importing: <ImportError> No module named 'cStringIO' (error at mpatch.py:10)
-  mercurial/filemerge.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  mercurial/fileset.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  mercurial/filemerge.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
+  mercurial/fileset.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   mercurial/formatter.py: error importing module: <ImportError> No module named 'cPickle' (line 10)
-  mercurial/graphmod.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  mercurial/hbisect.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  mercurial/graphmod.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   mercurial/help.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
-  mercurial/hg.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  mercurial/hg.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   mercurial/hgweb/common.py: error importing module: <ImportError> No module named 'BaseHTTPServer' (line 11)
   mercurial/hgweb/hgweb_mod.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line 14)
   mercurial/hgweb/hgwebdir_mod.py: error importing module: <SystemError> Parent module 'mercurial.hgweb' not loaded, cannot perform relative import (line 15)
@@ -231,33 +228,30 @@
   mercurial/httpconnection.py: error importing module: <ImportError> No module named 'urllib2' (line 17)
   mercurial/httppeer.py: error importing module: <ImportError> No module named 'httplib' (line 12)
   mercurial/keepalive.py: error importing module: <ImportError> No module named 'httplib' (line 113)
-  mercurial/localrepo.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  mercurial/localrepo.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   mercurial/lock.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   mercurial/mail.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   mercurial/manifest.py: error importing: <ImportError> No module named 'cStringIO' (error at mpatch.py:10)
   mercurial/match.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   mercurial/mdiff.py: error importing: <ImportError> No module named 'cStringIO' (error at mpatch.py:10)
-  mercurial/merge.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  mercurial/merge.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   mercurial/minirst.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
-  mercurial/namespaces.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  mercurial/node.py: error importing module: <TypeError> a bytes-like object is required, not 'str' (line 18)
-  mercurial/obsolete.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  mercurial/namespaces.py: error importing: <ImportError> No module named 'cStringIO' (error at patch.py:11)
+  mercurial/obsolete.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   mercurial/patch.py: error importing module: <ImportError> No module named 'cStringIO' (line 11)
   mercurial/pathutil.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   mercurial/peer.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
-  mercurial/phases.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
   mercurial/pure/mpatch.py: error importing module: <ImportError> No module named 'cStringIO' (line 10)
   mercurial/pure/parsers.py: error importing module: <ImportError> No module named 'cStringIO' (line 10)
-  mercurial/pushkey.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  mercurial/pvec.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  mercurial/pushkey.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
+  mercurial/pvec.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   mercurial/registrar.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
-  mercurial/repair.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  mercurial/repoview.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  mercurial/revlog.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  mercurial/revset.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  mercurial/repair.py: error importing module: <SyntaxError> invalid syntax (bundle2.py, line 977) (line 15)
+  mercurial/repoview.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
+  mercurial/revlog.py: error importing: <ImportError> No module named 'cStringIO' (error at mpatch.py:10)
+  mercurial/revset.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   mercurial/scmutil.py: error importing module: <ImportError> No module named 'Queue' (line 10)
   mercurial/scmwindows.py: error importing module: <ImportError> No module named '_winreg' (line 3)
-  mercurial/setdiscovery.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
   mercurial/similar.py: error importing: <ImportError> No module named 'cStringIO' (error at mpatch.py:10)
   mercurial/simplemerge.py: error importing: <ImportError> No module named 'cStringIO' (error at mpatch.py:10)
   mercurial/sshpeer.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
@@ -265,23 +259,22 @@
   mercurial/sslutil.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   mercurial/statichttprepo.py: error importing module: <ImportError> No module named 'urllib2' (line 15)
   mercurial/store.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
-  mercurial/streamclone.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  mercurial/streamclone.py: error importing: <ImportError> No module named 'Queue' (error at scmutil.py:10)
   mercurial/subrepo.py: error importing: <ImportError> No module named 'cStringIO' (error at cmdutil.py:10)
-  mercurial/tagmerge.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  mercurial/tags.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  mercurial/templatefilters.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  mercurial/templatekw.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  mercurial/tagmerge.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
+  mercurial/tags.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
+  mercurial/templatefilters.py: error importing: <ImportError> No module named 'cStringIO' (error at patch.py:11)
+  mercurial/templatekw.py: error importing: <ImportError> No module named 'cStringIO' (error at patch.py:11)
   mercurial/templater.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
   mercurial/transaction.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
-  mercurial/treediscovery.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  mercurial/ui.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
-  mercurial/unionrepo.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  mercurial/ui.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
+  mercurial/unionrepo.py: error importing: <ImportError> No module named 'cStringIO' (error at mpatch.py:10)
   mercurial/url.py: error importing module: <ImportError> No module named 'cStringIO' (line 13)
   mercurial/util.py: error importing: <ImportError> No module named 'cStringIO' (error at parsers.py:10)
-  mercurial/verify.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  mercurial/verify.py: error importing: <ImportError> No module named 'cStringIO' (error at mpatch.py:10)
   mercurial/win32.py: error importing module: <ImportError> No module named 'msvcrt' (line 12)
   mercurial/windows.py: error importing module: <ImportError> No module named '_winreg' (line 10)
-  mercurial/wireproto.py: error importing: <TypeError> a bytes-like object is required, not 'str' (error at node.py:18)
+  mercurial/wireproto.py: error importing module: <SyntaxError> invalid syntax (bundle2.py, line 977) (line 22)
   tests/filterpyflakes.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line 61)
   tests/generate-working-copy-states.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line 69)
   tests/get-with-headers.py: invalid syntax: Missing parentheses in call to 'print' (<unknown>, line 44)