Skip to content
Snippets Groups Projects
Commit b21c2e0e authored by Eric Sumner's avatar Eric Sumner
Browse files

repair: add experimental option to write bundle2 files

This adds an experimental option 'strip-bundle2-version' which causes backup
bundles to use bundle2 formatting.  Especially for generaldelta repositories,
this should provide significant performance gains for any operation that needs
to write a backup.
parent f99a6e18
No related branches found
No related tags found
No related merge requests found
...@@ -6,10 +6,10 @@ ...@@ -6,10 +6,10 @@
# This software may be used and distributed according to the terms of the # This software may be used and distributed according to the terms of the
# GNU General Public License version 2 or any later version. # GNU General Public License version 2 or any later version.
from mercurial import changegroup, exchange, util from mercurial import changegroup, exchange, util, bundle2
from mercurial.node import short, hex from mercurial.node import short, hex
from mercurial.i18n import _ from mercurial.i18n import _
import errno import errno
def _bundle(repo, bases, heads, node, suffix, compress=True): def _bundle(repo, bases, heads, node, suffix, compress=True):
"""create a bundle with the specified revisions as a backup""" """create a bundle with the specified revisions as a backup"""
...@@ -10,10 +10,18 @@ ...@@ -10,10 +10,18 @@
from mercurial.node import short, hex from mercurial.node import short, hex
from mercurial.i18n import _ from mercurial.i18n import _
import errno import errno
def _bundle(repo, bases, heads, node, suffix, compress=True): def _bundle(repo, bases, heads, node, suffix, compress=True):
"""create a bundle with the specified revisions as a backup""" """create a bundle with the specified revisions as a backup"""
cg = changegroup.changegroupsubset(repo, bases, heads, 'strip') usebundle2 = (repo.ui.config('experimental', 'bundle2-exp') and
repo.ui.config('experimental', 'strip-bundle2-version'))
if usebundle2:
cgversion = repo.ui.config('experimental', 'strip-bundle2-version')
else:
cgversion = '01'
cg = changegroup.changegroupsubset(repo, bases, heads, 'strip',
version=cgversion)
backupdir = "strip-backup" backupdir = "strip-backup"
vfs = repo.vfs vfs = repo.vfs
if not vfs.isdir(backupdir): if not vfs.isdir(backupdir):
...@@ -27,7 +35,9 @@ ...@@ -27,7 +35,9 @@
totalhash = util.sha1(''.join(allhashes)).hexdigest() totalhash = util.sha1(''.join(allhashes)).hexdigest()
name = "%s/%s-%s-%s.hg" % (backupdir, short(node), totalhash[:8], suffix) name = "%s/%s-%s-%s.hg" % (backupdir, short(node), totalhash[:8], suffix)
if compress: if usebundle2:
bundletype = "HG2Y"
elif compress:
bundletype = "HG10BZ" bundletype = "HG10BZ"
else: else:
bundletype = "HG10UN" bundletype = "HG10UN"
...@@ -163,8 +173,17 @@ ...@@ -163,8 +173,17 @@
if not repo.ui.verbose: if not repo.ui.verbose:
# silence internal shuffling chatter # silence internal shuffling chatter
repo.ui.pushbuffer() repo.ui.pushbuffer()
changegroup.addchangegroup(repo, gen, 'strip', if isinstance(gen, bundle2.unbundle20):
'bundle:' + vfs.join(chgrpfile), True) tr = repo.transaction('strip')
try:
bundle2.processbundle(repo, gen, lambda: tr)
tr.close()
finally:
tr.release()
else:
changegroup.addchangegroup(repo, gen, 'strip',
'bundle:' + vfs.join(chgrpfile),
True)
if not repo.ui.verbose: if not repo.ui.verbose:
repo.ui.popbuffer() repo.ui.popbuffer()
f.close() f.close()
......
...@@ -187,6 +187,30 @@ ...@@ -187,6 +187,30 @@
date: Thu Jan 01 00:00:00 1970 +0000 date: Thu Jan 01 00:00:00 1970 +0000
summary: a summary: a
$ hg up -C 4
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg parents
changeset: 4:264128213d29
tag: tip
parent: 1:ef3a871183d7
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: c
$ hg --config experimental.bundle2-exp=True --config experimental.strip-bundle2-version=02 --traceback strip 4
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
saved backup bundle to $TESTTMP/test/.hg/strip-backup/264128213d29-0b39d6bf-backup.hg (glob)
$ hg parents
changeset: 1:ef3a871183d7
user: test
date: Thu Jan 01 00:00:00 1970 +0000
summary: b
$ hg debugbundle .hg/strip-backup/*
Stream params: {}
b2x:changegroup -- "{'version': '02'}"
264128213d290d868c54642d13aeaa3675551a78
$ restore
$ hg up -C 2 $ hg up -C 2
1 files updated, 0 files merged, 0 files removed, 0 files unresolved 1 files updated, 0 files merged, 0 files removed, 0 files unresolved
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment