mirror of
https://github.com/facebook/sapling.git
synced 2024-10-07 07:17:55 +03:00
hooks: add preupdate and update hooks.
preupdate run before working dir updated. can prevent update. update run after working dir updated.
This commit is contained in:
parent
c828df5692
commit
1f1118a083
@ -219,10 +219,20 @@ hooks::
|
|||||||
commit to proceed. Non-zero status will cause the transaction to
|
commit to proceed. Non-zero status will cause the transaction to
|
||||||
be rolled back. ID of changeset is in $HG_NODE. Parent changeset
|
be rolled back. ID of changeset is in $HG_NODE. Parent changeset
|
||||||
IDs are in $HG_PARENT1 and $HG_PARENT2.
|
IDs are in $HG_PARENT1 and $HG_PARENT2.
|
||||||
|
preupdate;;
|
||||||
|
Run before updating the working directory. Exit status 0 allows
|
||||||
|
the update to proceed. Non-zero status will prevent the update.
|
||||||
|
Changeset ID of first new parent is in $HG_PARENT1. If merge, ID
|
||||||
|
of second new parent is in $HG_PARENT2.
|
||||||
tag;;
|
tag;;
|
||||||
Run after a tag is created. ID of tagged changeset is in
|
Run after a tag is created. ID of tagged changeset is in
|
||||||
$HG_NODE. Name of tag is in $HG_TAG. Tag is local if
|
$HG_NODE. Name of tag is in $HG_TAG. Tag is local if
|
||||||
$HG_LOCAL=1, in repo if $HG_LOCAL=0.
|
$HG_LOCAL=1, in repo if $HG_LOCAL=0.
|
||||||
|
update;;
|
||||||
|
Run after updating the working directory. Changeset ID of first
|
||||||
|
new parent is in $HG_PARENT1. If merge, ID of second new parent
|
||||||
|
is in $HG_PARENT2. If update succeeded, $HG_ERROR=0. If update
|
||||||
|
failed (e.g. because conflicts not resolved), $HG_ERROR=1.
|
||||||
|
|
||||||
In earlier releases, the names of hook environment variables did not
|
In earlier releases, the names of hook environment variables did not
|
||||||
have a "HG_" prefix. These unprefixed names are still provided in
|
have a "HG_" prefix. These unprefixed names are still provided in
|
||||||
|
@ -1592,6 +1592,7 @@ class localrepository(object):
|
|||||||
if allow and not forcemerge:
|
if allow and not forcemerge:
|
||||||
if modified or added or removed:
|
if modified or added or removed:
|
||||||
raise util.Abort(_("outstanding uncommitted changes"))
|
raise util.Abort(_("outstanding uncommitted changes"))
|
||||||
|
|
||||||
if not forcemerge and not force:
|
if not forcemerge and not force:
|
||||||
for f in unknown:
|
for f in unknown:
|
||||||
if f in m2:
|
if f in m2:
|
||||||
@ -1765,6 +1766,13 @@ class localrepository(object):
|
|||||||
return 1
|
return 1
|
||||||
branch_merge = True
|
branch_merge = True
|
||||||
|
|
||||||
|
xp1 = hex(p1)
|
||||||
|
xp2 = hex(p2)
|
||||||
|
if p2 == nullid: xxp2 = ''
|
||||||
|
else: xxp2 = xp2
|
||||||
|
|
||||||
|
self.hook('preupdate', throw=True, parent1=xp1, parent2=xxp2)
|
||||||
|
|
||||||
# get the files we don't need to change
|
# get the files we don't need to change
|
||||||
files = get.keys()
|
files = get.keys()
|
||||||
files.sort()
|
files.sort()
|
||||||
@ -1785,8 +1793,6 @@ class localrepository(object):
|
|||||||
failedmerge = []
|
failedmerge = []
|
||||||
files = merge.keys()
|
files = merge.keys()
|
||||||
files.sort()
|
files.sort()
|
||||||
xp1 = hex(p1)
|
|
||||||
xp2 = hex(p2)
|
|
||||||
for f in files:
|
for f in files:
|
||||||
self.ui.status(_("merging %s\n") % f)
|
self.ui.status(_("merging %s\n") % f)
|
||||||
my, other, flag = merge[f]
|
my, other, flag = merge[f]
|
||||||
@ -1850,6 +1856,7 @@ class localrepository(object):
|
|||||||
self.ui.status(_("There are unresolved merges with"
|
self.ui.status(_("There are unresolved merges with"
|
||||||
" locally modified files.\n"))
|
" locally modified files.\n"))
|
||||||
|
|
||||||
|
self.hook('update', parent1=xp1, parent2=xxp2, error=int(err))
|
||||||
return err
|
return err
|
||||||
|
|
||||||
def merge3(self, fn, my, other, p1, p2):
|
def merge3(self, fn, my, other, p1, p2):
|
||||||
|
@ -61,6 +61,14 @@ echo 'precommit.forbid = echo precommit.forbid hook; exit 1' >> .hg/hgrc
|
|||||||
hg commit -m 'fail' -d '4 0'
|
hg commit -m 'fail' -d '4 0'
|
||||||
hg -q tip
|
hg -q tip
|
||||||
|
|
||||||
|
# preupdate hook can prevent update
|
||||||
|
echo 'preupdate = echo preupdate hook: p1=$HG_PARENT1 p2=$HG_PARENT2' >> .hg/hgrc
|
||||||
|
hg update 1
|
||||||
|
|
||||||
|
# update hook
|
||||||
|
echo 'update = echo update hook: p1=$HG_PARENT1 p2=$HG_PARENT2 err=$HG_ERROR' >> .hg/hgrc
|
||||||
|
hg update
|
||||||
|
|
||||||
# prechangegroup hook can prevent incoming changes
|
# prechangegroup hook can prevent incoming changes
|
||||||
cd ../b
|
cd ../b
|
||||||
hg -q tip
|
hg -q tip
|
||||||
|
@ -62,6 +62,11 @@ precommit hook: p1=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 p2=
|
|||||||
precommit.forbid hook
|
precommit.forbid hook
|
||||||
abort: precommit.forbid hook exited with status 1
|
abort: precommit.forbid hook exited with status 1
|
||||||
4:4f92e785b90a
|
4:4f92e785b90a
|
||||||
|
preupdate hook: p1=b702efe9688826e3a91283852b328b84dbf37bc2 p2=
|
||||||
|
0 files updated, 0 files merged, 2 files removed, 0 files unresolved
|
||||||
|
preupdate hook: p1=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 p2=
|
||||||
|
update hook: p1=4f92e785b90ae8995dfe156e39dd4fbc3b346a24 p2= err=0
|
||||||
|
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
|
||||||
3:4c52fb2e4022
|
3:4c52fb2e4022
|
||||||
prechangegroup.forbid hook
|
prechangegroup.forbid hook
|
||||||
pulling from ../a
|
pulling from ../a
|
||||||
|
Loading…
Reference in New Issue
Block a user