Show More
@@ -10,23 +10,23 b' import changegroup, os' | |||||
10 | from node import * |
|
10 | from node import * | |
11 |
|
11 | |||
12 | def strip(ui, repo, node, backup="all"): |
|
12 | def strip(ui, repo, node, backup="all"): | |
13 |
def limitheads(c |
|
13 | def limitheads(cl, stop): | |
14 | """return the list of all nodes that have no children""" |
|
14 | """return the list of all nodes that have no children""" | |
15 | p = {} |
|
15 | p = {} | |
16 | h = [] |
|
16 | h = [] | |
17 | stoprev = 0 |
|
17 | stoprev = 0 | |
18 |
if stop in c |
|
18 | if stop in cl.nodemap: | |
19 |
stoprev = c |
|
19 | stoprev = cl.rev(stop) | |
20 |
|
20 | |||
21 |
for r in xrange(c |
|
21 | for r in xrange(cl.count() - 1, -1, -1): | |
22 |
n = c |
|
22 | n = cl.node(r) | |
23 | if n not in p: |
|
23 | if n not in p: | |
24 | h.append(n) |
|
24 | h.append(n) | |
25 | if n == stop: |
|
25 | if n == stop: | |
26 | break |
|
26 | break | |
27 | if r < stoprev: |
|
27 | if r < stoprev: | |
28 | break |
|
28 | break | |
29 |
for pn in c |
|
29 | for pn in cl.parents(n): | |
30 | p[pn] = 1 |
|
30 | p[pn] = 1 | |
31 | return h |
|
31 | return h | |
32 |
|
32 | |||
@@ -68,10 +68,10 b' def strip(ui, repo, node, backup="all"):' | |||||
68 | filerev = 0 |
|
68 | filerev = 0 | |
69 | ff.strip(filerev, striprev) |
|
69 | ff.strip(filerev, striprev) | |
70 |
|
70 | |||
71 |
c |
|
71 | cl = repo.changelog | |
72 | # TODO delete the undo files, and handle undo of merge sets |
|
72 | # TODO delete the undo files, and handle undo of merge sets | |
73 |
pp = c |
|
73 | pp = cl.parents(node) | |
74 |
striprev = c |
|
74 | striprev = cl.rev(node) | |
75 |
|
75 | |||
76 | # save is a list of all the branches we are truncating away |
|
76 | # save is a list of all the branches we are truncating away | |
77 | # that we actually want to keep. changegroup will be used |
|
77 | # that we actually want to keep. changegroup will be used | |
@@ -79,7 +79,7 b' def strip(ui, repo, node, backup="all"):' | |||||
79 | saveheads = [] |
|
79 | saveheads = [] | |
80 | savebases = {} |
|
80 | savebases = {} | |
81 |
|
81 | |||
82 |
heads = limitheads(c |
|
82 | heads = limitheads(cl, node) | |
83 | seen = {} |
|
83 | seen = {} | |
84 |
|
84 | |||
85 | # search through all the heads, finding those where the revision |
|
85 | # search through all the heads, finding those where the revision | |
@@ -90,35 +90,35 b' def strip(ui, repo, node, backup="all"):' | |||||
90 | n = h |
|
90 | n = h | |
91 | while True: |
|
91 | while True: | |
92 | seen[n] = 1 |
|
92 | seen[n] = 1 | |
93 |
pp = c |
|
93 | pp = cl.parents(n) | |
94 | if pp[1] != nullid: |
|
94 | if pp[1] != nullid: | |
95 | for p in pp: |
|
95 | for p in pp: | |
96 |
if c |
|
96 | if cl.rev(p) > striprev and p not in seen: | |
97 | heads.append(p) |
|
97 | heads.append(p) | |
98 | if pp[0] == nullid: |
|
98 | if pp[0] == nullid: | |
99 | break |
|
99 | break | |
100 |
if c |
|
100 | if cl.rev(pp[0]) < striprev: | |
101 | break |
|
101 | break | |
102 | n = pp[0] |
|
102 | n = pp[0] | |
103 | if n == node: |
|
103 | if n == node: | |
104 | break |
|
104 | break | |
105 |
r = c |
|
105 | r = cl.reachable(h, node) | |
106 | if node not in r: |
|
106 | if node not in r: | |
107 | saveheads.append(h) |
|
107 | saveheads.append(h) | |
108 | for x in r: |
|
108 | for x in r: | |
109 |
if c |
|
109 | if cl.rev(x) > striprev: | |
110 | savebases[x] = 1 |
|
110 | savebases[x] = 1 | |
111 |
|
111 | |||
112 | # create a changegroup for all the branches we need to keep |
|
112 | # create a changegroup for all the branches we need to keep | |
113 | if backup == "all": |
|
113 | if backup == "all": | |
114 |
bundle(repo, [node], c |
|
114 | bundle(repo, [node], cl.heads(), node, 'backup') | |
115 | if saveheads: |
|
115 | if saveheads: | |
116 | chgrpfile = bundle(repo, savebases.keys(), saveheads, node, 'temp') |
|
116 | chgrpfile = bundle(repo, savebases.keys(), saveheads, node, 'temp') | |
117 |
|
117 | |||
118 | stripall(striprev) |
|
118 | stripall(striprev) | |
119 |
|
119 | |||
120 |
change = c |
|
120 | change = cl.read(node) | |
121 |
c |
|
121 | cl.strip(striprev, striprev) | |
122 | repo.manifest.strip(repo.manifest.rev(change[0]), striprev) |
|
122 | repo.manifest.strip(repo.manifest.rev(change[0]), striprev) | |
123 | if saveheads: |
|
123 | if saveheads: | |
124 | ui.status("adding branch\n") |
|
124 | ui.status("adding branch\n") |
General Comments 0
You need to be logged in to leave comments.
Login now