Show More
@@ -1,74 +1,74 | |||
|
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 | 18 | try: |
|
19 | 19 | xrange |
|
20 | 20 | except NameError: |
|
21 | 21 | xrange = range |
|
22 | 22 | |
|
23 | 23 | cmdtable = {} |
|
24 | 24 | command = registrar.command(cmdtable) |
|
25 | 25 | |
|
26 | 26 | @command(b'debugbruterebase') |
|
27 | 27 | def debugbruterebase(ui, repo, source, dest): |
|
28 | 28 | """for every non-empty subset of source, run rebase -r subset -d dest |
|
29 | 29 | |
|
30 | 30 | Print one line summary for each subset. Assume obsstore is enabled. |
|
31 | 31 | """ |
|
32 | 32 | srevs = list(repo.revs(source)) |
|
33 | 33 | |
|
34 | 34 | with repo.wlock(), repo.lock(): |
|
35 | 35 | repolen = len(repo) |
|
36 | 36 | cl = repo.changelog |
|
37 | 37 | |
|
38 | 38 | def getdesc(rev): |
|
39 | 39 | result = cl.changelogrevision(rev).description |
|
40 | 40 | if rev >= repolen: |
|
41 | 41 | result += b"'" |
|
42 | 42 | return result |
|
43 | 43 | |
|
44 | 44 | for i in xrange(1, 2 ** len(srevs)): |
|
45 | 45 | subset = [rev for j, rev in enumerate(srevs) if i & (1 << j) != 0] |
|
46 | 46 | spec = revsetlang.formatspec(b'%ld', subset) |
|
47 | 47 | tr = repo.transaction(b'rebase') |
|
48 | 48 | tr.report = lambda x: 0 # hide "transaction abort" |
|
49 | 49 | |
|
50 | 50 | ui.pushbuffer() |
|
51 | 51 | try: |
|
52 | 52 | rebase.rebase(ui, repo, dest=dest, rev=[spec]) |
|
53 | 53 | except error.Abort as ex: |
|
54 | 54 | summary = b'ABORT: %s' % ex |
|
55 | 55 | except Exception as ex: |
|
56 | 56 | summary = b'CRASH: %s' % ex |
|
57 | 57 | else: |
|
58 | 58 | # short summary about new nodes |
|
59 | 59 | cl = repo.changelog |
|
60 | 60 | descs = [] |
|
61 | 61 | for rev in xrange(repolen, len(repo)): |
|
62 | 62 | desc = b'%s:' % getdesc(rev) |
|
63 | 63 | for prev in cl.parentrevs(rev): |
|
64 | 64 | if prev > -1: |
|
65 | 65 | desc += getdesc(prev) |
|
66 | 66 | descs.append(desc) |
|
67 | 67 | descs.sort() |
|
68 | summary = ' '.join(descs) | |
|
68 | summary = b' '.join(descs) | |
|
69 | 69 | ui.popbuffer() |
|
70 | 70 | repo.vfs.tryunlink(b'rebasestate') |
|
71 | 71 | |
|
72 | 72 | subsetdesc = b''.join(getdesc(rev) for rev in subset) |
|
73 | 73 | ui.write((b'%s: %s\n') % (subsetdesc.rjust(len(srevs)), summary)) |
|
74 | 74 | tr.abort() |
General Comments 0
You need to be logged in to leave comments.
Login now