annotate mercurial/phases.py @ 15696:0cb45fef99ba

phases: Add a third phase for secret changeset
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Sun, 18 Dec 2011 23:16:46 +0100
parents 1b9dcf2eb011
children 21eb048edc19
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
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
7fba5a245acc phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15649
diff changeset
37
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 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
39
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 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
41 ============================
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 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
44 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
45 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
46
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 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
48
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 * 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
50 * 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
51 * 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
52
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
7fba5a245acc phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15649
diff changeset
54 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
55
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 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
57 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
58 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
59 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
60 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
61 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
62 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
63 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
64 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
65 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
66 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
67 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
68 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
69 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
70 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
71 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
72 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
73
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 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
75
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 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
77
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 * 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
79 * 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
80 * 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
81 * 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
82 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
83
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 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
85
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 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
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 "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
90 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
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 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
93 - 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
94 - 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
95
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 """
15417
5261140d9322 phases: Minimal first add.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
97
15419
ccb7de21625a phases: handle errors other than ENOENT appropriately
Matt Mackall <mpm@selenic.com>
parents: 15418
diff changeset
98 import errno
15456
abcaaf51d568 phases: handle unknown nodes in boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15454
diff changeset
99 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
100 from i18n import _
15418
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
101
15696
0cb45fef99ba phases: Add a third phase for secret changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15695
diff changeset
102 allphases = range(3)
15417
5261140d9322 phases: Minimal first add.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff changeset
103 trackedphases = allphases[1:]
15418
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
104
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
105 def readroots(repo):
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
106 """Read phase roots from disk"""
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
107 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
108 roots[0].add(nullid)
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
109 try:
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
110 f = repo.sopener('phaseroots')
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
111 try:
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
112 for line in f:
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
113 phase, nh = line.strip().split()
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
114 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
115 finally:
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
116 f.close()
15419
ccb7de21625a phases: handle errors other than ENOENT appropriately
Matt Mackall <mpm@selenic.com>
parents: 15418
diff changeset
117 except IOError, inst:
ccb7de21625a phases: handle errors other than ENOENT appropriately
Matt Mackall <mpm@selenic.com>
parents: 15418
diff changeset
118 if inst.errno != errno.ENOENT:
ccb7de21625a phases: handle errors other than ENOENT appropriately
Matt Mackall <mpm@selenic.com>
parents: 15418
diff changeset
119 raise
15418
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
120 return roots
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
121
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
122 def writeroots(repo):
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
123 """Write phase roots from disk"""
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
124 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
125 try:
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
126 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
127 for h in roots:
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
128 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
129 repo._dirtyphases = False
15418
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
130 finally:
cf729af26963 phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15417
diff changeset
131 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
132
15456
abcaaf51d568 phases: handle unknown nodes in boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15454
diff changeset
133 def filterunknown(repo, phaseroots=None):
abcaaf51d568 phases: handle unknown nodes in boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15454
diff changeset
134 """remove unknown nodes from the phase boundary
abcaaf51d568 phases: handle unknown nodes in boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15454
diff changeset
135
abcaaf51d568 phases: handle unknown nodes in boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15454
diff changeset
136 no data is lost as unknown node only old data for their descentants
abcaaf51d568 phases: handle unknown nodes in boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15454
diff changeset
137 """
abcaaf51d568 phases: handle unknown nodes in boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15454
diff changeset
138 if phaseroots is None:
abcaaf51d568 phases: handle unknown nodes in boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15454
diff changeset
139 phaseroots = repo._phaseroots
abcaaf51d568 phases: handle unknown nodes in boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15454
diff changeset
140 for phase, nodes in enumerate(phaseroots):
abcaaf51d568 phases: handle unknown nodes in boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15454
diff changeset
141 missing = [node for node in nodes if node not in repo]
abcaaf51d568 phases: handle unknown nodes in boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15454
diff changeset
142 if missing:
abcaaf51d568 phases: handle unknown nodes in boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15454
diff changeset
143 for mnode in missing:
abcaaf51d568 phases: handle unknown nodes in boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15454
diff changeset
144 msg = _('Removing unknown node %(n)s from %(p)i-phase boundary')
abcaaf51d568 phases: handle unknown nodes in boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15454
diff changeset
145 repo.ui.debug(msg, {'n': short(mnode), 'p': phase})
abcaaf51d568 phases: handle unknown nodes in boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15454
diff changeset
146 nodes.symmetric_difference_update(missing)
abcaaf51d568 phases: handle unknown nodes in boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15454
diff changeset
147 repo._dirtyphases = True
abcaaf51d568 phases: handle unknown nodes in boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15454
diff changeset
148
15481
0b7ce2f739fb phases: rename moveboundary into advance boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15480
diff changeset
149 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
150 """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
151
15482
a667c89e49b3 phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15481
diff changeset
152 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
153 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
154
15482
a667c89e49b3 phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15481
diff changeset
155 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
156 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
157 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
158 # 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
159 # 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
160 # 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
161 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
162 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
163 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
164 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
165 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
166 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
167 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
168 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
169 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
170 # 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
171 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
172 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
173 repo._dirtyphases = True
15695
1b9dcf2eb011 phases: fix advanceboundary behavior when targetphase !=0
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15659
diff changeset
174 # 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
175 delroots.extend(olds - roots)
1b9dcf2eb011 phases: fix advanceboundary behavior when targetphase !=0
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15659
diff changeset
176 # 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
177 if targetphase != 0:
1b9dcf2eb011 phases: fix advanceboundary behavior when targetphase !=0
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15659
diff changeset
178 retractboundary(repo, targetphase, delroots)
1b9dcf2eb011 phases: fix advanceboundary behavior when targetphase !=0
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15659
diff changeset
179
15482
a667c89e49b3 phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15481
diff changeset
180
a667c89e49b3 phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15481
diff changeset
181 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
182 """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
183
a667c89e49b3 phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15481
diff changeset
184 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
185 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
186
a667c89e49b3 phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15481
diff changeset
187 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
188 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
189 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
190 if newroots:
a667c89e49b3 phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15481
diff changeset
191 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
192 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
193 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
194 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
195 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
196 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
197
15648
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
198
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
199 def listphases(repo):
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
200 """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
201 keys = {}
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
202 for phase in trackedphases:
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
203 for root in repo._phaseroots[phase]:
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
204 keys[hex(root)] = '%i' % phase
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
205 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
206 # 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
207 # 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
208 # 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
209 #
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
210 # 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
211 # 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
212 # 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
213 #
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
214 # 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
215 # 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
216 # 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
217 # public should
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
218 #
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
219 # 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
220 # phase data.
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
221 keys['publishing'] = 'True'
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
222 return keys
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
223
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
224 def pushphase(repo, nhex, oldphasestr, newphasestr):
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
225 """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
226 lock = repo.lock()
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
227 try:
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
228 currentphase = repo[nhex].phase()
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
229 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
230 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
231 if currentphase == oldphase and newphase < oldphase:
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
232 advanceboundary(repo, newphase, [bin(nhex)])
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
233 return 1
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
234 else:
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
235 return 0
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
236 finally:
79cc89de5be1 phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 15482
diff changeset
237 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
238
ca7c4254a21a phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15648
diff changeset
239 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
240 """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
241
ca7c4254a21a phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15648
diff changeset
242 * 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
243 * 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
244
ca7c4254a21a phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15648
diff changeset
245 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
246 """
ca7c4254a21a phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15648
diff changeset
247 # build list from dictionary
ca7c4254a21a phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15648
diff changeset
248 phaseroots = [[] for p in allphases]
ca7c4254a21a phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15648
diff changeset
249 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
250 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
251 continue
ca7c4254a21a phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15648
diff changeset
252 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
253 phase = int(phase)
ca7c4254a21a phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15648
diff changeset
254 if node in repo:
ca7c4254a21a phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15648
diff changeset
255 phaseroots[phase].append(node)
ca7c4254a21a phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15648
diff changeset
256 # compute heads
ca7c4254a21a phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15648
diff changeset
257 phaseheads = [[] for p in allphases]
ca7c4254a21a phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15648
diff changeset
258 for phase in allphases[:-1]:
ca7c4254a21a phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15648
diff changeset
259 toproof = phaseroots[phase + 1]
ca7c4254a21a phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15648
diff changeset
260 revset = repo.set('heads((%ln + parents(%ln)) - (%ln::%ln))',
ca7c4254a21a phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15648
diff changeset
261 subset, toproof, toproof, subset)
ca7c4254a21a phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15648
diff changeset
262 phaseheads[phase].extend(c.node() for c in revset)
ca7c4254a21a phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15648
diff changeset
263 return phaseheads, phaseroots
ca7c4254a21a phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 15648
diff changeset
264