mirror of
https://github.com/facebook/sapling.git
synced 2025-01-08 22:56:44 +03:00
pushrebase: add pack files to storage during hooks
Summary: Hooks should run with awareness of the tree pack data, so we need to pass the temporary pack location as part of the hook environment. Test Plan: Added a test Reviewers: #fbhgext, simpkins Reviewed By: #fbhgext, simpkins Subscribers: simpkins Differential Revision: https://phab.mercurial-scm.org/D8
This commit is contained in:
parent
c823246e06
commit
e3a87e44e3
@ -125,7 +125,31 @@ def _peerorrepo(orig, ui, path, create=False, **kwargs):
|
||||
# Force hooks to use a bundle repo
|
||||
bundlepath = encoding.environ.get("HG_HOOK_BUNDLEPATH")
|
||||
if bundlepath:
|
||||
return orig(ui, bundlepath, create=create, **kwargs)
|
||||
packpaths = encoding.environ.get("HG_HOOK_PACKPATHS")
|
||||
if packpaths:
|
||||
ui.setconfig("treemanifest", "treeonly", True)
|
||||
|
||||
repo = orig(ui, bundlepath, create=create, **kwargs)
|
||||
|
||||
# Add hook pack paths to the store
|
||||
if packpaths:
|
||||
bundledatastores = []
|
||||
bundlehiststores = []
|
||||
paths = packpaths.split(':')
|
||||
for path in paths:
|
||||
datastore, histstore = _createpackstore(repo.ui, path)
|
||||
bundledatastores.append(datastore)
|
||||
bundlehiststores.append(histstore)
|
||||
|
||||
# Point the bundle repo at the temp stores
|
||||
repo.svfs.manifestdatastore = contentstore.unioncontentstore(
|
||||
repo.svfs.manifestdatastore,
|
||||
*bundledatastores)
|
||||
repo.svfs.manifesthistorystore = metadatastore.unionmetadatastore(
|
||||
repo.svfs.manifesthistorystore,
|
||||
*bundlehiststores)
|
||||
return repo
|
||||
|
||||
return orig(ui, path, create, **kwargs)
|
||||
|
||||
def unbundle(orig, repo, cg, heads, source, url):
|
||||
@ -811,6 +835,13 @@ def prepushrebasehooks(op, params, bundle, bundlefile):
|
||||
'min(bundle())').hex()
|
||||
prelockrebaseargs['node_onto'] = prelockontonode
|
||||
prelockrebaseargs['hook_bundlepath'] = bundlefile
|
||||
|
||||
for path in op.records[treepackrecords]:
|
||||
if ':' in path:
|
||||
raise RuntimeError(_("tree pack path may not contain colon (%s)") %
|
||||
path)
|
||||
prelockrebaseargs['hook_packpaths'] = ':'.join(op.records[treepackrecords])
|
||||
|
||||
op.repo.hook("prepushrebase", throw=True, **prelockrebaseargs)
|
||||
|
||||
def prefetchcaches(op, params, bundle):
|
||||
|
@ -98,12 +98,35 @@ Test pushing only flat fails if forcetreereceive is on
|
||||
abort: push failed on remote
|
||||
[255]
|
||||
|
||||
Test pushing only trees (no flats) with pushrebase creates trees on the server
|
||||
Test pushing only trees with commit hooks
|
||||
$ cat >> .hg/hgrc <<EOF
|
||||
> [treemanifest]
|
||||
> sendflat=False
|
||||
> sendtrees=True
|
||||
> EOF
|
||||
$ cat >> $TESTTMP/myhook.sh <<EOF
|
||||
> set -xe
|
||||
> [[ \$(hg log -r \$HG_NODE -T '{file_adds}') == 'subdir2/z' ]] && exit 1
|
||||
> exit 2
|
||||
> EOF
|
||||
$ chmod a+x $TESTTMP/myhook.sh
|
||||
$ cp ../master/.hg/hgrc ../master/.hg/hgrc.bak
|
||||
$ cat >> ../master/.hg/hgrc <<EOF
|
||||
> [hooks]
|
||||
> prepushrebase.myhook=$TESTTMP/myhook.sh
|
||||
> EOF
|
||||
$ hg push --to mybook
|
||||
pushing to ssh://user@dummy/master
|
||||
searching for changes
|
||||
remote: +++ hg log -r 15486e46ccf6947fbb0a0209e6ce479e7f87ffae -T '{file_adds}'
|
||||
remote: ++ [[ subdir2/z == \s\u\b\d\i\r\2\/\z ]]
|
||||
remote: ++ exit 1
|
||||
remote: prepushrebase.myhook hook exited with status 1
|
||||
abort: push failed on remote
|
||||
[255]
|
||||
$ mv ../master/.hg/hgrc.bak ../master/.hg/hgrc
|
||||
|
||||
Test pushing only trees (no flats) with pushrebase creates trees on the server
|
||||
$ hg push --to mybook
|
||||
pushing to ssh://user@dummy/master
|
||||
searching for changes
|
||||
|
Loading…
Reference in New Issue
Block a user