Patchwork [2,of,2] pushkey: flush pending data before running a pre-pushkey hook (issue4607)

login
register
mail settings
Submitter Pierre-Yves David
Date April 20, 2015, 4:44 p.m.
Message ID <cbef1d5421d7b1e2dcb9.1429548264@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/8747/
State Accepted
Commit 7f9655f3716390df1484ebda60b38a2d191024b6
Headers show

Comments

Pierre-Yves David - April 20, 2015, 4:44 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1429542965 -7200
#      Mon Apr 20 17:16:05 2015 +0200
# Branch stable
# Node ID cbef1d5421d7b1e2dcb9b6e541c5749343c114a5
# Parent  2f9f8e4ca47e26dbf1183585edc364f3ef72c549
pushkey: flush pending data before running a pre-pushkey hook (issue4607)

The pre-pushkey hook will likely validate the pushkey based on element
previously changed in the same transaction. We need to make theses data
available for the hook.
Matt Mackall - April 20, 2015, 9:59 p.m.
On Mon, 2015-04-20 at 18:44 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1429542965 -7200
> #      Mon Apr 20 17:16:05 2015 +0200
> # Branch stable
> # Node ID cbef1d5421d7b1e2dcb9b6e541c5749343c114a5
> # Parent  2f9f8e4ca47e26dbf1183585edc364f3ef72c549
> pushkey: flush pending data before running a pre-pushkey hook (issue4607)

These are queued for stable, thanks.

Patch

diff --git a/mercurial/localrepo.py b/mercurial/localrepo.py
--- a/mercurial/localrepo.py
+++ b/mercurial/localrepo.py
@@ -1900,10 +1900,12 @@  class localrepository(object):
         try:
             tr = self.currenttransaction()
             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
             hookargs['new'] = new
             self.hook('prepushkey', throw=True, **hookargs)