# HG changeset patch # User Eric Sumner # Date 2015-01-21 23:54:52 # Node ID 33d1b81c6ef029651954589584dd67d1aebbc110 # Parent de519517f597abd733961a8c549074eecb6c0ab3 repair._bundle: fix traceback for bad config value On IRC, rom1dep reported a traceback[1] from setting experimental.strip-bundle2-version to True. This diff catches unexpected values and falls back to the non-experimental bundle1 implementation after issuing a warning. [1] http://gist.tamytro.org/_admin/gists/qXcdQLwtApgy6e3NwWgl diff --git a/mercurial/repair.py b/mercurial/repair.py --- a/mercurial/repair.py +++ b/mercurial/repair.py @@ -17,6 +17,12 @@ def _bundle(repo, bases, heads, node, su repo.ui.config('experimental', 'strip-bundle2-version')) if usebundle2: cgversion = repo.ui.config('experimental', 'strip-bundle2-version') + if cgversion not in changegroup.packermap: + repo.ui.warn(_('unknown strip-bundle2-version value %r; ' + + 'should be one of %r\n') % + (cgversion, sorted(changegroup.packermap.keys()),)) + cgversion = '01' + usebundle2 = False else: cgversion = '01' diff --git a/tests/test-strip.t b/tests/test-strip.t --- a/tests/test-strip.t +++ b/tests/test-strip.t @@ -197,6 +197,16 @@ date: Thu Jan 01 00:00:00 1970 +0000 summary: c + $ hg --config experimental.bundle2-exp=True --config experimental.strip-bundle2-version=INVALID strip 4 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved + unknown strip-bundle2-version value 'INVALID'; should be one of ['01', '02'] + saved backup bundle to $TESTTMP/test/.hg/strip-backup/264128213d29-0b39d6bf-backup.hg (glob) + $ hg debugbundle .hg/strip-backup/* + 264128213d290d868c54642d13aeaa3675551a78 + $ restore + + $ hg up -C 4 + 1 files updated, 0 files merged, 0 files removed, 0 files unresolved $ 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)