Mercurial > hg
comparison mercurial/repair.py @ 5904:ad5f97e08e1b
repair.py: use revs in limitheads
author | Alexis S. L. Carvalho <alexis@cecm.usp.br> |
---|---|
date | Sat, 19 Jan 2008 18:01:16 -0200 |
parents | bf20995f1ac3 |
children | 3afbd82a6c82 |
comparison
equal
deleted
inserted
replaced
5903:bf20995f1ac3 | 5904:ad5f97e08e1b |
---|---|
8 | 8 |
9 import changegroup, os | 9 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(cl, stop): | 13 def limitheads(cl, stoprev): |
14 """return the list of all nodes that have no children""" | 14 """return the list of all revs >= stoprev that have no children""" |
15 p = {} | 15 seen = {} |
16 h = [] | 16 heads = [] |
17 stoprev = 0 | |
18 if stop in cl.nodemap: | |
19 stoprev = cl.rev(stop) | |
20 | 17 |
21 for r in xrange(cl.count() - 1, -1, -1): | 18 for r in xrange(cl.count() - 1, stoprev - 1, -1): |
22 n = cl.node(r) | 19 if r not in seen: |
23 if n not in p: | 20 heads.append(r) |
24 h.append(n) | 21 for p in cl.parentrevs(r): |
25 if n == stop: | 22 seen[p] = 1 |
26 break | 23 return heads |
27 if r < stoprev: | |
28 break | |
29 for pn in cl.parents(n): | |
30 p[pn] = 1 | |
31 return h | |
32 | 24 |
33 def bundle(repo, bases, heads, node, suffix): | 25 def bundle(repo, bases, heads, node, suffix): |
34 """create a bundle with the specified revisions as a backup""" | 26 """create a bundle with the specified revisions as a backup""" |
35 cg = repo.changegroupsubset(bases, heads, 'strip') | 27 cg = repo.changegroupsubset(bases, heads, 'strip') |
36 backupdir = repo.join("strip-backup") | 28 backupdir = repo.join("strip-backup") |
78 # that we actually want to keep. changegroup will be used | 70 # that we actually want to keep. changegroup will be used |
79 # to preserve them and add them back after the truncate | 71 # to preserve them and add them back after the truncate |
80 saveheads = [] | 72 saveheads = [] |
81 savebases = {} | 73 savebases = {} |
82 | 74 |
83 heads = limitheads(cl, node) | 75 heads = [cl.node(r) for r in limitheads(cl, striprev)] |
84 seen = {} | 76 seen = {} |
85 | 77 |
86 # search through all the heads, finding those where the revision | 78 # search through all the heads, finding those where the revision |
87 # we want to strip away is an ancestor. Also look for merges | 79 # we want to strip away is an ancestor. Also look for merges |
88 # that might be turned into new heads by the strip. | 80 # that might be turned into new heads by the strip. |