[PATCH 1 of 5 STABLE V2] localrepo: rename hook argument from TXNID to txnid

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Tue May 19 19:40:35 UTC 2015


# HG changeset patch
# User FUJIWARA Katsunori <foozy at lares.dti.ne.jp>
# Date 1432064067 -32400
#      Wed May 20 04:34:27 2015 +0900
# Branch stable
# Node ID 81c0fdfa3c6337d279322f467b3c7d910c53522b
# Parent  ef4538ba67ef0d63fe55d4defa7b5993f0d16b6f
localrepo: rename hook argument from TXNID to txnid

>From the first (3.4 or d283517b260b), `TXNID` is passed to Python
hooks without lowering its name, but it is wrong.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -985,7 +985,7 @@
                                      validator=validate)
 
         trid = 'TXN:' + util.sha1("%s#%f" % (id(tr), time.time())).hexdigest()
-        tr.hookargs['TXNID'] = trid
+        tr.hookargs['txnid'] = trid
         # note: writing the fncache only during finalize mean that the file is
         # outdated when running hooks. As fncache is used for streaming clone,
         # this is not expected to break anything that happen during the hooks.
diff --git a/tests/test-hook.t b/tests/test-hook.t
--- a/tests/test-hook.t
+++ b/tests/test-hook.t
@@ -1,6 +1,11 @@
 commit hooks can see env vars
 (and post-transaction one are run unlocked)
 
+  $ cat > $TESTTMP/txnabort.checkargs.py <<EOF
+  > def showargs(ui, repo, hooktype, **kwargs):
+  >     ui.write('%s python hook: %s\n' % (hooktype, ','.join(sorted(kwargs))))
+  > EOF
+
   $ hg init a
   $ cd a
   $ cat > .hg/hgrc <<EOF
@@ -16,7 +21,8 @@
   > pretxnopen = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxnopen"
   > pretxnclose = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" pretxnclose"
   > txnclose = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" txnclose"
-  > txnabort = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" txnabort"
+  > txnabort.0 = python:$TESTTMP/txnabort.checkargs.py:showargs
+  > txnabort.1 = sh -c "HG_LOCAL= HG_TAG= python \"$TESTDIR/printenv.py\" txnabort"
   > txnclose.checklock = sh -c "hg debuglock > /dev/null"
   > EOF
   $ echo a > a
@@ -164,6 +170,7 @@
   5:6f611f8018c1
   pretxncommit.forbid hook: HG_NODE=6f611f8018c10e827fee6bd2bc807f937e761567 HG_PARENT1=539e4b31b6dc99b3cfbaa6b53cbc1c1f9a1e3a10 HG_PENDING=$TESTTMP/a
   transaction abort!
+  txnabort python hook: txnid,txnname
   txnabort hook: HG_TXNID=TXN:* HG_TXNNAME=commit (glob)
   rollback completed
   abort: pretxncommit.forbid1 hook exited with status 1


More information about the Mercurial-devel mailing list