##// END OF EJS Templates
repair: switch from changegroupsubset to getbundle...
Peter Arrenbrecht -
r15068:73307643 default
parent child Browse files
Show More
@@ -11,9 +11,8 b' from mercurial.node import short'
11 from mercurial.i18n import _
11 from mercurial.i18n import _
12 import os
12 import os
13
13
14 def _bundle(repo, bases, heads, node, suffix, compress=True):
14 def _bundle(repo, cg, node, suffix, compress=True):
15 """create a bundle with the specified revisions as a backup"""
15 """create a bundle with the specified revisions as a backup"""
16 cg = repo.changegroupsubset(bases, heads, 'strip')
17 backupdir = repo.join("strip-backup")
16 backupdir = repo.join("strip-backup")
18 if not os.path.isdir(backupdir):
17 if not os.path.isdir(backupdir):
19 os.mkdir(backupdir)
18 os.mkdir(backupdir)
@@ -83,11 +82,9 b' def strip(ui, repo, node, backup="all"):'
83 saveheads.add(r)
82 saveheads.add(r)
84 saveheads = [cl.node(r) for r in saveheads]
83 saveheads = [cl.node(r) for r in saveheads]
85
84
86 # compute base nodes
85 # compute common nodes
87 if saverevs:
86 savecommon = set(cl.node(p) for r in saverevs for p in cl.parentrevs(r)
88 descendants = set(cl.descendants(*saverevs))
87 if p not in saverevs and p not in tostrip)
89 saverevs.difference_update(descendants)
90 savebases = [cl.node(r) for r in saverevs]
91
88
92 bm = repo._bookmarks
89 bm = repo._bookmarks
93 updatebm = []
90 updatebm = []
@@ -99,12 +96,14 b' def strip(ui, repo, node, backup="all"):'
99 # create a changegroup for all the branches we need to keep
96 # create a changegroup for all the branches we need to keep
100 backupfile = None
97 backupfile = None
101 if backup == "all":
98 if backup == "all":
102 backupfile = _bundle(repo, [node], cl.heads(), node, 'backup')
99 allnodes=[cl.node(r) for r in xrange(striprev, len(cl))]
100 cg = repo._changegroup(allnodes, 'strip')
101 backupfile = _bundle(repo, cg, node, 'backup')
103 repo.ui.status(_("saved backup bundle to %s\n") % backupfile)
102 repo.ui.status(_("saved backup bundle to %s\n") % backupfile)
104 if saveheads or savebases:
103 if saveheads or savecommon:
105 # do not compress partial bundle if we remove it from disk later
104 # do not compress partial bundle if we remove it from disk later
106 chgrpfile = _bundle(repo, savebases, saveheads, node, 'temp',
105 cg = repo.getbundle('strip', common=savecommon, heads=saveheads)
107 compress=keeppartialbundle)
106 chgrpfile = _bundle(repo, cg, node, 'temp', compress=keeppartialbundle)
108
107
109 mfst = repo.manifest
108 mfst = repo.manifest
110
109
@@ -128,7 +127,7 b' def strip(ui, repo, node, backup="all"):'
128 tr.abort()
127 tr.abort()
129 raise
128 raise
130
129
131 if saveheads or savebases:
130 if saveheads or savecommon:
132 ui.note(_("adding branch\n"))
131 ui.note(_("adding branch\n"))
133 f = open(chgrpfile, "rb")
132 f = open(chgrpfile, "rb")
134 gen = changegroup.readbundle(f, chgrpfile)
133 gen = changegroup.readbundle(f, chgrpfile)
General Comments 0
You need to be logged in to leave comments. Login now