changeset 34204:bab82c43c065

bruterebase: port to python 3
author Augie Fackler <raf@durin42.com>
date Wed, 23 Aug 2017 01:22:59 -0400
parents 3a5d8e2996f8
children 6c408bfa2dab
files tests/bruterebase.py
diffstat 1 files changed, 15 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/tests/bruterebase.py	Tue Aug 22 21:21:13 2017 -0400
+++ b/tests/bruterebase.py	Wed Aug 23 01:22:59 2017 -0400
@@ -15,10 +15,15 @@
 
 from hgext import rebase
 
+try:
+    xrange
+except NameError:
+    xrange = range
+
 cmdtable = {}
 command = registrar.command(cmdtable)
 
-@command('debugbruterebase')
+@command(b'debugbruterebase')
 def debugbruterebase(ui, repo, source, dest):
     """for every non-empty subset of source, run rebase -r subset -d dest
 
@@ -33,28 +38,28 @@
         def getdesc(rev):
             result = cl.changelogrevision(rev).description
             if rev >= repolen:
-                result += "'"
+                result += b"'"
             return result
 
         for i in xrange(1, 2 ** len(srevs)):
             subset = [rev for j, rev in enumerate(srevs) if i & (1 << j) != 0]
-            spec = revsetlang.formatspec('%ld', subset)
-            tr = repo.transaction('rebase')
+            spec = revsetlang.formatspec(b'%ld', subset)
+            tr = repo.transaction(b'rebase')
             tr.report = lambda x: 0 # hide "transaction abort"
 
             ui.pushbuffer()
             try:
                 rebase.rebase(ui, repo, dest=dest, rev=[spec])
             except error.Abort as ex:
-                summary = 'ABORT: %s' % ex
+                summary = b'ABORT: %s' % ex
             except Exception as ex:
-                summary = 'CRASH: %s' % ex
+                summary = b'CRASH: %s' % ex
             else:
                 # short summary about new nodes
                 cl = repo.changelog
                 descs = []
                 for rev in xrange(repolen, len(repo)):
-                    desc = '%s:' % getdesc(rev)
+                    desc = b'%s:' % getdesc(rev)
                     for prev in cl.parentrevs(rev):
                         if prev > -1:
                             desc += getdesc(prev)
@@ -62,8 +67,8 @@
                 descs.sort()
                 summary = ' '.join(descs)
             ui.popbuffer()
-            repo.vfs.tryunlink('rebasestate')
+            repo.vfs.tryunlink(b'rebasestate')
 
-            subsetdesc = ''.join(getdesc(rev) for rev in subset)
-            ui.write(('%s: %s\n') % (subsetdesc.rjust(len(srevs)), summary))
+            subsetdesc = b''.join(getdesc(rev) for rev in subset)
+            ui.write((b'%s: %s\n') % (subsetdesc.rjust(len(srevs)), summary))
             tr.abort()