Show More
@@ -6,14 +6,22 b'' | |||
|
6 | 6 | # This software may be used and distributed according to the terms of the |
|
7 | 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 | 10 | from mercurial.node import short, hex |
|
11 | 11 | from mercurial.i18n import _ |
|
12 | 12 | import errno |
|
13 | 13 | |
|
14 | 14 | def _bundle(repo, bases, heads, node, suffix, compress=True): |
|
15 | 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 | 25 | backupdir = "strip-backup" |
|
18 | 26 | vfs = repo.vfs |
|
19 | 27 | if not vfs.isdir(backupdir): |
@@ -27,7 +35,9 b' def _bundle(repo, bases, heads, node, su' | |||
|
27 | 35 | totalhash = util.sha1(''.join(allhashes)).hexdigest() |
|
28 | 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 | 41 | bundletype = "HG10BZ" |
|
32 | 42 | else: |
|
33 | 43 | bundletype = "HG10UN" |
@@ -163,8 +173,17 b' def strip(ui, repo, nodelist, backup=Tru' | |||
|
163 | 173 | if not repo.ui.verbose: |
|
164 | 174 | # silence internal shuffling chatter |
|
165 | 175 | repo.ui.pushbuffer() |
|
166 | changegroup.addchangegroup(repo, gen, 'strip', | |
|
167 | 'bundle:' + vfs.join(chgrpfile), True) | |
|
176 | if isinstance(gen, bundle2.unbundle20): | |
|
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 | 187 | if not repo.ui.verbose: |
|
169 | 188 | repo.ui.popbuffer() |
|
170 | 189 | f.close() |
@@ -187,6 +187,30 b'' | |||
|
187 | 187 | date: Thu Jan 01 00:00:00 1970 +0000 |
|
188 | 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 | 215 |
$ |
|
192 | 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