mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
infinitepush: send treepack parts with the client push
This makes the client side pushes also include tree packs in the push. Also adds a test to see that the tree parts round trip between two tree-only clients. Differential Revision: https://phab.mercurial-scm.org/D721
This commit is contained in:
parent
d0ee81e289
commit
286d6bbe18
@ -100,7 +100,7 @@ import tempfile
|
||||
import time
|
||||
|
||||
from .bundleparts import (
|
||||
getscratchbranchpart,
|
||||
getscratchbranchparts,
|
||||
scratchbookmarksparttype,
|
||||
scratchbranchparttype,
|
||||
)
|
||||
@ -897,7 +897,7 @@ def partgen(pushop, bundler):
|
||||
|
||||
nonforwardmove = pushop.force or pushop.ui.configbool(experimental,
|
||||
confignonforwardmove)
|
||||
scratchpart = getscratchbranchpart(pushop.repo,
|
||||
scratchparts = getscratchbranchparts(pushop.repo,
|
||||
pushop.remote,
|
||||
pushop.outgoing,
|
||||
nonforwardmove,
|
||||
@ -905,6 +905,7 @@ def partgen(pushop, bundler):
|
||||
bookmark,
|
||||
create)
|
||||
|
||||
for scratchpart in scratchparts:
|
||||
bundler.addpart(scratchpart)
|
||||
|
||||
def handlereply(op):
|
||||
|
@ -51,7 +51,7 @@ import time
|
||||
|
||||
from .bundleparts import (
|
||||
getscratchbookmarkspart,
|
||||
getscratchbranchpart,
|
||||
getscratchbranchparts,
|
||||
)
|
||||
from mercurial import (
|
||||
bundle2,
|
||||
@ -450,10 +450,12 @@ def _dobackup(ui, repo, dest, **opts):
|
||||
backup = False
|
||||
if outgoing and outgoing.missing:
|
||||
backup = True
|
||||
bundler.addpart(getscratchbranchpart(repo, other, outgoing,
|
||||
parts = getscratchbranchparts(repo, other, outgoing,
|
||||
confignonforwardmove=False,
|
||||
ui=ui, bookmark=None,
|
||||
create=False))
|
||||
create=False)
|
||||
for part in parts:
|
||||
bundler.addpart(part)
|
||||
|
||||
if bookmarkstobackup:
|
||||
backup = True
|
||||
|
@ -19,7 +19,7 @@ from mercurial.i18n import _
|
||||
scratchbranchparttype = 'b2x:infinitepush'
|
||||
scratchbookmarksparttype = 'b2x:infinitepushscratchbookmarks'
|
||||
|
||||
def getscratchbranchpart(repo, peer, outgoing, confignonforwardmove,
|
||||
def getscratchbranchparts(repo, peer, outgoing, confignonforwardmove,
|
||||
ui, bookmark, create):
|
||||
if not outgoing.missing:
|
||||
raise error.Abort(_('no commits to push'))
|
||||
@ -56,12 +56,23 @@ def getscratchbranchpart(repo, peer, outgoing, confignonforwardmove,
|
||||
if not isremotebooksenabled(ui):
|
||||
params['pushbackbookmarks'] = '1'
|
||||
|
||||
parts = []
|
||||
|
||||
# .upper() marks this as a mandatory part: server will abort if there's no
|
||||
# handler
|
||||
return bundle2.bundlepart(
|
||||
parts.append(bundle2.bundlepart(
|
||||
scratchbranchparttype.upper(),
|
||||
advisoryparams=params.iteritems(),
|
||||
data=cg)
|
||||
data=cg))
|
||||
|
||||
try:
|
||||
treemod = extensions.find('treemanifest')
|
||||
parts.append(treemod.createtreepackpart(repo, outgoing,
|
||||
treemod.TREEGROUP_PARTTYPE2))
|
||||
except KeyError:
|
||||
pass
|
||||
|
||||
return parts
|
||||
|
||||
def getscratchbookmarkspart(peer, bookmarks):
|
||||
if scratchbookmarksparttype not in bundle2.bundle2caps(peer):
|
||||
|
@ -72,6 +72,8 @@ class shallowcg1packer(changegroup.cg1packer):
|
||||
"""
|
||||
sendflat = self._repo.ui.configbool('treemanifest', 'sendflat',
|
||||
True)
|
||||
sendflat &= not self._repo.ui.configbool('treemanifest', 'treeonly')
|
||||
|
||||
if sendflat:
|
||||
# In this code path, generating the manifests populates fnodes for
|
||||
# us.
|
||||
|
107
tests/test-treemanifest-infinitepush.t
Normal file
107
tests/test-treemanifest-infinitepush.t
Normal file
@ -0,0 +1,107 @@
|
||||
$ . "$TESTDIR/library.sh"
|
||||
$ . "$TESTDIR/library-infinitepush.sh"
|
||||
|
||||
$ PYTHONPATH=$TESTDIR/..:$PYTHONPATH
|
||||
$ export PYTHONPATH
|
||||
$ setupcommon
|
||||
|
||||
$ hginit master
|
||||
$ cd master
|
||||
$ setupserver
|
||||
$ cat >> .hg/hgrc <<EOF
|
||||
> [extensions]
|
||||
> pushrebase=$TESTDIR/../hgext3rd/pushrebase.py
|
||||
> treemanifest=$TESTDIR/../treemanifest
|
||||
> [remotefilelog]
|
||||
> server=True
|
||||
> [treemanifest]
|
||||
> server=True
|
||||
> EOF
|
||||
$ echo x > x
|
||||
$ hg commit -qAm 'add x'
|
||||
$ cd ..
|
||||
|
||||
Push a scratch branch from one client
|
||||
|
||||
$ hgcloneshallow ssh://user@dummy/master client1 -q --config extensions.treemanifest=$TESTDIR/../treemanifest --config treemanifest.treeonly=True
|
||||
1 trees fetched over * (glob)
|
||||
1 trees fetched over * (glob)
|
||||
1 files fetched over 1 fetches - (1 misses, 0.00% hit ratio) over * (glob)
|
||||
$ cd client1
|
||||
$ cat >> .hg/hgrc <<EOF
|
||||
> [extensions]
|
||||
> treemanifest=$TESTDIR/../treemanifest
|
||||
>
|
||||
> [remotefilelog]
|
||||
> usefastdatapack=True
|
||||
>
|
||||
> [treemanifest]
|
||||
> treeonly=True
|
||||
> EOF
|
||||
|
||||
$ mkdir subdir
|
||||
$ echo "my change" >> subdir/a
|
||||
$ hg commit -qAm 'add subdir/a'
|
||||
$ hg push --to scratch/foo --create
|
||||
pushing to ssh://user@dummy/master
|
||||
searching for changes
|
||||
remote: pushing 1 commit:
|
||||
remote: 02c12aef64ff add subdir/a
|
||||
$ cd ..
|
||||
|
||||
Pull a scratch branch from another client
|
||||
|
||||
$ hgcloneshallow ssh://user@dummy/master client2 -q --config extensions.treemanifest=$TESTDIR/../treemanifest --config treemanifest.treeonly=True
|
||||
$ cd client2
|
||||
$ cat >> .hg/hgrc <<EOF
|
||||
> [extensions]
|
||||
> treemanifest=$TESTDIR/../treemanifest
|
||||
>
|
||||
> [remotefilelog]
|
||||
> usefastdatapack=True
|
||||
>
|
||||
> [treemanifest]
|
||||
> treeonly=True
|
||||
> EOF
|
||||
$ hg pull -r scratch/foo
|
||||
pulling from ssh://user@dummy/master
|
||||
searching for changes
|
||||
adding changesets
|
||||
adding manifests
|
||||
adding file changes
|
||||
added 1 changesets with 1 changes to 1 files
|
||||
(run 'hg update' to get a working copy)
|
||||
$ hg log -G
|
||||
o changeset: 1:02c12aef64ff
|
||||
| tag: tip
|
||||
| user: test
|
||||
| date: Thu Jan 01 00:00:00 1970 +0000
|
||||
| summary: add subdir/a
|
||||
|
|
||||
@ changeset: 0:085784c01c08
|
||||
user: test
|
||||
date: Thu Jan 01 00:00:00 1970 +0000
|
||||
summary: add x
|
||||
|
||||
$ hg cat -r tip subdir/a
|
||||
my change
|
||||
$ ls_l .hg/store
|
||||
-rw-r--r-- 257 00changelog.i
|
||||
-rw-r--r-- 108 00manifesttree.i
|
||||
drwxr-xr-x data
|
||||
drwxrwxr-x packs
|
||||
-rw-r--r-- 43 phaseroots
|
||||
-rw-r--r-- 18 undo
|
||||
-rw-r--r-- 17 undo.backupfiles
|
||||
-rw-r--r-- 0 undo.phaseroots
|
||||
$ cd ..
|
||||
|
||||
Verify its not on the server
|
||||
$ cd master
|
||||
$ hg log -G
|
||||
@ changeset: 0:085784c01c08
|
||||
tag: tip
|
||||
user: test
|
||||
date: Thu Jan 01 00:00:00 1970 +0000
|
||||
summary: add x
|
||||
|
Loading…
Reference in New Issue
Block a user