author | Patrick Mezard <patrick@mezard.eu> |
Thu, 10 May 2012 18:21:15 +0200 | |
changeset 16624 | 3f85cef66dcc |
parent 16588 | 72319bfd7966 |
child 16625 | df9df747070d |
permissions | -rw-r--r-- |
15659
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
1 |
""" Mercurial phases support code |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
2 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
3 |
--- |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
4 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
5 |
Copyright 2011 Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
6 |
Logilab SA <contact@logilab.fr> |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
7 |
Augie Fackler <durin42@gmail.com> |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
8 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
9 |
This software may be used and distributed according to the terms of the |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
10 |
GNU General Public License version 2 or any later version. |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
11 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
12 |
--- |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
13 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
14 |
This module implements most phase logic in mercurial. |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
15 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
16 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
17 |
Basic Concept |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
18 |
============= |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
19 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
20 |
A 'changeset phases' is an indicator that tells us how a changeset is |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
21 |
manipulated and communicated. The details of each phase is described below, |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
22 |
here we describe the properties they have in common. |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
23 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
24 |
Like bookmarks, phases are not stored in history and thus are not permanent and |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
25 |
leave no audit trail. |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
26 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
27 |
First, no changeset can be in two phases at once. Phases are ordered, so they |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
28 |
can be considered from lowest to highest. The default, lowest phase is 'public' |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
29 |
- this is the normal phase of existing changesets. A child changeset can not be |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
30 |
in a lower phase than its parents. |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
31 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
32 |
These phases share a hierarchy of traits: |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
33 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
34 |
immutable shared |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
35 |
public: X X |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
36 |
draft: X |
15705
e34f4d1f0dbb
phases: update doc to mention secret phase
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15697
diff
changeset
|
37 |
secret: |
15659
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
38 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
39 |
local commits are draft by default |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
40 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
41 |
Phase movement and exchange |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
42 |
============================ |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
43 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
44 |
Phase data are exchanged by pushkey on pull and push. Some server have a |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
45 |
publish option set, we call them publishing server. Pushing to such server make |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
46 |
draft changeset publish. |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
47 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
48 |
A small list of fact/rules define the exchange of phase: |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
49 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
50 |
* old client never changes server states |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
51 |
* pull never changes server states |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
52 |
* publish and old server csets are seen as public by client |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
53 |
|
15705
e34f4d1f0dbb
phases: update doc to mention secret phase
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15697
diff
changeset
|
54 |
* Any secret changeset seens in another repository is lowered to at least draft |
e34f4d1f0dbb
phases: update doc to mention secret phase
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15697
diff
changeset
|
55 |
|
15659
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
56 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
57 |
Here is the final table summing up the 49 possible usecase of phase exchange: |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
58 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
59 |
server |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
60 |
old publish non-publish |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
61 |
N X N D P N D P |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
62 |
old client |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
63 |
pull |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
64 |
N - X/X - X/D X/P - X/D X/P |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
65 |
X - X/X - X/D X/P - X/D X/P |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
66 |
push |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
67 |
X X/X X/X X/P X/P X/P X/D X/D X/P |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
68 |
new client |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
69 |
pull |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
70 |
N - P/X - P/D P/P - D/D P/P |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
71 |
D - P/X - P/D P/P - D/D P/P |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
72 |
P - P/X - P/D P/P - P/D P/P |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
73 |
push |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
74 |
D P/X P/X P/P P/P P/P D/D D/D P/P |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
75 |
P P/X P/X P/P P/P P/P P/P P/P P/P |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
76 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
77 |
Legend: |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
78 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
79 |
A/B = final state on client / state on server |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
80 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
81 |
* N = new/not present, |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
82 |
* P = public, |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
83 |
* D = draft, |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
84 |
* X = not tracked (ie: the old client or server has no internal way of |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
85 |
recording the phase.) |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
86 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
87 |
passive = only pushes |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
88 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
89 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
90 |
A cell here can be read like this: |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
91 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
92 |
"When a new client pushes a draft changeset (D) to a publishing server |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
93 |
where it's not present (N), it's marked public on both sides (P/P)." |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
94 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
95 |
Note: old client behave as publish server with Draft only content |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
96 |
- other people see it as public |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
97 |
- content is pushed as draft |
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
98 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
99 |
""" |
15417
5261140d9322
phases: Minimal first add.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
100 |
|
15419
ccb7de21625a
phases: handle errors other than ENOENT appropriately
Matt Mackall <mpm@selenic.com>
parents:
15418
diff
changeset
|
101 |
import errno |
15456
abcaaf51d568
phases: handle unknown nodes in boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15454
diff
changeset
|
102 |
from node import nullid, bin, hex, short |
abcaaf51d568
phases: handle unknown nodes in boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15454
diff
changeset
|
103 |
from i18n import _ |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
104 |
|
15818
57241845a4bb
phases: store phase values in constant instead of using raw integer
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15705
diff
changeset
|
105 |
allphases = public, draft, secret = range(3) |
15417
5261140d9322
phases: Minimal first add.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
106 |
trackedphases = allphases[1:] |
15821
e3ee8bf5d0cc
phases: add list of string to access phase name
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15818
diff
changeset
|
107 |
phasenames = ['public', 'draft', 'secret'] |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
108 |
|
16624
3f85cef66dcc
phases: call filterunknown() in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16588
diff
changeset
|
109 |
def _filterunknown(ui, changelog, phaseroots): |
3f85cef66dcc
phases: call filterunknown() in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16588
diff
changeset
|
110 |
"""remove unknown nodes from the phase boundary |
3f85cef66dcc
phases: call filterunknown() in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16588
diff
changeset
|
111 |
|
3f85cef66dcc
phases: call filterunknown() in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16588
diff
changeset
|
112 |
Nothing is lost as unknown nodes only hold data for their descendants |
3f85cef66dcc
phases: call filterunknown() in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16588
diff
changeset
|
113 |
""" |
3f85cef66dcc
phases: call filterunknown() in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16588
diff
changeset
|
114 |
updated = False |
3f85cef66dcc
phases: call filterunknown() in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16588
diff
changeset
|
115 |
nodemap = changelog.nodemap # to filter unknown nodes |
3f85cef66dcc
phases: call filterunknown() in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16588
diff
changeset
|
116 |
for phase, nodes in enumerate(phaseroots): |
3f85cef66dcc
phases: call filterunknown() in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16588
diff
changeset
|
117 |
missing = [node for node in nodes if node not in nodemap] |
3f85cef66dcc
phases: call filterunknown() in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16588
diff
changeset
|
118 |
if missing: |
3f85cef66dcc
phases: call filterunknown() in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16588
diff
changeset
|
119 |
for mnode in missing: |
3f85cef66dcc
phases: call filterunknown() in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16588
diff
changeset
|
120 |
ui.debug( |
3f85cef66dcc
phases: call filterunknown() in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16588
diff
changeset
|
121 |
'removing unknown node %s from %i-phase boundary\n' |
3f85cef66dcc
phases: call filterunknown() in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16588
diff
changeset
|
122 |
% (short(mnode), phase)) |
3f85cef66dcc
phases: call filterunknown() in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16588
diff
changeset
|
123 |
nodes.symmetric_difference_update(missing) |
3f85cef66dcc
phases: call filterunknown() in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16588
diff
changeset
|
124 |
updated = True |
3f85cef66dcc
phases: call filterunknown() in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16588
diff
changeset
|
125 |
return updated |
3f85cef66dcc
phases: call filterunknown() in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16588
diff
changeset
|
126 |
|
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
127 |
def readroots(repo): |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
128 |
"""Read phase roots from disk""" |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
129 |
roots = [set() for i in allphases] |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
130 |
try: |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
131 |
f = repo.sopener('phaseroots') |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
132 |
try: |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
133 |
for line in f: |
16588
72319bfd7966
phases: line.strip().split() == line.split()
Martin Geisler <mg@aragost.com>
parents:
16535
diff
changeset
|
134 |
phase, nh = line.split() |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
135 |
roots[int(phase)].add(bin(nh)) |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
136 |
finally: |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
137 |
f.close() |
15419
ccb7de21625a
phases: handle errors other than ENOENT appropriately
Matt Mackall <mpm@selenic.com>
parents:
15418
diff
changeset
|
138 |
except IOError, inst: |
ccb7de21625a
phases: handle errors other than ENOENT appropriately
Matt Mackall <mpm@selenic.com>
parents:
15418
diff
changeset
|
139 |
if inst.errno != errno.ENOENT: |
ccb7de21625a
phases: handle errors other than ENOENT appropriately
Matt Mackall <mpm@selenic.com>
parents:
15418
diff
changeset
|
140 |
raise |
15922
23921c17299a
phases: mechanism to allow extension to alter initial computation of phase
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15902
diff
changeset
|
141 |
for f in repo._phasedefaults: |
23921c17299a
phases: mechanism to allow extension to alter initial computation of phase
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15902
diff
changeset
|
142 |
roots = f(repo, roots) |
16025
6697498bdd83
phases: write default phase data as soon as possible.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15954
diff
changeset
|
143 |
repo._dirtyphases = True |
16624
3f85cef66dcc
phases: call filterunknown() in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16588
diff
changeset
|
144 |
if _filterunknown(repo.ui, repo.changelog, roots): |
3f85cef66dcc
phases: call filterunknown() in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16588
diff
changeset
|
145 |
repo._dirtyphases = True |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
146 |
return roots |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
147 |
|
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
148 |
def writeroots(repo): |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
149 |
"""Write phase roots from disk""" |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
150 |
f = repo.sopener('phaseroots', 'w', atomictemp=True) |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
151 |
try: |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
152 |
for phase, roots in enumerate(repo._phaseroots): |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
153 |
for h in roots: |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
154 |
f.write('%i %s\n' % (phase, hex(h))) |
15454
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
155 |
repo._dirtyphases = False |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
156 |
finally: |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
157 |
f.close() |
15454
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
158 |
|
15481
0b7ce2f739fb
phases: rename moveboundary into advance boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15480
diff
changeset
|
159 |
def advanceboundary(repo, targetphase, nodes): |
15454
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
160 |
"""Add nodes to a phase changing other nodes phases if necessary. |
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
161 |
|
15482
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
162 |
This function move boundary *forward* this means that all nodes are set |
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
163 |
in the target phase or kept in a *lower* phase. |
15454
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
164 |
|
15482
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
165 |
Simplify boundary to contains phase roots only.""" |
15695
1b9dcf2eb011
phases: fix advanceboundary behavior when targetphase !=0
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15659
diff
changeset
|
166 |
delroots = [] # set of root deleted by this path |
15480
7d4f364c980b
phases: remove underbar into target_phase argument
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15456
diff
changeset
|
167 |
for phase in xrange(targetphase + 1, len(allphases)): |
15454
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
168 |
# filter nodes that are not in a compatible phase already |
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
169 |
# XXX rev phase cache might have been invalidated by a previous loop |
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
170 |
# XXX we need to be smarter here |
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
171 |
nodes = [n for n in nodes if repo[n].phase() >= phase] |
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
172 |
if not nodes: |
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
173 |
break # no roots to move anymore |
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
174 |
roots = repo._phaseroots[phase] |
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
175 |
olds = roots.copy() |
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
176 |
ctxs = list(repo.set('roots((%ln::) - (%ln::%ln))', olds, olds, nodes)) |
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
177 |
roots.clear() |
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
178 |
roots.update(ctx.node() for ctx in ctxs) |
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
179 |
if olds != roots: |
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
180 |
# invalidate cache (we probably could be smarter here |
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
181 |
if '_phaserev' in vars(repo): |
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
182 |
del repo._phaserev |
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
183 |
repo._dirtyphases = True |
15695
1b9dcf2eb011
phases: fix advanceboundary behavior when targetphase !=0
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15659
diff
changeset
|
184 |
# some roots may need to be declared for lower phases |
1b9dcf2eb011
phases: fix advanceboundary behavior when targetphase !=0
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15659
diff
changeset
|
185 |
delroots.extend(olds - roots) |
1b9dcf2eb011
phases: fix advanceboundary behavior when targetphase !=0
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15659
diff
changeset
|
186 |
# declare deleted root in the target phase |
1b9dcf2eb011
phases: fix advanceboundary behavior when targetphase !=0
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15659
diff
changeset
|
187 |
if targetphase != 0: |
1b9dcf2eb011
phases: fix advanceboundary behavior when targetphase !=0
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15659
diff
changeset
|
188 |
retractboundary(repo, targetphase, delroots) |
1b9dcf2eb011
phases: fix advanceboundary behavior when targetphase !=0
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15659
diff
changeset
|
189 |
|
15482
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
190 |
|
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
191 |
def retractboundary(repo, targetphase, nodes): |
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
192 |
"""Set nodes back to a phase changing other nodes phases if necessary. |
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
193 |
|
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
194 |
This function move boundary *backward* this means that all nodes are set |
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
195 |
in the target phase or kept in a *higher* phase. |
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
196 |
|
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
197 |
Simplify boundary to contains phase roots only.""" |
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
198 |
currentroots = repo._phaseroots[targetphase] |
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
199 |
newroots = [n for n in nodes if repo[n].phase() < targetphase] |
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
200 |
if newroots: |
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
201 |
currentroots.update(newroots) |
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
202 |
ctxs = repo.set('roots(%ln::)', currentroots) |
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
203 |
currentroots.intersection_update(ctx.node() for ctx in ctxs) |
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
204 |
if '_phaserev' in vars(repo): |
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
205 |
del repo._phaserev |
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
206 |
repo._dirtyphases = True |
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
207 |
|
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
208 |
|
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
209 |
def listphases(repo): |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
210 |
"""List phases root for serialisation over pushkey""" |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
211 |
keys = {} |
15892
592b3d1742a1
phases: simplify phase exchange and movement over pushkey
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15821
diff
changeset
|
212 |
value = '%i' % draft |
592b3d1742a1
phases: simplify phase exchange and movement over pushkey
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15821
diff
changeset
|
213 |
for root in repo._phaseroots[draft]: |
592b3d1742a1
phases: simplify phase exchange and movement over pushkey
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15821
diff
changeset
|
214 |
keys[hex(root)] = value |
592b3d1742a1
phases: simplify phase exchange and movement over pushkey
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15821
diff
changeset
|
215 |
|
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
216 |
if repo.ui.configbool('phases', 'publish', True): |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
217 |
# Add an extra data to let remote know we are a publishing repo. |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
218 |
# Publishing repo can't just pretend they are old repo. When pushing to |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
219 |
# a publishing repo, the client still need to push phase boundary |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
220 |
# |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
221 |
# Push do not only push changeset. It also push phase data. New |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
222 |
# phase data may apply to common changeset which won't be push (as they |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
223 |
# are common). Here is a very simple example: |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
224 |
# |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
225 |
# 1) repo A push changeset X as draft to repo B |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
226 |
# 2) repo B make changeset X public |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
227 |
# 3) repo B push to repo A. X is not pushed but the data that X as now |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
228 |
# public should |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
229 |
# |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
230 |
# The server can't handle it on it's own as it has no idea of client |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
231 |
# phase data. |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
232 |
keys['publishing'] = 'True' |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
233 |
return keys |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
234 |
|
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
235 |
def pushphase(repo, nhex, oldphasestr, newphasestr): |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
236 |
"""List phases root for serialisation over pushkey""" |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
237 |
lock = repo.lock() |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
238 |
try: |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
239 |
currentphase = repo[nhex].phase() |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
240 |
newphase = abs(int(newphasestr)) # let's avoid negative index surprise |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
241 |
oldphase = abs(int(oldphasestr)) # let's avoid negative index surprise |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
242 |
if currentphase == oldphase and newphase < oldphase: |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
243 |
advanceboundary(repo, newphase, [bin(nhex)]) |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
244 |
return 1 |
16051
2aa5b51f310f
phases: don't complain if cset is already public on pushkey (issue3230)
Matt Mackall <mpm@selenic.com>
parents:
16030
diff
changeset
|
245 |
elif currentphase == newphase: |
2aa5b51f310f
phases: don't complain if cset is already public on pushkey (issue3230)
Matt Mackall <mpm@selenic.com>
parents:
16030
diff
changeset
|
246 |
# raced, but got correct result |
2aa5b51f310f
phases: don't complain if cset is already public on pushkey (issue3230)
Matt Mackall <mpm@selenic.com>
parents:
16030
diff
changeset
|
247 |
return 1 |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
248 |
else: |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
249 |
return 0 |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
250 |
finally: |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
251 |
lock.release() |
15649
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
252 |
|
15697
21eb048edc19
phases: add a function to compute visible heads
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15696
diff
changeset
|
253 |
def visibleheads(repo): |
21eb048edc19
phases: add a function to compute visible heads
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15696
diff
changeset
|
254 |
"""return the set of visible head of this repo""" |
21eb048edc19
phases: add a function to compute visible heads
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15696
diff
changeset
|
255 |
# XXX we want a cache on this |
15818
57241845a4bb
phases: store phase values in constant instead of using raw integer
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15705
diff
changeset
|
256 |
sroots = repo._phaseroots[secret] |
15697
21eb048edc19
phases: add a function to compute visible heads
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15696
diff
changeset
|
257 |
if sroots: |
21eb048edc19
phases: add a function to compute visible heads
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15696
diff
changeset
|
258 |
# XXX very slow revset. storing heads or secret "boundary" would help. |
21eb048edc19
phases: add a function to compute visible heads
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15696
diff
changeset
|
259 |
revset = repo.set('heads(not (%ln::))', sroots) |
21eb048edc19
phases: add a function to compute visible heads
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15696
diff
changeset
|
260 |
|
21eb048edc19
phases: add a function to compute visible heads
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15696
diff
changeset
|
261 |
vheads = [ctx.node() for ctx in revset] |
21eb048edc19
phases: add a function to compute visible heads
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15696
diff
changeset
|
262 |
if not vheads: |
21eb048edc19
phases: add a function to compute visible heads
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15696
diff
changeset
|
263 |
vheads.append(nullid) |
21eb048edc19
phases: add a function to compute visible heads
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15696
diff
changeset
|
264 |
else: |
21eb048edc19
phases: add a function to compute visible heads
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15696
diff
changeset
|
265 |
vheads = repo.heads() |
21eb048edc19
phases: add a function to compute visible heads
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15696
diff
changeset
|
266 |
return vheads |
21eb048edc19
phases: add a function to compute visible heads
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15696
diff
changeset
|
267 |
|
16535
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
268 |
def visiblebranchmap(repo): |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
269 |
"""return a branchmap for the visible set""" |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
270 |
# XXX Recomputing this data on the fly is very slow. We should build a |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
271 |
# XXX cached version while computin the standard branchmap version. |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
272 |
sroots = repo._phaseroots[secret] |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
273 |
if sroots: |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
274 |
vbranchmap = {} |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
275 |
for branch, nodes in repo.branchmap().iteritems(): |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
276 |
# search for secret heads. |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
277 |
for n in nodes: |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
278 |
if repo[n].phase() >= secret: |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
279 |
nodes = None |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
280 |
break |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
281 |
# if secreat heads where found we must compute them again |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
282 |
if nodes is None: |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
283 |
s = repo.set('heads(branch(%s) - secret())', branch) |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
284 |
nodes = [c.node() for c in s] |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
285 |
vbranchmap[branch] = nodes |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
286 |
else: |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
287 |
vbranchmap = repo.branchmap() |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
288 |
return vbranchmap |
39d1f83eb05d
branchmap: server should not advertise secret changeset in branchmap (Issue3303)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16293
diff
changeset
|
289 |
|
15649
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
290 |
def analyzeremotephases(repo, subset, roots): |
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
291 |
"""Compute phases heads and root in a subset of node from root dict |
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
292 |
|
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
293 |
* subset is heads of the subset |
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
294 |
* roots is {<nodeid> => phase} mapping. key and value are string. |
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
295 |
|
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
296 |
Accept unknown element input |
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
297 |
""" |
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
298 |
# build list from dictionary |
15892
592b3d1742a1
phases: simplify phase exchange and movement over pushkey
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15821
diff
changeset
|
299 |
draftroots = [] |
15902
4252d9f08d7e
phases: use nodemap to check for missing nodes
Sune Foldager <cryo@cyanite.org>
parents:
15892
diff
changeset
|
300 |
nodemap = repo.changelog.nodemap # to filter unknown nodes |
15649
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
301 |
for nhex, phase in roots.iteritems(): |
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
302 |
if nhex == 'publishing': # ignore data related to publish option |
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
303 |
continue |
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
304 |
node = bin(nhex) |
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
305 |
phase = int(phase) |
15892
592b3d1742a1
phases: simplify phase exchange and movement over pushkey
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15821
diff
changeset
|
306 |
if phase == 0: |
592b3d1742a1
phases: simplify phase exchange and movement over pushkey
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15821
diff
changeset
|
307 |
if node != nullid: |
15953
52dc2b33d0be
phase: fix warning text from invalid remote phase
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15948
diff
changeset
|
308 |
repo.ui.warn(_('ignoring inconsistent public root' |
52dc2b33d0be
phase: fix warning text from invalid remote phase
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15948
diff
changeset
|
309 |
' from remote: %s\n') % nhex) |
15892
592b3d1742a1
phases: simplify phase exchange and movement over pushkey
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15821
diff
changeset
|
310 |
elif phase == 1: |
15902
4252d9f08d7e
phases: use nodemap to check for missing nodes
Sune Foldager <cryo@cyanite.org>
parents:
15892
diff
changeset
|
311 |
if node in nodemap: |
15892
592b3d1742a1
phases: simplify phase exchange and movement over pushkey
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15821
diff
changeset
|
312 |
draftroots.append(node) |
592b3d1742a1
phases: simplify phase exchange and movement over pushkey
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15821
diff
changeset
|
313 |
else: |
15953
52dc2b33d0be
phase: fix warning text from invalid remote phase
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15948
diff
changeset
|
314 |
repo.ui.warn(_('ignoring unexpected root from remote: %i %s\n') |
52dc2b33d0be
phase: fix warning text from invalid remote phase
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15948
diff
changeset
|
315 |
% (phase, nhex)) |
15649
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
316 |
# compute heads |
15954
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
317 |
publicheads = newheads(repo, subset, draftroots) |
15892
592b3d1742a1
phases: simplify phase exchange and movement over pushkey
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15821
diff
changeset
|
318 |
return publicheads, draftroots |
15649
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
319 |
|
15954
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
320 |
def newheads(repo, heads, roots): |
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
321 |
"""compute new head of a subset minus another |
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
322 |
|
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
323 |
* `heads`: define the first subset |
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
324 |
* `rroots`: define the second we substract to the first""" |
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
325 |
revset = repo.set('heads((%ln + parents(%ln)) - (%ln::%ln))', |
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
326 |
heads, roots, roots, heads) |
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
327 |
return [c.node() for c in revset] |
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
328 |
|
16030
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
329 |
|
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
330 |
def newcommitphase(ui): |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
331 |
"""helper to get the target phase of new commit |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
332 |
|
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
333 |
Handle all possible values for the phases.new-commit options. |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
334 |
|
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
335 |
""" |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
336 |
v = ui.config('phases', 'new-commit', draft) |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
337 |
try: |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
338 |
return phasenames.index(v) |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
339 |
except ValueError: |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
340 |
try: |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
341 |
return int(v) |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
342 |
except ValueError: |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
343 |
msg = _("phases.new-commit: not a valid phase name ('%s')") |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
344 |
raise error.ConfigError(msg % v) |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
345 |