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