phases: change publish behavior to only alter behavior when server.
authorPierre-Yves David <pierre-yves.david@ens-lyon.org>
Thu, 15 Dec 2011 23:08:09 +0100
changeset 15659 7fba5a245acc
parent 15657 d976b1ef6760
child 15660 c7b0bedbb07a
phases: change publish behavior to only alter behavior when server. Older publish=True was: 1) Content of Publishing server are seen as public by client. 2) Any changegroup *added* to a publish=True server is public. New definition are: 1) Content of Publishing server are seen as public by client. 2) Any changegroup *pushed* to a publish=True server is public. See mercurial/phase.py documentation for exact final behavior
mercurial/localrepo.py
mercurial/phases.py
tests/test-hardlinks.t
tests/test-phases-exchange.t
--- a/mercurial/localrepo.py	Thu Dec 15 15:27:11 2011 -0600
+++ b/mercurial/localrepo.py	Thu Dec 15 23:08:09 2011 +0100
@@ -2045,10 +2045,12 @@
                           url=url, pending=p)
 
             added = [cl.node(r) for r in xrange(clstart, clend)]
-            if self.ui.configbool('phases', 'publish', True):
-                if srctype != 'strip':
-                    phases.advanceboundary(self, 0, added)
-            else:
+            publishing = self.ui.configbool('phases', 'publish', True)
+            if publishing and srctype == 'push':
+                # Old server can not push the boundary themself.
+                # This clause ensure pushed changeset are alway marked as public
+                phases.advanceboundary(self, 0, added)
+            elif srctype != 'strip': # strip should not touch boundary at all
                 phases.retractboundary(self, 1, added)
 
             # make changelog see real files again
--- a/mercurial/phases.py	Thu Dec 15 15:27:11 2011 -0600
+++ b/mercurial/phases.py	Thu Dec 15 23:08:09 2011 +0100
@@ -1,11 +1,99 @@
-# Mercurial phases support code
-#
-# Copyright 2011 Pierre-Yves David <pierre-yves.david@ens-lyon.org>
-#                Logilab SA        <contact@logilab.fr>
-#                Augie Fackler     <durin42@gmail.com>
-#
-# This software may be used and distributed according to the terms of the
-# GNU General Public License version 2 or any later version.
+""" Mercurial phases support code
+
+    ---
+
+    Copyright 2011 Pierre-Yves David <pierre-yves.david@ens-lyon.org>
+                   Logilab SA        <contact@logilab.fr>
+                   Augie Fackler     <durin42@gmail.com>
+
+    This software may be used and distributed according to the terms of the
+    GNU General Public License version 2 or any later version.
+
+    ---
+
+This module implements most phase logic in mercurial.
+
+
+Basic Concept
+=============
+
+A 'changeset phases' is an indicator that tells us how a changeset is
+manipulated and communicated. The details of each phase is described below,
+here we describe the properties they have in common.
+
+Like bookmarks, phases are not stored in history and thus are not permanent and
+leave no audit trail.
+
+First, no changeset can be in two phases at once. Phases are ordered, so they
+can be considered from lowest to highest. The default, lowest phase is 'public'
+- this is the normal phase of existing changesets. A child changeset can not be
+in a lower phase than its parents.
+
+These phases share a hierarchy of traits:
+
+            immutable shared
+    public:     X        X
+    draft:               X
+
+local commits are draft by default
+
+Phase movement and exchange
+============================
+
+Phase data are exchanged by pushkey on pull and push. Some server have a
+publish option set, we call them publishing server. Pushing to such server make
+draft changeset publish.
+
+A small list of fact/rules define the exchange of phase:
+
+* old client never changes server states
+* pull never changes server states
+* publish and old server csets are seen as public by client
+
+
+Here is the final table summing up the 49 possible usecase of phase exchange:
+
+                           server
+                  old     publish      non-publish
+                 N   X    N   D   P    N   D   P
+    old client
+    pull
+     N           -   X/X  -   X/D X/P  -   X/D X/P
+     X           -   X/X  -   X/D X/P  -   X/D X/P
+    push
+     X           X/X X/X  X/P X/P X/P  X/D X/D X/P
+    new client
+    pull
+     N           -   P/X  -   P/D P/P  -   D/D P/P
+     D           -   P/X  -   P/D P/P  -   D/D P/P
+     P           -   P/X  -   P/D P/P  -   P/D P/P
+    push
+     D           P/X P/X  P/P P/P P/P  D/D D/D P/P
+     P           P/X P/X  P/P P/P P/P  P/P P/P P/P
+
+Legend:
+
+    A/B = final state on client / state on server
+
+    * N = new/not present,
+    * P = public,
+    * D = draft,
+    * X = not tracked (ie: the old client or server has no internal way of
+          recording the phase.)
+
+    passive = only pushes
+
+
+    A cell here can be read like this:
+
+    "When a new client pushes a draft changeset (D) to a publishing server
+    where it's not present (N), it's marked public on both sides (P/P)."
+
+Note: old client behave as publish server with Draft only content
+- other people see it as public
+- content is pushed as draft
+
+"""
 
 import errno
 from node import nullid, bin, hex, short
--- a/tests/test-hardlinks.t	Thu Dec 15 15:27:11 2011 -0600
+++ b/tests/test-hardlinks.t	Thu Dec 15 23:08:09 2011 +0100
@@ -96,6 +96,7 @@
   1 r3/.hg/store/data/d1/f2.i
   1 r3/.hg/store/data/f1.i
   1 r3/.hg/store/fncache
+  1 r3/.hg/store/phaseroots
   1 r3/.hg/store/undo
   1 r3/.hg/store/undo.phaseroots
 
--- a/tests/test-phases-exchange.t	Thu Dec 15 15:27:11 2011 -0600
+++ b/tests/test-phases-exchange.t	Thu Dec 15 23:08:09 2011 +0100
@@ -245,8 +245,8 @@
   added 2 changesets with 2 changes to 2 files
   (run 'hg update' to get a working copy)
   $ hgph
-  6 0 n-B - 145e75495359
-  5 0 n-A - d6bcb4f74035
+  6 1 n-B - 145e75495359
+  5 1 n-A - d6bcb4f74035
   4 0 b-A - f54f1bb90ff3
   3 0 a-D - b555f63b6063
   2 0 a-C - 54acac6f23ab
@@ -269,15 +269,38 @@
   2 0 a-C - 54acac6f23ab
   1 0 a-B - 548a3d25dbf0
   0 0 a-A - 054250a37db4
-  $ cd ..
 
 Push
 ````
 
+(inserted)
+
+Test that phase are pushed even when they are nothing to pus
+(this might be tested later bu are very convenient to not alter too much test)
+
+Push back to alpha
+
+  $ hg push ../alpha # from nu
+  pushing to ../alpha
+  searching for changes
+  no changes found
+  $ cd ..
+  $ cd alpha
+  $ hgph
+  6 0 n-B - 145e75495359
+  5 0 n-A - d6bcb4f74035
+  4 0 b-A - f54f1bb90ff3
+  3 0 a-D - b555f63b6063
+  2 0 a-C - 54acac6f23ab
+  1 0 a-B - 548a3d25dbf0
+  0 0 a-A - 054250a37db4
+
+(end insertion)
+
+
 initial setup
 
-  $ cd alpha
-  $ hg glog
+  $ hg glog # of alpha
   o  changeset:   6:145e75495359
   |  tag:         tip
   |  user:        test