##// END OF EJS Templates
bruterebase: port to python 3
Augie Fackler -
r34201:bab82c43 default
parent child Browse files
Show More
@@ -15,10 +15,15 b' from mercurial import ('
15
15
16 from hgext import rebase
16 from hgext import rebase
17
17
18 try:
19 xrange
20 except NameError:
21 xrange = range
22
18 cmdtable = {}
23 cmdtable = {}
19 command = registrar.command(cmdtable)
24 command = registrar.command(cmdtable)
20
25
21 @command('debugbruterebase')
26 @command(b'debugbruterebase')
22 def debugbruterebase(ui, repo, source, dest):
27 def debugbruterebase(ui, repo, source, dest):
23 """for every non-empty subset of source, run rebase -r subset -d dest
28 """for every non-empty subset of source, run rebase -r subset -d dest
24
29
@@ -33,28 +38,28 b' def debugbruterebase(ui, repo, source, d'
33 def getdesc(rev):
38 def getdesc(rev):
34 result = cl.changelogrevision(rev).description
39 result = cl.changelogrevision(rev).description
35 if rev >= repolen:
40 if rev >= repolen:
36 result += "'"
41 result += b"'"
37 return result
42 return result
38
43
39 for i in xrange(1, 2 ** len(srevs)):
44 for i in xrange(1, 2 ** len(srevs)):
40 subset = [rev for j, rev in enumerate(srevs) if i & (1 << j) != 0]
45 subset = [rev for j, rev in enumerate(srevs) if i & (1 << j) != 0]
41 spec = revsetlang.formatspec('%ld', subset)
46 spec = revsetlang.formatspec(b'%ld', subset)
42 tr = repo.transaction('rebase')
47 tr = repo.transaction(b'rebase')
43 tr.report = lambda x: 0 # hide "transaction abort"
48 tr.report = lambda x: 0 # hide "transaction abort"
44
49
45 ui.pushbuffer()
50 ui.pushbuffer()
46 try:
51 try:
47 rebase.rebase(ui, repo, dest=dest, rev=[spec])
52 rebase.rebase(ui, repo, dest=dest, rev=[spec])
48 except error.Abort as ex:
53 except error.Abort as ex:
49 summary = 'ABORT: %s' % ex
54 summary = b'ABORT: %s' % ex
50 except Exception as ex:
55 except Exception as ex:
51 summary = 'CRASH: %s' % ex
56 summary = b'CRASH: %s' % ex
52 else:
57 else:
53 # short summary about new nodes
58 # short summary about new nodes
54 cl = repo.changelog
59 cl = repo.changelog
55 descs = []
60 descs = []
56 for rev in xrange(repolen, len(repo)):
61 for rev in xrange(repolen, len(repo)):
57 desc = '%s:' % getdesc(rev)
62 desc = b'%s:' % getdesc(rev)
58 for prev in cl.parentrevs(rev):
63 for prev in cl.parentrevs(rev):
59 if prev > -1:
64 if prev > -1:
60 desc += getdesc(prev)
65 desc += getdesc(prev)
@@ -62,8 +67,8 b' def debugbruterebase(ui, repo, source, d'
62 descs.sort()
67 descs.sort()
63 summary = ' '.join(descs)
68 summary = ' '.join(descs)
64 ui.popbuffer()
69 ui.popbuffer()
65 repo.vfs.tryunlink('rebasestate')
70 repo.vfs.tryunlink(b'rebasestate')
66
71
67 subsetdesc = ''.join(getdesc(rev) for rev in subset)
72 subsetdesc = b''.join(getdesc(rev) for rev in subset)
68 ui.write(('%s: %s\n') % (subsetdesc.rjust(len(srevs)), summary))
73 ui.write((b'%s: %s\n') % (subsetdesc.rjust(len(srevs)), summary))
69 tr.abort()
74 tr.abort()
General Comments 0
You need to be logged in to leave comments. Login now