Mercurial > hg
changeset 27953:88609cfa3745 stable
changegroup: fix pulling to treemanifest repo from flat repo (issue5066)
In c0f11347b107 (changegroup: don't support versions 01 and 02 with
treemanifests, 2016-01-19), I stopped supporting use of cg1 and cg2
with treemanifest repos. What I had not considered was that it's
perfectly safe to pull *to* a treemanifest repo using any changegroup
version. As reported in issue5066, I therefore broke pull from old
repos into a treemanifest repo. It was not covered by the test case,
because that pulled from a local repo while enabling treemanifests,
which enabled treemanifests on the source repo as well. After
switching to pulling via HTTP, it breaks.
Fix by splitting up changegroup.supportedversions() into
supportedincomingversions() and supportedoutgoingversions().
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Wed, 27 Jan 2016 09:07:28 -0800 |
parents | c5ffbd4c033b |
children | 9960b6369e7f 288f5b083e09 |
files | mercurial/bundle2.py mercurial/bundlerepo.py mercurial/changegroup.py mercurial/exchange.py tests/test-treemanifest.t |
diffstat | 5 files changed, 48 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/bundle2.py Thu Jan 28 13:49:05 2016 -0800 +++ b/mercurial/bundle2.py Wed Jan 27 09:07:28 2016 -0800 @@ -1242,7 +1242,8 @@ Exists to allow extensions (like evolution) to mutate the capabilities. """ caps = capabilities.copy() - caps['changegroup'] = tuple(sorted(changegroup.supportedversions(repo))) + caps['changegroup'] = tuple(sorted( + changegroup.supportedincomingversions(repo))) if obsolete.isenabled(repo, obsolete.exchangeopt): supportedformat = tuple('V%i' % v for v in obsolete.formats) caps['obsmarkers'] = supportedformat
--- a/mercurial/bundlerepo.py Thu Jan 28 13:49:05 2016 -0800 +++ b/mercurial/bundlerepo.py Wed Jan 27 09:07:28 2016 -0800 @@ -282,7 +282,7 @@ "multiple changegroups") cgstream = part version = part.params.get('version', '01') - if version not in changegroup.supportedversions(self): + if version not in changegroup.allsupportedversions(ui): msg = _('Unsupported changegroup version: %s') raise error.Abort(msg % version) if self.bundle.compressed():
--- a/mercurial/changegroup.py Thu Jan 28 13:49:05 2016 -0800 +++ b/mercurial/changegroup.py Wed Jan 27 09:07:28 2016 -0800 @@ -949,10 +949,25 @@ '03': (cg3packer, cg3unpacker), } -def supportedversions(repo): +def allsupportedversions(ui): versions = set(_packermap.keys()) - if ('treemanifest' in repo.requirements or - repo.ui.configbool('experimental', 'treemanifest')): + versions.discard('03') + if (ui.configbool('experimental', 'changegroup3') or + ui.configbool('experimental', 'treemanifest')): + versions.add('03') + return versions + +# Changegroup versions that can be applied to the repo +def supportedincomingversions(repo): + versions = allsupportedversions(repo.ui) + if 'treemanifest' in repo.requirements: + versions.add('03') + return versions + +# Changegroup versions that can be created from the repo +def supportedoutgoingversions(repo): + versions = allsupportedversions(repo.ui) + if 'treemanifest' in repo.requirements: # Versions 01 and 02 support only flat manifests and it's just too # expensive to convert between the flat manifest and tree manifest on # the fly. Since tree manifests are hashed differently, all of history @@ -960,22 +975,21 @@ # support versions 01 and 02. versions.discard('01') versions.discard('02') - elif not repo.ui.configbool('experimental', 'changegroup3'): - versions.discard('03') + versions.add('03') return versions def safeversion(repo): # Finds the smallest version that it's safe to assume clients of the repo # will support. For example, all hg versions that support generaldelta also # support changegroup 02. - versions = supportedversions(repo) + versions = supportedoutgoingversions(repo) if 'generaldelta' in repo.requirements: versions.discard('01') assert versions return min(versions) def getbundler(version, repo, bundlecaps=None): - assert version in supportedversions(repo) + assert version in supportedoutgoingversions(repo) return _packermap[version][0](repo, bundlecaps) def getunbundler(version, fh, alg):
--- a/mercurial/exchange.py Thu Jan 28 13:49:05 2016 -0800 +++ b/mercurial/exchange.py Wed Jan 27 09:07:28 2016 -0800 @@ -707,7 +707,8 @@ pushop.outgoing) else: cgversions = [v for v in cgversions - if v in changegroup.supportedversions(pushop.repo)] + if v in changegroup.supportedoutgoingversions( + pushop.repo)] if not cgversions: raise ValueError(_('no common changegroup version')) version = max(cgversions) @@ -1562,7 +1563,7 @@ getcgkwargs = {} if cgversions: # 3.1 and 3.2 ship with an empty value cgversions = [v for v in cgversions - if v in changegroup.supportedversions(repo)] + if v in changegroup.supportedoutgoingversions(repo)] if not cgversions: raise ValueError(_('no common changegroup version')) version = getcgkwargs['version'] = max(cgversions)
--- a/tests/test-treemanifest.t Thu Jan 28 13:49:05 2016 -0800 +++ b/tests/test-treemanifest.t Wed Jan 27 09:07:28 2016 -0800 @@ -1,6 +1,8 @@ $ cat << EOF >> $HGRCPATH > [format] > usegeneraldelta=yes + > [ui] + > ssh=python "$TESTDIR/dummyssh" > EOF Set up repo @@ -203,15 +205,18 @@ (branch merge, don't forget to commit) $ hg ci -m 'merge of flat manifests to new flat manifest' + $ hg serve -p $HGPORT -d --pid-file=hg.pid --errorlog=errors.log + $ cat hg.pid >> $DAEMON_PIDS + Create clone with tree manifests enabled $ cd .. - $ hg clone --pull --config experimental.treemanifest=1 repo-flat repo-mixed - requesting all changes + $ hg clone --config experimental.treemanifest=1 \ + > http://localhost:$HGPORT repo-mixed -r 1 adding changesets adding manifests adding file changes - added 4 changesets with 17 changes to 11 files + added 2 changesets with 14 changes to 11 files updating to branch default 11 files updated, 0 files merged, 0 files removed, 0 files unresolved $ cd repo-mixed @@ -220,10 +225,20 @@ $ grep treemanifest .hg/requires treemanifest +Should be possible to push updates from flat to tree manifest repo + + $ hg -R ../repo-flat push ssh://user@dummy/repo-mixed + pushing to ssh://user@dummy/repo-mixed + searching for changes + remote: adding changesets + remote: adding manifests + remote: adding file changes + remote: added 2 changesets with 3 changes to 3 files + Commit should store revlog per directory $ hg co 1 - 3 files updated, 0 files merged, 0 files removed, 0 files unresolved + 0 files updated, 0 files merged, 0 files removed, 0 files unresolved $ echo 3 > a $ echo 3 > dir1/a $ echo 3 > dir1/dir1/a @@ -456,13 +471,13 @@ $ hg ci -m troz Test cloning a treemanifest repo over http. - $ hg serve -p $HGPORT -d --pid-file=hg.pid --errorlog=errors.log + $ hg serve -p $HGPORT2 -d --pid-file=hg.pid --errorlog=errors.log $ cat hg.pid >> $DAEMON_PIDS $ cd .. We can clone even with the knob turned off and we'll get a treemanifest repo. $ hg clone --config experimental.treemanifest=False \ > --config experimental.changegroup3=True \ - > http://localhost:$HGPORT deepclone + > http://localhost:$HGPORT2 deepclone requesting all changes adding changesets adding manifests