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.
--- a/mercurial/changelog.py Mon Apr 20 15:27:55 2015 +0200
+++ b/mercurial/changelog.py Mon Apr 20 17:16:22 2015 +0200
@@ -267,6 +267,8 @@
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
--- a/tests/test-bundle2-exchange.t Mon Apr 20 15:27:55 2015 +0200
+++ b/tests/test-bundle2-exchange.t Mon Apr 20 17:16:22 2015 +0200
@@ -72,7 +72,7 @@
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 @@
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 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 @@
$ 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 @@
$ 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
--- a/tests/test-pending.t Mon Apr 20 15:27:55 2015 +0200
+++ b/tests/test-pending.t Mon Apr 20 17:16:22 2015 +0200
@@ -113,3 +113,27 @@
rollback completed
abort: pretxnchangegroup hook exited with status 1
pull 0000000000000000000000000000000000000000
+
+Test that pending on transaction without changegroup see the normal changegroup(
+(issue4609)
+
+ $ cat <<EOF > 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