Patchwork D1791: tests: make autodiff.py work on Python 3

login
register
mail settings
Submitter phabricator
Date Dec. 29, 2017, 12:48 a.m.
Message ID <differential-rev-PHID-DREV-7u6b2crckokgcuddzkhj-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/26487/
State Superseded
Headers show

Comments

phabricator - Dec. 29, 2017, 12:48 a.m.
pulkit created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  This patch adds b'' to string literal to make it compatible with in-core Python
  3 compatibility.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/autodiff.py

CHANGE DETAILS




To: pulkit, #hg-reviewers
Cc: mercurial-devel
phabricator - Dec. 29, 2017, 1:51 a.m.
durin42 added a comment.


  For patches like this that are just adding bytes prefixes, let's go ahead and do a '# skip-blame' as in https://phab.mercurial-scm.org/rHGd92dc725223bbde09963fc431e57d32a40c4167d (aka https://phab.mercurial-scm.org/D1170) so that blame is cleaner in the future.

REPOSITORY
  rHG Mercurial

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

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

Patch

diff --git a/tests/autodiff.py b/tests/autodiff.py
--- a/tests/autodiff.py
+++ b/tests/autodiff.py
@@ -12,39 +12,39 @@ 
 cmdtable = {}
 command = registrar.command(cmdtable)
 
-@command('autodiff',
-    [('', 'git', '', 'git upgrade mode (yes/no/auto/warn/abort)')],
-    '[OPTION]... [FILE]...')
+@command(b'autodiff',
+    [(b'', b'git', b'', b'git upgrade mode (yes/no/auto/warn/abort)')],
+    b'[OPTION]... [FILE]...')
 def autodiff(ui, repo, *pats, **opts):
     diffopts = patch.difffeatureopts(ui, opts)
-    git = opts.get('git', 'no')
+    git = opts.get(b'git', b'no')
     brokenfiles = set()
     losedatafn = None
-    if git in ('yes', 'no'):
-        diffopts.git = git == 'yes'
+    if git in (b'yes', b'no'):
+        diffopts.git = git == b'yes'
         diffopts.upgrade = False
-    elif git == 'auto':
+    elif git == b'auto':
         diffopts.git = False
         diffopts.upgrade = True
-    elif git == 'warn':
+    elif git == b'warn':
         diffopts.git = False
         diffopts.upgrade = True
         def losedatafn(fn=None, **kwargs):
             brokenfiles.add(fn)
             return True
-    elif git == 'abort':
+    elif git == b'abort':
         diffopts.git = False
         diffopts.upgrade = True
         def losedatafn(fn=None, **kwargs):
-            raise error.Abort('losing data for %s' % fn)
+            raise error.Abort(b'losing data for %s' % fn)
     else:
-        raise error.Abort('--git must be yes, no or auto')
+        raise error.Abort(b'--git must be yes, no or auto')
 
     node1, node2 = scmutil.revpair(repo, [])
     m = scmutil.match(repo[node2], pats, opts)
     it = patch.diff(repo, node1, node2, match=m, opts=diffopts,
                     losedatafn=losedatafn)
     for chunk in it:
         ui.write(chunk)
     for fn in sorted(brokenfiles):
-        ui.write(('data lost for: %s\n' % fn))
+        ui.write((b'data lost for: %s\n' % fn))