From bf28a4a61f27e476f3e9b245d1054799c6079555 Mon Sep 17 00:00:00 2001 From: Pierre-Yves David Date: Mon, 20 Apr 2015 17:16:22 +0200 Subject: [PATCH] changelog: fix readpending if no pending data exist (issue4609) Since transaction are used for more than just changesets, it is possible to have a transaction without new changesets at all. In this case no ''00changelog.i.a' are written. In all cases the 'changelog.readpending' method is called if the repository has any pending data. The 'revlog' logic provides empty content if the file is missing, so the whole operation resulted in an empty changelog. We now skip reading the pending file if it is missing. --- mercurial/changelog.py | 2 ++ tests/test-bundle2-exchange.t | 12 ++++++------ tests/test-pending.t | 24 ++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 6 deletions(-) diff --git a/mercurial/changelog.py b/mercurial/changelog.py index fe1593cc5f..ff091ca4cc 100644 --- a/mercurial/changelog.py +++ b/mercurial/changelog.py @@ -267,6 +267,8 @@ class changelog(revlog.revlog): self.checkinlinesize(tr) def readpending(self, file): + if not self.opener.exists(file): + return # no pending data for changelog r = revlog.revlog(self.opener, file) self.index = r.index self.nodemap = r.nodemap diff --git a/tests/test-bundle2-exchange.t b/tests/test-bundle2-exchange.t index 159a3b200c..0d8eb29fc7 100644 --- a/tests/test-bundle2-exchange.t +++ b/tests/test-bundle2-exchange.t @@ -72,7 +72,7 @@ Add more obsolescence information clone --pull $ hg -R main phase --public cd010b8cd998 - pre-close-tip:000000000000 public + pre-close-tip:02de42196ebe draft postclose-tip:02de42196ebe draft txnclose hook: HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=phase (glob) $ hg clone main other --pull --rev 9520eea781bc @@ -98,7 +98,7 @@ clone --pull pull $ hg -R main phase --public 9520eea781bc - pre-close-tip:000000000000 public + pre-close-tip:02de42196ebe draft postclose-tip:02de42196ebe draft txnclose hook: HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=phase (glob) $ hg -R other pull -r 24b6387c8c8c @@ -128,13 +128,13 @@ pull pull empty (with phase movement) $ hg -R main phase --public 24b6387c8c8c - pre-close-tip:000000000000 public + pre-close-tip:02de42196ebe draft postclose-tip:02de42196ebe draft txnclose hook: HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=phase (glob) $ hg -R other pull -r 24b6387c8c8c pulling from $TESTTMP/main (glob) no changes found - pre-close-tip:000000000000 public + pre-close-tip:24b6387c8c8c public postclose-tip:24b6387c8c8c public txnclose hook: HG_NEW_OBSMARKERS=0 HG_PHASES_MOVED=1 HG_SOURCE=pull HG_TXNID=TXN:* HG_TXNNAME=pull (glob) file:/*/$TESTTMP/main HG_URL=file:$TESTTMP/main (glob) @@ -204,7 +204,7 @@ add extra data to test their exchange during push $ hg -R other bookmark --rev cd010b8cd998 book_32af $ hg -R main phase --public eea13746799a - pre-close-tip:000000000000 public + pre-close-tip:02de42196ebe draft book_02de postclose-tip:02de42196ebe draft book_02de txnclose hook: HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=phase (glob) @@ -344,7 +344,7 @@ push over http $ cat other.pid >> $DAEMON_PIDS $ hg -R main phase --public 32af7686d403 - pre-close-tip:000000000000 public + pre-close-tip:02de42196ebe draft book_02de postclose-tip:02de42196ebe draft book_02de txnclose hook: HG_PHASES_MOVED=1 HG_TXNID=TXN:* HG_TXNNAME=phase (glob) $ hg -R main push http://localhost:$HGPORT2/ -r 32af7686d403 --bookmark book_32af diff --git a/tests/test-pending.t b/tests/test-pending.t index d449d29ec1..acc3171a9f 100644 --- a/tests/test-pending.t +++ b/tests/test-pending.t @@ -113,3 +113,27 @@ test external hook rollback completed abort: pretxnchangegroup hook exited with status 1 pull 0000000000000000000000000000000000000000 + +Test that pending on transaction without changegroup see the normal changegroup( +(issue4609) + + $ cat < parent/.hg/hgrc + > [hooks] + > pretxnchangegroup= + > pretxnclose = hg tip -T 'tip: {node|short}\n' + > [phases] + > publishing=False + > EOF + +setup + + $ cd parent + $ echo a > a + $ hg add a + $ hg commit -m a + tip: cb9a9f314b8b + +actual test + + $ hg phase --public . + tip: cb9a9f314b8b