Patchwork [7,of,7] phases: read pending data when appropriate

login
register
mail settings
Submitter Pierre-Yves David
Date Nov. 18, 2014, 11:40 p.m.
Message ID <dbfbacaef794f8ba6778.1416354004@marginatus.alto.octopoid.net>
Download mbox | patch
Permalink /patch/6777/
State Accepted
Commit 936b0ff3434668e2b8c25476664056764ce3b498
Headers show

Comments

Pierre-Yves David - Nov. 18, 2014, 11:40 p.m.
# HG changeset patch
# User Pierre-Yves David <pierre-yves.david@fb.com>
# Date 1413609786 25200
#      Fri Oct 17 22:23:06 2014 -0700
# Node ID dbfbacaef794f8ba6778b83d9f56c28ea6ce95c7
# Parent  70d34957c8eab543e1da1f7a23ed21d72b9772c5
phases: read pending data when appropriate

If we are called by a hook and pending data exists, read those.
Matt Mackall - Nov. 19, 2014, 4:22 p.m.
On Tue, 2014-11-18 at 23:40 +0000, Pierre-Yves David wrote:
> # HG changeset patch
> # User Pierre-Yves David <pierre-yves.david@fb.com>
> # Date 1413609786 25200
> #      Fri Oct 17 22:23:06 2014 -0700
> # Node ID dbfbacaef794f8ba6778b83d9f56c28ea6ce95c7
> # Parent  70d34957c8eab543e1da1f7a23ed21d72b9772c5
> phases: read pending data when appropriate

These are queued for default, thanks. I think we need a way to
encapsulate the pending logic though.

Patch

diff --git a/mercurial/phases.py b/mercurial/phases.py
--- a/mercurial/phases.py
+++ b/mercurial/phases.py
@@ -98,10 +98,11 @@  Note: old client behave as a publishing 
 - other people see it as public
 - content is pushed as draft
 
 """
 
+import os
 import errno
 from node import nullid, nullrev, bin, hex, short
 from i18n import _
 import util, error
 
@@ -122,11 +123,19 @@  def _readroots(repo, phasedefaults=None)
     """
     repo = repo.unfiltered()
     dirty = False
     roots = [set() for i in allphases]
     try:
-        f = repo.sopener('phaseroots')
+        f = None
+        if 'HG_PENDING' in os.environ:
+            try:
+                f = repo.svfs('phaseroots.pending')
+            except IOError, inst:
+                if inst.errno != errno.ENOENT:
+                    raise
+        if f is None:
+            f = repo.sopener('phaseroots')
         try:
             for line in f:
                 phase, nh = line.split()
                 roots[int(phase)].add(bin(nh))
         finally:
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
@@ -59,11 +59,11 @@  clone --pull
   adding changesets
   adding manifests
   adding file changes
   added 2 changesets with 2 changes to 2 files
   1 new obsolescence markers
-  pre-close-tip:9520eea781bc public 
+  pre-close-tip:9520eea781bc draft 
   postclose-tip:9520eea781bc draft 
   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
   updating to branch default
   2 files updated, 0 files merged, 0 files removed, 0 files unresolved
@@ -84,11 +84,11 @@  pull
   adding changesets
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files (+1 heads)
   1 new obsolescence markers
-  pre-close-tip:24b6387c8c8c public 
+  pre-close-tip:24b6387c8c8c draft 
   postclose-tip:24b6387c8c8c draft 
   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
   (run 'hg heads' to see heads, 'hg merge' to merge)
   $ hg -R other log -G
@@ -164,11 +164,11 @@  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
-  pre-close-tip:eea13746799a draft book_eea1
+  pre-close-tip:eea13746799a public book_eea1
   postclose-tip:eea13746799a public book_eea1
   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
   remote: adding changesets
   remote: adding manifests
@@ -199,11 +199,11 @@  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
-  pre-close-tip:02de42196ebe public book_02de
+  pre-close-tip:02de42196ebe draft book_02de
   postclose-tip:02de42196ebe draft 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
   (run 'hg heads' to see heads, 'hg merge' to merge)
   $ hg -R other debugobsolete
@@ -224,11 +224,11 @@  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
-  pre-close-tip:42ccdea3bb16 public book_42cc
+  pre-close-tip:42ccdea3bb16 draft book_42cc
   postclose-tip:42ccdea3bb16 draft 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/
   (run 'hg heads .' to see heads, 'hg merge' to merge)
   $ cat main-error.log