mirror of
https://github.com/facebook/sapling.git
synced 2024-10-06 23:07:18 +03:00
infinitepush: reuse bundlerepo
Summary: This diff is part of the series to avoid downloading the same bundle a few times. Finally reuse the same bundlerepo. Test Plan: arc unit Reviewers: #mercurial Subscribers: mjpieters, #sourcecontrol Differential Revision: https://phabricator.intern.facebook.com/D4612094 Tasks: 15389402
This commit is contained in:
parent
29031ff4a1
commit
666f7299d3
@ -446,17 +446,21 @@ def getbundlechunks(orig, repo, source, heads=None, bundlecaps=None, **kwargs):
|
||||
try:
|
||||
for head in heads:
|
||||
if head not in repo.changelog.nodemap:
|
||||
if head in nodestobundle:
|
||||
bundlerepo, bundleroots = nodestobundle[head]
|
||||
else:
|
||||
bundlerepo = getbundlerepo(repo, head)
|
||||
allbundlerepos.append(bundlerepo)
|
||||
bundlerevs = set(_readbundlerevs(bundlerepo))
|
||||
bundlecaps = _includefilelogstobundle(bundlecaps, bundlerepo,
|
||||
bundlerevs, repo.ui)
|
||||
bundlecaps = _includefilelogstobundle(
|
||||
bundlecaps, bundlerepo, bundlerevs, repo.ui)
|
||||
cl = bundlerepo.changelog
|
||||
bundleroots = _getbundleroots(repo, bundlerepo, bundlerevs)
|
||||
for rev in bundlerevs:
|
||||
node = cl.node(rev)
|
||||
newphases[hex(node)] = str(phases.draft)
|
||||
nodestobundle[node] = (bundlerepo, bundleroots)
|
||||
|
||||
outputbundleraw = _getoutputbundleraw(bundlerepo, bundleroots,
|
||||
head)
|
||||
scratchbundles.append(outputbundleraw)
|
||||
|
14
tests/bundlerepologger.py
Normal file
14
tests/bundlerepologger.py
Normal file
@ -0,0 +1,14 @@
|
||||
# Copyright 2017 Facebook, Inc.
|
||||
#
|
||||
# This software may be used and distributed according to the terms of the
|
||||
# GNU General Public License version 2 or any later version.
|
||||
|
||||
from mercurial import bundlerepo, extensions
|
||||
from mercurial.i18n import _
|
||||
|
||||
def extsetup(ui):
|
||||
extensions.wrapfunction(bundlerepo.bundlerepository, '__init__', _init)
|
||||
|
||||
def _init(orig, self, ui, *args, **kwargs):
|
||||
ui.warn(_('creating bundlerepo'))
|
||||
return orig(self, ui, *args, **kwargs)
|
@ -121,3 +121,33 @@ Create a repo with `/bookmarks/` in path
|
||||
secondbook 0:c1bfda8efb6e
|
||||
|
||||
$ cd ..
|
||||
|
||||
Backup and restore two commits
|
||||
$ cd backupsource
|
||||
$ mkcommit firstinbatch
|
||||
$ hg up 0
|
||||
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
|
||||
(leaving bookmark book/bookmarksbookmarks/somebook)
|
||||
$ mkcommit secondinbatch
|
||||
created new head
|
||||
$ hg pushbackup
|
||||
searching for changes
|
||||
remote: pushing 3 commits:
|
||||
remote: 89ecc969c0ac firstcommit
|
||||
remote: 33c1c9df81e9 firstinbatch
|
||||
remote: 0e1a088ff282 secondinbatch
|
||||
$ cd ../restored
|
||||
|
||||
Install server-side extension that will print message every time when bundlerepo
|
||||
is created
|
||||
$ cd ../repo
|
||||
$ printf "\n[extensions]\nbundlerepologger=$TESTDIR/bundlerepologger.py" >> .hg/hgrc
|
||||
$ hg st
|
||||
$ cd ../restored
|
||||
|
||||
Pull the backup and check bundlerepo was created only once
|
||||
$ hg pullbackup --reporoot $TESTTMP/backupsource | grep 'creating bundlerepo'
|
||||
remote: creating bundlerepo
|
||||
|
||||
Make sure that commits were restored
|
||||
$ hg log -r '33c1c9df81e9 + 0e1a088ff282' > /dev/null
|
||||
|
Loading…
Reference in New Issue
Block a user