Mercurial > public > mercurial-scm > hg-stable
diff mercurial/localrepo.py @ 26751:520defbc0335
hook: centralize passing HG_PENDING to external hook process
This patch centralizes passing HG_PENDING to external hook process
into '_exthook()'. To make in-memory changes visible to external hook
process, this patch does:
- write (or schedule to write) in-memory dirstate changes, and
- set HG_PENDING environment variable, if:
- a transaction is running, and
- there are in-memory changes to be visible
This patch tests some commands with some hooks, because transaction
activity of a same hook differs from each other ("---": "not tested").
======== ========= ========= ============
command preupdate precommit pretxncommit
======== ========= ========= ============
unshelve o --- ---
backout x --- ---
import --- o o
qrefresh --- x o
======== ========= ========= ============
Each hooks are examined separately to prevent in-memory changes from
being visible to external process accidentally by side effect of hooks
previously invoked.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sat, 17 Oct 2015 01:15:34 +0900 |
parents | 5ba0a99ff27f |
children | 69a121c378ef |
line wrap: on
line diff
--- a/mercurial/localrepo.py Sat Oct 17 01:15:34 2015 +0900 +++ b/mercurial/localrepo.py Sat Oct 17 01:15:34 2015 +0900 @@ -994,8 +994,7 @@ reporef = weakref.ref(self) def validate(tr): """will run pre-closing hooks""" - pending = lambda: tr.writepending() and self.root or "" - reporef().hook('pretxnclose', throw=True, pending=pending, + reporef().hook('pretxnclose', throw=True, txnname=desc, **tr.hookargs) def releasefn(tr, success): repo = reporef() @@ -1682,10 +1681,9 @@ n = self.changelog.add(mn, files, ctx.description(), trp, p1.node(), p2.node(), user, ctx.date(), ctx.extra().copy()) - p = lambda: tr.writepending() and self.root or "" xp1, xp2 = p1.hex(), p2 and p2.hex() or '' self.hook('pretxncommit', throw=True, node=hex(n), parent1=xp1, - parent2=xp2, pending=p) + parent2=xp2) # set the new commit is proper phase targetphase = subrepo.newcommitphase(self.ui, ctx) if targetphase: @@ -1865,8 +1863,6 @@ hookargs = {} if tr is not None: hookargs.update(tr.hookargs) - pending = lambda: tr.writepending() and self.root or "" - hookargs['pending'] = pending hookargs['namespace'] = namespace hookargs['key'] = key hookargs['old'] = old