##// END OF EJS Templates
bruterebase: port to python 3
Augie Fackler -
r34201:bab82c43 default
parent child Browse files
Show More
@@ -1,69 +1,74 b''
1 1 # bruterebase.py - brute force rebase testing
2 2 #
3 3 # Copyright 2017 Facebook, Inc.
4 4 #
5 5 # This software may be used and distributed according to the terms of the
6 6 # GNU General Public License version 2 or any later version.
7 7
8 8 from __future__ import absolute_import
9 9
10 10 from mercurial import (
11 11 error,
12 12 registrar,
13 13 revsetlang,
14 14 )
15 15
16 16 from hgext import rebase
17 17
18 try:
19 xrange
20 except NameError:
21 xrange = range
22
18 23 cmdtable = {}
19 24 command = registrar.command(cmdtable)
20 25
21 @command('debugbruterebase')
26 @command(b'debugbruterebase')
22 27 def debugbruterebase(ui, repo, source, dest):
23 28 """for every non-empty subset of source, run rebase -r subset -d dest
24 29
25 30 Print one line summary for each subset. Assume obsstore is enabled.
26 31 """
27 32 srevs = list(repo.revs(source))
28 33
29 34 with repo.wlock(), repo.lock():
30 35 repolen = len(repo)
31 36 cl = repo.changelog
32 37
33 38 def getdesc(rev):
34 39 result = cl.changelogrevision(rev).description
35 40 if rev >= repolen:
36 result += "'"
41 result += b"'"
37 42 return result
38 43
39 44 for i in xrange(1, 2 ** len(srevs)):
40 45 subset = [rev for j, rev in enumerate(srevs) if i & (1 << j) != 0]
41 spec = revsetlang.formatspec('%ld', subset)
42 tr = repo.transaction('rebase')
46 spec = revsetlang.formatspec(b'%ld', subset)
47 tr = repo.transaction(b'rebase')
43 48 tr.report = lambda x: 0 # hide "transaction abort"
44 49
45 50 ui.pushbuffer()
46 51 try:
47 52 rebase.rebase(ui, repo, dest=dest, rev=[spec])
48 53 except error.Abort as ex:
49 summary = 'ABORT: %s' % ex
54 summary = b'ABORT: %s' % ex
50 55 except Exception as ex:
51 summary = 'CRASH: %s' % ex
56 summary = b'CRASH: %s' % ex
52 57 else:
53 58 # short summary about new nodes
54 59 cl = repo.changelog
55 60 descs = []
56 61 for rev in xrange(repolen, len(repo)):
57 desc = '%s:' % getdesc(rev)
62 desc = b'%s:' % getdesc(rev)
58 63 for prev in cl.parentrevs(rev):
59 64 if prev > -1:
60 65 desc += getdesc(prev)
61 66 descs.append(desc)
62 67 descs.sort()
63 68 summary = ' '.join(descs)
64 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)
68 ui.write(('%s: %s\n') % (subsetdesc.rjust(len(srevs)), summary))
72 subsetdesc = b''.join(getdesc(rev) for rev in subset)
73 ui.write((b'%s: %s\n') % (subsetdesc.rjust(len(srevs)), summary))
69 74 tr.abort()
General Comments 0
You need to be logged in to leave comments. Login now