[PATCH 3 of 3 🚂] exchange: use the postclose API on transaction
Augie Fackler
raf at durin42.com
Fri Nov 7 10:17:05 CST 2014
On Fri, Nov 07, 2014 at 04:05:30PM +0000, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david at fb.com>
> # Date 1414504716 -3600
> # Tue Oct 28 14:58:36 2014 +0100
> # Node ID fd24dc73428037b74a7ada3f704b94f0573ab50f
> # Parent 27fbb6a1d103c2b4178f859f9010c58601d7042f
> exchange: use the postclose API on transaction
Queued these with EN tweaks.
>
> As for changegroup, we should wait for the transaction to be really closed
> before scheduling the hooks execution.
>
> diff --git a/mercurial/exchange.py b/mercurial/exchange.py
> --- a/mercurial/exchange.py
> +++ b/mercurial/exchange.py
> @@ -855,15 +855,16 @@ class pulloperation(object):
> if self._tr is not None:
> repo = self.repo
> p = lambda: self._tr.writepending() and repo.root or ""
> repo.hook('b2x-pretransactionclose', throw=True, pending=p,
> **self._tr.hookargs)
> - self._tr.close()
> hookargs = dict(self._tr.hookargs)
> def runhooks():
> repo.hook('b2x-transactionclose', **hookargs)
> - repo._afterlock(runhooks)
> + self._tr.addpostclose('b2x-hook-transactionclose',
> + lambda: repo._afterlock(runhooks))
> + self._tr.close()
>
> def releasetransaction(self):
> """release transaction if created"""
> if self._tr is not None:
> self._tr.release()
> @@ -1278,15 +1279,16 @@ def unbundle(repo, cg, heads, source, ur
> tr.hookargs['bundle2-exp'] = '1'
> r = bundle2.processbundle(repo, cg, lambda: tr).reply
> p = lambda: tr.writepending() and repo.root or ""
> repo.hook('b2x-pretransactionclose', throw=True, pending=p,
> **tr.hookargs)
> - tr.close()
> hookargs = dict(tr.hookargs)
> def runhooks():
> repo.hook('b2x-transactionclose', **hookargs)
> - repo._afterlock(runhooks)
> + tr.addpostclose('b2x-hook-transactionclose',
> + lambda: repo._afterlock(runhooks))
> + tr.close()
> except Exception, exc:
> exc.duringunbundle2 = True
> raise
> else:
> r = changegroup.addchangegroup(repo, cg, source, url)
> 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
> @@ -57,12 +57,12 @@ 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_NODE=cd010b8cd998f3981a5a8115f94f8da4ab506089 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
> changegroup hook: HG_NODE=cd010b8cd998f3981a5a8115f94f8da4ab506089 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
> - b2x-transactionclose hook: HG_NEW_OBSMARKERS=1 HG_NODE=cd010b8cd998f3981a5a8115f94f8da4ab506089 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
> |
> @@ -80,12 +80,12 @@ 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_NODE=24b6387c8c8cae37178880f3fa95ded3cb1cf785 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
> changegroup hook: HG_NODE=24b6387c8c8cae37178880f3fa95ded3cb1cf785 HG_SOURCE=pull HG_URL=file:$TESTTMP/main
> - b2x-transactionclose hook: HG_NEW_OBSMARKERS=1 HG_NODE=24b6387c8c8cae37178880f3fa95ded3cb1cf785 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
> |
> | @ 1:9520eea781bc draft Nicolas Dumazet <nicdumz.commits at gmail.com> E
> @@ -154,12 +154,12 @@ add extra data to test their exchange du
>
> push
> $ hg -R main push other --rev eea13746799a --bookmark book_eea1
> pushing to other
> searching for changes
> + b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2-EXP=1 HG_NEW_OBSMARKERS=1 HG_NODE=eea13746799a9e0bfd88f29d3c2e9dc9389f524f HG_PHASES_MOVED=1 HG_SOURCE=push HG_URL=push
> changegroup hook: HG_BUNDLE2-EXP=1 HG_NODE=eea13746799a9e0bfd88f29d3c2e9dc9389f524f HG_SOURCE=push HG_URL=push
> - b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2-EXP=1 HG_NEW_OBSMARKERS=1 HG_NODE=eea13746799a9e0bfd88f29d3c2e9dc9389f524f HG_PHASES_MOVED=1 HG_SOURCE=push HG_URL=push
> remote: adding changesets
> remote: adding manifests
> remote: adding file changes
> remote: added 1 changesets with 0 changes to 0 files (-1 heads)
> remote: 1 new obsolescence markers
> @@ -187,12 +187,12 @@ 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_NODE=02de42196ebee42ef284b6780a87cdc96e8eaab6 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=ssh://user@dummy/main
> changegroup hook: HG_NODE=02de42196ebee42ef284b6780a87cdc96e8eaab6 HG_SOURCE=pull HG_URL=ssh://user@dummy/main
> - b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_NEW_OBSMARKERS=1 HG_NODE=02de42196ebee42ef284b6780a87cdc96e8eaab6 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'}
> 3333333333333333333333333333333333333333 eea13746799a9e0bfd88f29d3c2e9dc9389f524f 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
> @@ -210,12 +210,12 @@ 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_NODE=42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_URL=http://localhost:$HGPORT/
> changegroup hook: HG_NODE=42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 HG_SOURCE=pull HG_URL=http://localhost:$HGPORT/
> - b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_NEW_OBSMARKERS=1 HG_NODE=42ccdea3bb16d28e1848c95fe2e44c000f3f21b1 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'}
> 2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
> @@ -232,12 +232,12 @@ push over ssh
> remote: adding manifests
> remote: adding file changes
> remote: added 1 changesets with 1 changes to 1 files
> remote: 1 new obsolescence markers
> updating bookmark book_5fdd
> + remote: b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2-EXP=1 HG_NEW_OBSMARKERS=1 HG_NODE=5fddd98957c8a54a4d436dfe1da9d87f21a1b97b HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1
> remote: changegroup hook: HG_BUNDLE2-EXP=1 HG_NODE=5fddd98957c8a54a4d436dfe1da9d87f21a1b97b HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1
> - remote: b2x-transactionclose hook: HG_BOOKMARK_MOVED=1 HG_BUNDLE2-EXP=1 HG_NEW_OBSMARKERS=1 HG_NODE=5fddd98957c8a54a4d436dfe1da9d87f21a1b97b HG_SOURCE=serve HG_URL=remote:ssh:127.0.0.1
> $ hg -R other log -G
> o 6:5fddd98957c8 draft Nicolas Dumazet <nicdumz.commits at gmail.com> book_5fdd C
> |
> o 5:42ccdea3bb16 draft Nicolas Dumazet <nicdumz.commits at gmail.com> book_42cc B
> |
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel
More information about the Mercurial-devel
mailing list