Re: [PATCH 10 of 10] transaction: include txnname in the hookargs dictionary

2019-02-18 Thread Boris FELD
On 09/02/2019 23:34, Pulkit Goyal wrote:
>
>
> On Sun, Feb 10, 2019 at 3:54 AM Boris Feld  > wrote:
>
> # HG changeset patch
> # User Boris Feld  >
> # Date 1549749690 -3600
> #      Sat Feb 09 23:01:30 2019 +0100
> # Node ID f4936120d74a81199068bed14a04ac65f24f6109
> # Parent  62d13ee8373ad4a7c97192680a4781fe5818a1df
> # EXP-Topic hook.txname
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #              hg pull
> https://bitbucket.org/octobus/mercurial-devel/ -r f4936120d74a
> transaction: include txnname in the hookargs dictionary
>
> There is no reason to not include the txnname alongside the txnid
> in all case.
> So let's do that. If the transaction name is useful to internal
> code, it can
> be useful for hooks.
>
>
> What are the cases when we have transaction name and source different?

I don't remember anything specific about the rationale for this patch.
It has been laying around for a long while (first version date back from
May 2015). At that point, I think the point is mostly to make the shell
hook consistent with the python one. (Because the Python one take this
argument already).
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


Re: [PATCH 10 of 10] transaction: include txnname in the hookargs dictionary

2019-02-09 Thread Pulkit Goyal
On Sun, Feb 10, 2019 at 3:54 AM Boris Feld  wrote:

> # HG changeset patch
> # User Boris Feld 
> # Date 1549749690 -3600
> #  Sat Feb 09 23:01:30 2019 +0100
> # Node ID f4936120d74a81199068bed14a04ac65f24f6109
> # Parent  62d13ee8373ad4a7c97192680a4781fe5818a1df
> # EXP-Topic hook.txname
> # Available At https://bitbucket.org/octobus/mercurial-devel/
> #  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r
> f4936120d74a
> transaction: include txnname in the hookargs dictionary
>
> There is no reason to not include the txnname alongside the txnid in all
> case.
> So let's do that. If the transaction name is useful to internal code, it
> can
> be useful for hooks.
>

What are the cases when we have transaction name and source different?

>
> diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
> --- a/mercurial/localrepo.py
> +++ b/mercurial/localrepo.py
> @@ -1811,7 +1811,6 @@ class localrepository(object):
>  args = tr.hookargs.copy()
>  args.update(bookmarks.preparehookargs(name, old, new))
>  repo.hook('pretxnclose-bookmark', throw=True,
> -  txnname=desc,
>**pycompat.strkwargs(args))
>  if hook.hashook(repo.ui, 'pretxnclose-phase'):
>  cl = repo.unfiltered().changelog
> @@ -1819,11 +1818,11 @@ class localrepository(object):
>  args = tr.hookargs.copy()
>  node = hex(cl.node(rev))
>  args.update(phases.preparehookargs(node, old, new))
> -repo.hook('pretxnclose-phase', throw=True,
> txnname=desc,
> +repo.hook('pretxnclose-phase', throw=True,
>**pycompat.strkwargs(args))
>
>  repo.hook('pretxnclose', throw=True,
> -  txnname=desc, **pycompat.strkwargs(tr.hookargs))
> +  **pycompat.strkwargs(tr.hookargs))
>  def releasefn(tr, success):
>  repo = reporef()
>  if success:
> @@ -1857,6 +1856,7 @@ class localrepository(object):
>  tr.changes['bookmarks'] = {}
>
>  tr.hookargs['txnid'] = txnid
> +tr.hookargs['txnname'] = desc
>  # 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.
> @@ -1878,7 +1878,7 @@ class localrepository(object):
>  args = tr.hookargs.copy()
>  args.update(bookmarks.preparehookargs(name, old,
> new))
>  repo.hook('txnclose-bookmark', throw=False,
> -  txnname=desc,
> **pycompat.strkwargs(args))
> +  **pycompat.strkwargs(args))
>
>  if hook.hashook(repo.ui, 'txnclose-phase'):
>  cl = repo.unfiltered().changelog
> @@ -1887,10 +1887,10 @@ class localrepository(object):
>  args = tr.hookargs.copy()
>  node = hex(cl.node(rev))
>  args.update(phases.preparehookargs(node, old,
> new))
> -repo.hook('txnclose-phase', throw=False,
> txnname=desc,
> +repo.hook('txnclose-phase', throw=False,
>**pycompat.strkwargs(args))
>
> -repo.hook('txnclose', throw=False, txnname=desc,
> +repo.hook('txnclose', throw=False,
>**pycompat.strkwargs(hookargs))
>  reporef()._afterlock(hookfunc)
>  tr.addfinalize('txnclose-hook', txnclosehook)
> @@ -1902,7 +1902,7 @@ class localrepository(object):
>  def txnaborthook(tr2):
>  """To be run if transaction is aborted
>  """
> -reporef().hook('txnabort', throw=False, txnname=desc,
> +reporef().hook('txnabort', throw=False,
> **pycompat.strkwargs(tr2.hookargs))
>  tr.addabort('txnabort-hook', txnaborthook)
>  # avoid eager cache invalidation. in-memory data should be
> identical
> diff --git a/tests/test-bundle.t b/tests/test-bundle.t
> --- a/tests/test-bundle.t
> +++ b/tests/test-bundle.t
> @@ -239,6 +239,8 @@ hg -R bundle://../full.hg verify
>HG_NODE_LAST=aa35859c02ea8bd48da5da68cd2740ac71afcbaf
>HG_SOURCE=pull
>HG_TXNID=TXN:$ID$
> +  HG_TXNNAME=pull
> +  bundle:../full.hg
>HG_URL=bundle:../full.hg
>
>(run 'hg heads' to see heads, 'hg merge' to merge)
> @@ -270,6 +272,8 @@ Pull full.hg into empty again (using -R;
>HG_NODE_LAST=aa35859c02ea8bd48da5da68cd2740ac71afcbaf
>HG_SOURCE=pull
>HG_TXNID=TXN:$ID$
> +  HG_TXNNAME=pull
> +  bundle:empty+full.hg
>HG_URL=bundle:empty+full.hg
>
>(run 'hg heads' to see heads, 'hg merge' to merge)
> 

[PATCH 10 of 10] transaction: include txnname in the hookargs dictionary

2019-02-09 Thread Boris Feld
# HG changeset patch
# User Boris Feld 
# Date 1549749690 -3600
#  Sat Feb 09 23:01:30 2019 +0100
# Node ID f4936120d74a81199068bed14a04ac65f24f6109
# Parent  62d13ee8373ad4a7c97192680a4781fe5818a1df
# EXP-Topic hook.txname
# Available At https://bitbucket.org/octobus/mercurial-devel/
#  hg pull https://bitbucket.org/octobus/mercurial-devel/ -r 
f4936120d74a
transaction: include txnname in the hookargs dictionary

There is no reason to not include the txnname alongside the txnid in all case.
So let's do that. If the transaction name is useful to internal code, it can
be useful for hooks.

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1811,7 +1811,6 @@ class localrepository(object):
 args = tr.hookargs.copy()
 args.update(bookmarks.preparehookargs(name, old, new))
 repo.hook('pretxnclose-bookmark', throw=True,
-  txnname=desc,
   **pycompat.strkwargs(args))
 if hook.hashook(repo.ui, 'pretxnclose-phase'):
 cl = repo.unfiltered().changelog
@@ -1819,11 +1818,11 @@ class localrepository(object):
 args = tr.hookargs.copy()
 node = hex(cl.node(rev))
 args.update(phases.preparehookargs(node, old, new))
-repo.hook('pretxnclose-phase', throw=True, txnname=desc,
+repo.hook('pretxnclose-phase', throw=True,
   **pycompat.strkwargs(args))
 
 repo.hook('pretxnclose', throw=True,
-  txnname=desc, **pycompat.strkwargs(tr.hookargs))
+  **pycompat.strkwargs(tr.hookargs))
 def releasefn(tr, success):
 repo = reporef()
 if success:
@@ -1857,6 +1856,7 @@ class localrepository(object):
 tr.changes['bookmarks'] = {}
 
 tr.hookargs['txnid'] = txnid
+tr.hookargs['txnname'] = desc
 # 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.
@@ -1878,7 +1878,7 @@ class localrepository(object):
 args = tr.hookargs.copy()
 args.update(bookmarks.preparehookargs(name, old, new))
 repo.hook('txnclose-bookmark', throw=False,
-  txnname=desc, **pycompat.strkwargs(args))
+  **pycompat.strkwargs(args))
 
 if hook.hashook(repo.ui, 'txnclose-phase'):
 cl = repo.unfiltered().changelog
@@ -1887,10 +1887,10 @@ class localrepository(object):
 args = tr.hookargs.copy()
 node = hex(cl.node(rev))
 args.update(phases.preparehookargs(node, old, new))
-repo.hook('txnclose-phase', throw=False, txnname=desc,
+repo.hook('txnclose-phase', throw=False,
   **pycompat.strkwargs(args))
 
-repo.hook('txnclose', throw=False, txnname=desc,
+repo.hook('txnclose', throw=False,
   **pycompat.strkwargs(hookargs))
 reporef()._afterlock(hookfunc)
 tr.addfinalize('txnclose-hook', txnclosehook)
@@ -1902,7 +1902,7 @@ class localrepository(object):
 def txnaborthook(tr2):
 """To be run if transaction is aborted
 """
-reporef().hook('txnabort', throw=False, txnname=desc,
+reporef().hook('txnabort', throw=False,
**pycompat.strkwargs(tr2.hookargs))
 tr.addabort('txnabort-hook', txnaborthook)
 # avoid eager cache invalidation. in-memory data should be identical
diff --git a/tests/test-bundle.t b/tests/test-bundle.t
--- a/tests/test-bundle.t
+++ b/tests/test-bundle.t
@@ -239,6 +239,8 @@ hg -R bundle://../full.hg verify
   HG_NODE_LAST=aa35859c02ea8bd48da5da68cd2740ac71afcbaf
   HG_SOURCE=pull
   HG_TXNID=TXN:$ID$
+  HG_TXNNAME=pull
+  bundle:../full.hg
   HG_URL=bundle:../full.hg
   
   (run 'hg heads' to see heads, 'hg merge' to merge)
@@ -270,6 +272,8 @@ Pull full.hg into empty again (using -R;
   HG_NODE_LAST=aa35859c02ea8bd48da5da68cd2740ac71afcbaf
   HG_SOURCE=pull
   HG_TXNID=TXN:$ID$
+  HG_TXNNAME=pull
+  bundle:empty+full.hg
   HG_URL=bundle:empty+full.hg
   
   (run 'hg heads' to see heads, 'hg merge' to merge)
diff --git a/tests/test-bundle2-multiple-changegroups.t 
b/tests/test-bundle2-multiple-changegroups.t
--- a/tests/test-bundle2-multiple-changegroups.t
+++ b/tests/test-bundle2-multiple-changegroups.t
@@ -88,6 +88,8 @@ Pull the new commits in the clone
   HG_PENDING=$TESTTMP/clone
   HG_SOURCE=pull
   HG_TXNID=TXN:$ID$
+