Patchwork [STABLE] changelog: fix readpending if no pending data exist (issue4609)

login
register
mail settings
Submitter Pierre-Yves David
Date April 20, 2015, 4:47 p.m.
Message ID <249dbb11aba1a7587487.1429548455@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/8748/
State Accepted
Headers show

Comments

Pierre-Yves David - April 20, 2015, 4:47 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1429542982 -7200
#      Mon Apr 20 17:16:22 2015 +0200
# Branch stable
# Node ID 249dbb11aba1a75874870362459a6920bedfeae4
# Parent  8d7d0bf62f9f84fef087c07eef505d5cd5b4c602
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.
Matt Mackall - April 20, 2015, 4:53 p.m.
On Mon, 2015-04-20 at 18:47 +0200, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1429542982 -7200
> #      Mon Apr 20 17:16:22 2015 +0200
> # Branch stable
> # Node ID 249dbb11aba1a75874870362459a6920bedfeae4
> # Parent  8d7d0bf62f9f84fef087c07eef505d5cd5b4c602
> changelog: fix readpending if no pending data exist  (issue4609)

Queued for stable, thanks.

Patch

diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -265,10 +265,12 @@  class changelog(revlog.revlog):
         self._divert = False
         # split when we're done
         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
         self._nodecache = r._nodecache
         self._chunkcache = r._chunkcache
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
@@ -70,11 +70,11 @@  Add more obsolescence information
   txnclose hook: HG_NEW_OBSMARKERS=1 HG_TXNID=TXN:* HG_TXNNAME=debugobsolete (glob)
 
 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
   adding changesets
   adding manifests
@@ -96,11 +96,11 @@  clone --pull
   1111111111111111111111111111111111111111 9520eea781bcca16c1e15acc0ba14335a0e8e5ba 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
 
 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
   pulling from $TESTTMP/main (glob)
   searching for changes
@@ -126,17 +126,17 @@  pull
   2222222222222222222222222222222222222222 24b6387c8c8cae37178880f3fa95ded3cb1cf785 0 (Thu Jan 01 00:00:00 1970 +0000) {'user': 'test'}
 
 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)
   $ hg -R other log -G
   o  2:24b6387c8c8c public Nicolas Dumazet <nicdumz.commits@gmail.com>  F
@@ -202,11 +202,11 @@  add extra data to test their exchange du
   $ hg -R other bookmark --rev cd010b8cd998 book_42cc
   $ hg -R other bookmark --rev cd010b8cd998 book_5fdd
   $ 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)
 
 push
   $ hg -R main push other --rev eea13746799a --bookmark book_eea1
@@ -342,11 +342,11 @@  push over http
 
   $ hg -R other serve -p $HGPORT2 -d --pid-file=other.pid -E other-error.log
   $ 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
   pushing to http://localhost:$HGPORT2/
   searching for changes
diff --git a/tests/test-pending.t b/tests/test-pending.t
--- a/tests/test-pending.t
+++ b/tests/test-pending.t
@@ -111,5 +111,29 @@  test external hook
   hook 29b62aeb769fdf78d8d9c5f28b017f76d7ef824b
   transaction abort!
   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