##// END OF EJS Templates
repair: add experimental option to write bundle2 files...
Eric Sumner -
r23898:b21c2e0e default
parent child Browse files
Show More
@@ -6,14 +6,22 b''
6 # This software may be used and distributed according to the terms of the
6 # This software may be used and distributed according to the terms of the
7 # GNU General Public License version 2 or any later version.
7 # GNU General Public License version 2 or any later version.
8
8
9 from mercurial import changegroup, exchange, util
9 from mercurial import changegroup, exchange, util, bundle2
10 from mercurial.node import short, hex
10 from mercurial.node import short, hex
11 from mercurial.i18n import _
11 from mercurial.i18n import _
12 import errno
12 import errno
13
13
14 def _bundle(repo, bases, heads, node, suffix, compress=True):
14 def _bundle(repo, bases, heads, 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 = changegroup.changegroupsubset(repo, bases, heads, 'strip')
16 usebundle2 = (repo.ui.config('experimental', 'bundle2-exp') and
17 repo.ui.config('experimental', 'strip-bundle2-version'))
18 if usebundle2:
19 cgversion = repo.ui.config('experimental', 'strip-bundle2-version')
20 else:
21 cgversion = '01'
22
23 cg = changegroup.changegroupsubset(repo, bases, heads, 'strip',
24 version=cgversion)
17 backupdir = "strip-backup"
25 backupdir = "strip-backup"
18 vfs = repo.vfs
26 vfs = repo.vfs
19 if not vfs.isdir(backupdir):
27 if not vfs.isdir(backupdir):
@@ -27,7 +35,9 b' def _bundle(repo, bases, heads, node, su'
27 totalhash = util.sha1(''.join(allhashes)).hexdigest()
35 totalhash = util.sha1(''.join(allhashes)).hexdigest()
28 name = "%s/%s-%s-%s.hg" % (backupdir, short(node), totalhash[:8], suffix)
36 name = "%s/%s-%s-%s.hg" % (backupdir, short(node), totalhash[:8], suffix)
29
37
30 if compress:
38 if usebundle2:
39 bundletype = "HG2Y"
40 elif compress:
31 bundletype = "HG10BZ"
41 bundletype = "HG10BZ"
32 else:
42 else:
33 bundletype = "HG10UN"
43 bundletype = "HG10UN"
@@ -163,8 +173,17 b' def strip(ui, repo, nodelist, backup=Tru'
163 if not repo.ui.verbose:
173 if not repo.ui.verbose:
164 # silence internal shuffling chatter
174 # silence internal shuffling chatter
165 repo.ui.pushbuffer()
175 repo.ui.pushbuffer()
166 changegroup.addchangegroup(repo, gen, 'strip',
176 if isinstance(gen, bundle2.unbundle20):
167 'bundle:' + vfs.join(chgrpfile), True)
177 tr = repo.transaction('strip')
178 try:
179 bundle2.processbundle(repo, gen, lambda: tr)
180 tr.close()
181 finally:
182 tr.release()
183 else:
184 changegroup.addchangegroup(repo, gen, 'strip',
185 'bundle:' + vfs.join(chgrpfile),
186 True)
168 if not repo.ui.verbose:
187 if not repo.ui.verbose:
169 repo.ui.popbuffer()
188 repo.ui.popbuffer()
170 f.close()
189 f.close()
@@ -187,6 +187,30 b''
187 date: Thu Jan 01 00:00:00 1970 +0000
187 date: Thu Jan 01 00:00:00 1970 +0000
188 summary: a
188 summary: a
189
189
190 $ hg up -C 4
191 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
192 $ hg parents
193 changeset: 4:264128213d29
194 tag: tip
195 parent: 1:ef3a871183d7
196 user: test
197 date: Thu Jan 01 00:00:00 1970 +0000
198 summary: c
199
200 $ hg --config experimental.bundle2-exp=True --config experimental.strip-bundle2-version=02 --traceback strip 4
201 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
202 saved backup bundle to $TESTTMP/test/.hg/strip-backup/264128213d29-0b39d6bf-backup.hg (glob)
203 $ hg parents
204 changeset: 1:ef3a871183d7
205 user: test
206 date: Thu Jan 01 00:00:00 1970 +0000
207 summary: b
208
209 $ hg debugbundle .hg/strip-backup/*
210 Stream params: {}
211 b2x:changegroup -- "{'version': '02'}"
212 264128213d290d868c54642d13aeaa3675551a78
213 $ restore
190
214
191 $ hg up -C 2
215 $ hg up -C 2
192 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
216 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
General Comments 0
You need to be logged in to leave comments. Login now