diff --git a/tests/test-treemanifest-treeonly.t b/tests/test-treemanifest-treeonly.t --- a/tests/test-treemanifest-treeonly.t +++ b/tests/test-treemanifest-treeonly.t @@ -419,6 +419,32 @@ y | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) - -TODO -# log -T "{manifest}" #TODO: edit templatekw.showmanifest +Switch back to hybrid mode + $ cd ../client + $ cat >> .hg/hgrc < [treemanifest] + > treeonly=False + > EOF + $ hg pull + pulling from ssh://user@dummy/master + searching for changes + adding changesets + adding manifests + transaction abort! + rollback completed + abort: 00manifest.i@d9920715ba88: unknown parent! + [255] + $ hg backfillmanifestrevlog + adding changesets + adding manifests + adding file changes + added 0 changesets with 0 changes to 0 files + $ hg pull + pulling from ssh://user@dummy/master + searching for changes + adding changesets + adding manifests + adding file changes + added 1 changesets with 0 changes to 0 files (+1 heads) + new changesets 4f84204095e0 + (run 'hg heads .' to see heads, 'hg merge' to merge) diff --git a/treemanifest/__init__.py b/treemanifest/__init__.py --- a/treemanifest/__init__.py +++ b/treemanifest/__init__.py @@ -659,6 +659,36 @@ recordmanifest(dpack, hpack, repo, mfrev1, mfrev2, verify=opts.get('verify', False)) +@command('backfillmanifestrevlog', [ + ], _('hg backfillmanifestrevlog')) +def backfillmanifestrevlog(ui, repo, *args, **opts): + """Download any missing manifest revlog entries. This is useful when + transitioning back from a treeonly repo to a flat+tree hybrid repo.""" + fallbackpath = getfallbackpath(repo) + with repo.connectionpool.get(fallbackpath) as conn: + remote = conn.peer + + # _localrepo is needed for remotefilelog to work + if util.safehasattr(remote, '_callstream'): + remote._localrepo = repo + + cl = repo.changelog + mfrevlog = repo.manifestlog._revlog + + # We need to download any manifests the server has that we don't. We + # calculate that by saying we need all the public heads, and that we + # have some of them already. This might result in extra downloading but + # they become no-ops when attempting to be added to the revlog. + publicheads = repo.revs('heads(public())') + clnode = cl.node + heads = [clnode(r) for r in publicheads] + common = [clnode(r) for r in publicheads if + cl.changelogrevision(r).manifest in mfrevlog.nodemap] + with repo.wlock(), repo.lock(), ( + repo.transaction("backfillmanifest")) as tr: + cg = remote.getbundle('pull', common=common, heads=heads) + bundle2.applybundle(repo, cg, tr, 'pull', remote.url()) + @command('backfilltree', [ ('l', 'limit', '10000000', _('')) ], _('hg backfilltree [OPTIONS]'))