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.
This commit is contained in:
Pierre-Yves David 2015-04-20 17:16:22 +02:00
parent cb2e913723
commit bf28a4a61f
3 changed files with 32 additions and 6 deletions

View File

@ -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

View File

@ -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

View File

@ -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 <<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