[PATCH 2 of 3] pull: call the `b2x-transactionclose` hook when closing the transaction
Pierre-Yves David
pierre-yves.david at ens-lyon.org
Wed Oct 15 15:07:56 CDT 2014
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david at fb.com>
# Date 1413371977 25200
# Wed Oct 15 04:19:37 2014 -0700
# Node ID f8ce7ae07a44373cacbe9e58f8476861e0f342b8
# Parent 4d992e70ad166ae5a98c2f7c7ba242829da59582
pull: call the `b2x-transactionclose` hook when closing the transaction
We need a wider set of hook to process all the change that happened during the
pull transaction. We reusing the experimental `b2x-transactionclose` hook set
from server's unbundle for consistency. This hook is experimental and will not
remains as-is forever, but this will open door for experimentation in 3.2.
diff --git a/mercurial/exchange.py b/mercurial/exchange.py
--- a/mercurial/exchange.py
+++ b/mercurial/exchange.py
@@ -832,11 +832,18 @@ class pulloperation(object):
return self._tr
def closetransaction(self):
"""close transaction if created"""
if self._tr is not None:
+ repo = self.repo
+ cl = repo.unfiltered().changelog
+ p = cl.writepending() and repo.root or ""
+ p = cl.writepending() and repo.root or ""
+ repo.hook('b2x-pretransactionclose', throw=True, pending=p,
+ **self._tr.hookargs)
self._tr.close()
+ repo.hook('b2x-transactionclose', **self._tr.hookargs)
def releasetransaction(self):
"""release transaction if created"""
if self._tr is not None:
self._tr.release()
diff --git a/tests/test-bundle2-exchange.t b/tests/test-bundle2-exchange.t
--- a/tests/test-bundle2-exchange.t
+++ b/tests/test-bundle2-exchange.t
@@ -63,10 +63,11 @@ clone --pull
adding changesets
adding manifests
adding file changes
added 2 changesets with 2 changes to 2 files
1 new obsolescence markers
+ b2x-transactionclose hook: HG_NEW_OBSMARKERS=1 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
changegroup hook: HG_NEW_OBSMARKERS=1 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
updating to branch default
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
$ hg -R other log -G
@ 1:9520eea781bc draft Nicolas Dumazet <nicdumz.commits at gmail.com> E
@@ -85,10 +86,11 @@ pull
adding changesets
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
1 new obsolescence markers
+ b2x-transactionclose hook: HG_NEW_OBSMARKERS=1 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
changegroup hook: HG_NEW_OBSMARKERS=1 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
(run 'hg heads' to see heads, 'hg merge' to merge)
$ hg -R other log -G
o 2:24b6387c8c8c draft Nicolas Dumazet <nicdumz.commits at gmail.com> F
|
@@ -104,10 +106,11 @@ pull empty (with phase movement)
$ hg -R main phase --public 24b6387c8c8c
$ hg -R other pull -r 24b6387c8c8c
pulling from $TESTTMP/main (glob)
no changes found
+ b2x-transactionclose hook: HG_NEW_OBSMARKERS=0 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
$ hg -R other log -G
o 2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits at gmail.com> F
|
| @ 1:9520eea781bc draft Nicolas Dumazet <nicdumz.commits at gmail.com> E
|/
@@ -120,10 +123,11 @@ pull empty (with phase movement)
pull empty
$ hg -R other pull -r 24b6387c8c8c
pulling from $TESTTMP/main (glob)
no changes found
+ b2x-transactionclose hook: HG_NEW_OBSMARKERS=0 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
$ hg -R other log -G
o 2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits at gmail.com> F
|
| @ 1:9520eea781bc draft Nicolas Dumazet <nicdumz.commits at gmail.com> E
|/
@@ -189,10 +193,11 @@ pull over ssh
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
1 new obsolescence markers
updating bookmark book_02de
+ b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_NEW_OBSMARKERS=1 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=ssh://user@dummy/main
changegroup hook: HG_BOOKMARK_MOVED=1 HG_NEW_OBSMARKERS=1 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=ssh://user@dummy/main
(run 'hg heads' to see heads, 'hg merge' to merge)
$ hg -R other debugobsolete
1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
@@ -211,10 +216,11 @@ pull over http
adding manifests
adding file changes
added 1 changesets with 1 changes to 1 files (+1 heads)
1 new obsolescence markers
updating bookmark book_42cc
+ b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_NEW_OBSMARKERS=1 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=http://localhost:$HGPORT/
changegroup hook: HG_BOOKMARK_MOVED=1 HG_NEW_OBSMARKERS=1 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=http://localhost:$HGPORT/
(run 'hg heads .' to see heads, 'hg merge' to merge)
$ cat main-error.log
$ hg -R other debugobsolete
1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
More information about the Mercurial-devel
mailing list