author | Yuya Nishihara <yuya@tcha.org> |
Sat, 30 Aug 2014 17:38:14 +0200 | |
changeset 23030 | a0e0aa12b672 |
parent 22940 | e803186296ab |
child 23361 | 936b0ff34346 |
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 |
|
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
9 |
This software may be used and distributed according to the terms |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
10 |
of the GNU General Public License version 2 or any later version. |
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
|
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 |
|
16724
00535da82faf
phases: fix typos in docstrings
Martin Geisler <martin@geisler.net>
parents:
16659
diff
changeset
|
20 |
A 'changeset phase' is an indicator that tells us how a changeset is |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
21 |
manipulated and communicated. The details of each phase is described |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
22 |
below, here we describe the properties they have in common. |
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
|
23 |
|
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
24 |
Like bookmarks, phases are not stored in history and thus are not |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
25 |
permanent and leave no audit trail. |
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
|
26 |
|
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
27 |
First, no changeset can be in two phases at once. Phases are ordered, |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
28 |
so they can be considered from lowest to highest. The default, lowest |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
29 |
phase is 'public' - this is the normal phase of existing changesets. A |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
30 |
child changeset can not be in a lower phase than its parents. |
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
|
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 |
|
16724
00535da82faf
phases: fix typos in docstrings
Martin Geisler <martin@geisler.net>
parents:
16659
diff
changeset
|
39 |
Local commits are draft by default. |
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
|
40 |
|
16724
00535da82faf
phases: fix typos in docstrings
Martin Geisler <martin@geisler.net>
parents:
16659
diff
changeset
|
41 |
Phase Movement and Exchange |
00535da82faf
phases: fix typos in docstrings
Martin Geisler <martin@geisler.net>
parents:
16659
diff
changeset
|
42 |
=========================== |
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
|
43 |
|
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
44 |
Phase data is exchanged by pushkey on pull and push. Some servers have |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
45 |
a publish option set, we call such a server a "publishing server". |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
46 |
Pushing a draft changeset to a publishing server changes the phase to |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
47 |
public. |
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
|
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 |
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
|
50 |
|
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 |
* 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
|
52 |
* pull never changes server states |
16724
00535da82faf
phases: fix typos in docstrings
Martin Geisler <martin@geisler.net>
parents:
16659
diff
changeset
|
53 |
* publish and old server changesets are seen as public by client |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
54 |
* any secret changeset seen in another repository is lowered to at |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
55 |
least draft |
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 |
|
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
57 |
Here is the final table summing up the 49 possible use cases of phase |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
58 |
exchange: |
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
|
59 |
|
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 |
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
|
61 |
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
|
62 |
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
|
63 |
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
|
64 |
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
|
65 |
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
|
66 |
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
|
67 |
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
|
68 |
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
|
69 |
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
|
70 |
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
|
71 |
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
|
72 |
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
|
73 |
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
|
74 |
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
|
75 |
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
|
76 |
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
|
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 |
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
|
79 |
|
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 |
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
|
81 |
|
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 |
* 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
|
83 |
* 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
|
84 |
* D = draft, |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
85 |
* X = not tracked (i.e., the old client or server has no internal |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
86 |
way of recording the phase.) |
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
|
87 |
|
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 |
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
|
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 |
|
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 |
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
|
92 |
|
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
93 |
"When a new client pushes a draft changeset (D) to a publishing |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
94 |
server where it's not present (N), it's marked public on both |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
95 |
sides (P/P)." |
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
|
96 |
|
16724
00535da82faf
phases: fix typos in docstrings
Martin Geisler <martin@geisler.net>
parents:
16659
diff
changeset
|
97 |
Note: old client behave as a publishing server with draft only content |
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
|
98 |
- 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
|
99 |
- 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
|
100 |
|
7fba5a245acc
phases: change publish behavior to only alter behavior when server.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15649
diff
changeset
|
101 |
""" |
15417
5261140d9322
phases: Minimal first add.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
102 |
|
15419
ccb7de21625a
phases: handle errors other than ENOENT appropriately
Matt Mackall <mpm@selenic.com>
parents:
15418
diff
changeset
|
103 |
import errno |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
104 |
from node import nullid, nullrev, bin, hex, short |
15456
abcaaf51d568
phases: handle unknown nodes in boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15454
diff
changeset
|
105 |
from i18n import _ |
17979
b3ec0b5fd777
phases: fix missing "error" module import (issue3707)
André Sintzoff <andre.sintzoff@gmail.com>
parents:
17671
diff
changeset
|
106 |
import util, error |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
107 |
|
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
|
108 |
allphases = public, draft, secret = range(3) |
15417
5261140d9322
phases: Minimal first add.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
109 |
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
|
110 |
phasenames = ['public', 'draft', 'secret'] |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
111 |
|
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
112 |
def _readroots(repo, phasedefaults=None): |
16625
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
113 |
"""Read phase roots from disk |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
114 |
|
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
115 |
phasedefaults is a list of fn(repo, roots) callable, which are |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
116 |
executed if the phase roots file does not exist. When phases are |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
117 |
being initialized on an existing repository, this could be used to |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
118 |
set selected changesets phase to something else than public. |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
119 |
|
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
120 |
Return (roots, dirty) where dirty is true if roots differ from |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
121 |
what is being stored. |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
122 |
""" |
18002
9bc5873e52af
clfilter: phases logic should be unfiltered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17979
diff
changeset
|
123 |
repo = repo.unfiltered() |
16625
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
124 |
dirty = False |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
125 |
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
|
126 |
try: |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
127 |
f = repo.sopener('phaseroots') |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
128 |
try: |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
129 |
for line in f: |
16588
72319bfd7966
phases: line.strip().split() == line.split()
Martin Geisler <mg@aragost.com>
parents:
16535
diff
changeset
|
130 |
phase, nh = line.split() |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
131 |
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
|
132 |
finally: |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
133 |
f.close() |
15419
ccb7de21625a
phases: handle errors other than ENOENT appropriately
Matt Mackall <mpm@selenic.com>
parents:
15418
diff
changeset
|
134 |
except IOError, inst: |
ccb7de21625a
phases: handle errors other than ENOENT appropriately
Matt Mackall <mpm@selenic.com>
parents:
15418
diff
changeset
|
135 |
if inst.errno != errno.ENOENT: |
ccb7de21625a
phases: handle errors other than ENOENT appropriately
Matt Mackall <mpm@selenic.com>
parents:
15418
diff
changeset
|
136 |
raise |
16625
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
137 |
if phasedefaults: |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
138 |
for f in phasedefaults: |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
139 |
roots = f(repo, roots) |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
140 |
dirty = True |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
141 |
return roots, dirty |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
142 |
|
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
143 |
class phasecache(object): |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
144 |
def __init__(self, repo, phasedefaults, _load=True): |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
145 |
if _load: |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
146 |
# Cheap trick to allow shallow-copy without copy module |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
147 |
self.phaseroots, self.dirty = _readroots(repo, phasedefaults) |
18220
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
148 |
self._phaserevs = None |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
149 |
self.filterunknown(repo) |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
150 |
self.opener = repo.sopener |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
151 |
|
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
152 |
def copy(self): |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
153 |
# Shallow copy meant to ensure isolation in |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
154 |
# advance/retractboundary(), nothing more. |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
155 |
ph = phasecache(None, None, _load=False) |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
156 |
ph.phaseroots = self.phaseroots[:] |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
157 |
ph.dirty = self.dirty |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
158 |
ph.opener = self.opener |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
159 |
ph._phaserevs = self._phaserevs |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
160 |
return ph |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
161 |
|
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
162 |
def replace(self, phcache): |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
163 |
for a in 'phaseroots dirty opener _phaserevs'.split(): |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
164 |
setattr(self, a, getattr(phcache, a)) |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
165 |
|
22893
9672f0b2cdd9
phases: add invalidate function
Durham Goode <durham@fb.com>
parents:
22080
diff
changeset
|
166 |
def getphaserevs(self, repo): |
9672f0b2cdd9
phases: add invalidate function
Durham Goode <durham@fb.com>
parents:
22080
diff
changeset
|
167 |
if self._phaserevs is None: |
18002
9bc5873e52af
clfilter: phases logic should be unfiltered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17979
diff
changeset
|
168 |
repo = repo.unfiltered() |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
169 |
revs = [public] * len(repo.changelog) |
22894
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
170 |
self._phaserevs = revs |
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
171 |
self._populatephaseroots(repo) |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
172 |
for phase in trackedphases: |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
173 |
roots = map(repo.changelog.rev, self.phaseroots[phase]) |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
174 |
if roots: |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
175 |
for rev in roots: |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
176 |
revs[rev] = phase |
16867
1093ad1e8903
revlog: descendants(*revs) becomes descendants(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents:
16725
diff
changeset
|
177 |
for rev in repo.changelog.descendants(roots): |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
178 |
revs[rev] = phase |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
179 |
return self._phaserevs |
22894
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
180 |
|
22893
9672f0b2cdd9
phases: add invalidate function
Durham Goode <durham@fb.com>
parents:
22080
diff
changeset
|
181 |
def invalidate(self): |
9672f0b2cdd9
phases: add invalidate function
Durham Goode <durham@fb.com>
parents:
22080
diff
changeset
|
182 |
self._phaserevs = None |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
183 |
|
22894
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
184 |
def _populatephaseroots(self, repo): |
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
185 |
"""Fills the _phaserevs cache with phases for the roots. |
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
186 |
""" |
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
187 |
cl = repo.changelog |
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
188 |
phaserevs = self._phaserevs |
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
189 |
for phase in trackedphases: |
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
190 |
roots = map(cl.rev, self.phaseroots[phase]) |
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
191 |
for root in roots: |
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
192 |
phaserevs[root] = phase |
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
193 |
|
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
194 |
def phase(self, repo, rev): |
17424
e7cfe3587ea4
fix trivial spelling errors
Mads Kiilerich <mads@kiilerich.com>
parents:
17205
diff
changeset
|
195 |
# We need a repo argument here to be able to build _phaserevs |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
196 |
# if necessary. The repository instance is not stored in |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
197 |
# phasecache to avoid reference cycles. The changelog instance |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
198 |
# is not stored because it is a filecache() property and can |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
199 |
# be replaced without us being notified. |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
200 |
if rev == nullrev: |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
201 |
return public |
19984
7d5e7799a29f
rebase: fix rebase aborts when 'tip-1' is public (issue4082)
Durham Goode <durham@fb.com>
parents:
19951
diff
changeset
|
202 |
if rev < nullrev: |
7d5e7799a29f
rebase: fix rebase aborts when 'tip-1' is public (issue4082)
Durham Goode <durham@fb.com>
parents:
19951
diff
changeset
|
203 |
raise ValueError(_('cannot lookup negative revision')) |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
204 |
if self._phaserevs is None or rev >= len(self._phaserevs): |
22893
9672f0b2cdd9
phases: add invalidate function
Durham Goode <durham@fb.com>
parents:
22080
diff
changeset
|
205 |
self.invalidate() |
9672f0b2cdd9
phases: add invalidate function
Durham Goode <durham@fb.com>
parents:
22080
diff
changeset
|
206 |
self._phaserevs = self.getphaserevs(repo) |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
207 |
return self._phaserevs[rev] |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
208 |
|
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
209 |
def write(self): |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
210 |
if not self.dirty: |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
211 |
return |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
212 |
f = self.opener('phaseroots', 'w', atomictemp=True) |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
213 |
try: |
22079
5dcc58649b1a
phase: extract the phaseroots serialization in a dedicated method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22070
diff
changeset
|
214 |
self._write(f) |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
215 |
finally: |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
216 |
f.close() |
22079
5dcc58649b1a
phase: extract the phaseroots serialization in a dedicated method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22070
diff
changeset
|
217 |
|
5dcc58649b1a
phase: extract the phaseroots serialization in a dedicated method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22070
diff
changeset
|
218 |
def _write(self, fp): |
5dcc58649b1a
phase: extract the phaseroots serialization in a dedicated method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22070
diff
changeset
|
219 |
for phase, roots in enumerate(self.phaseroots): |
5dcc58649b1a
phase: extract the phaseroots serialization in a dedicated method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22070
diff
changeset
|
220 |
for h in roots: |
5dcc58649b1a
phase: extract the phaseroots serialization in a dedicated method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22070
diff
changeset
|
221 |
fp.write('%i %s\n' % (phase, hex(h))) |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
222 |
self.dirty = False |
15454
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
223 |
|
22080
37f46575d9c2
phase: attach phase to the transaction instead of the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22079
diff
changeset
|
224 |
def _updateroots(self, phase, newroots, tr): |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
225 |
self.phaseroots[phase] = newroots |
22893
9672f0b2cdd9
phases: add invalidate function
Durham Goode <durham@fb.com>
parents:
22080
diff
changeset
|
226 |
self.invalidate() |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
227 |
self.dirty = True |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
228 |
|
22080
37f46575d9c2
phase: attach phase to the transaction instead of the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22079
diff
changeset
|
229 |
tr.addfilegenerator('phase', ('phaseroots',), self._write) |
22940
e803186296ab
phases: inform transaction-related hooks that a phase was moved
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22894
diff
changeset
|
230 |
tr.hookargs['phases_moved'] = '1' |
22080
37f46575d9c2
phase: attach phase to the transaction instead of the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22079
diff
changeset
|
231 |
|
22069
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22052
diff
changeset
|
232 |
def advanceboundary(self, repo, tr, targetphase, nodes): |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
233 |
# Be careful to preserve shallow-copied values: do not update |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
234 |
# phaseroots values, replace them. |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
235 |
|
18002
9bc5873e52af
clfilter: phases logic should be unfiltered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17979
diff
changeset
|
236 |
repo = repo.unfiltered() |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
237 |
delroots = [] # set of root deleted by this path |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
238 |
for phase in xrange(targetphase + 1, len(allphases)): |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
239 |
# filter nodes that are not in a compatible phase already |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
240 |
nodes = [n for n in nodes |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
241 |
if self.phase(repo, repo[n].rev()) >= phase] |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
242 |
if not nodes: |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
243 |
break # no roots to move anymore |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
244 |
olds = self.phaseroots[phase] |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
245 |
roots = set(ctx.node() for ctx in repo.set( |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
246 |
'roots((%ln::) - (%ln::%ln))', olds, olds, nodes)) |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
247 |
if olds != roots: |
22080
37f46575d9c2
phase: attach phase to the transaction instead of the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22079
diff
changeset
|
248 |
self._updateroots(phase, roots, tr) |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
249 |
# some roots may need to be declared for lower phases |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
250 |
delroots.extend(olds - roots) |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
251 |
# declare deleted root in the target phase |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
252 |
if targetphase != 0: |
22070
c1ca47204590
phase: add a transaction argument to retractboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22069
diff
changeset
|
253 |
self.retractboundary(repo, tr, targetphase, delroots) |
18105
312262ebc223
cache: group obscache and revsfiltercache invalidation in a single function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18101
diff
changeset
|
254 |
repo.invalidatevolatilesets() |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
255 |
|
22070
c1ca47204590
phase: add a transaction argument to retractboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22069
diff
changeset
|
256 |
def retractboundary(self, repo, tr, targetphase, nodes): |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
257 |
# Be careful to preserve shallow-copied values: do not update |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
258 |
# phaseroots values, replace them. |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
259 |
|
18002
9bc5873e52af
clfilter: phases logic should be unfiltered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17979
diff
changeset
|
260 |
repo = repo.unfiltered() |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
261 |
currentroots = self.phaseroots[targetphase] |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
262 |
newroots = [n for n in nodes |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
263 |
if self.phase(repo, repo[n].rev()) < targetphase] |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
264 |
if newroots: |
16659
58edd786e96f
phase: make if abort on nullid for the good reason
Patrick Mezard <patrick@mezard.eu>
parents:
16658
diff
changeset
|
265 |
if nullid in newroots: |
58edd786e96f
phase: make if abort on nullid for the good reason
Patrick Mezard <patrick@mezard.eu>
parents:
16658
diff
changeset
|
266 |
raise util.Abort(_('cannot change null revision phase')) |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
267 |
currentroots = currentroots.copy() |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
268 |
currentroots.update(newroots) |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
269 |
ctxs = repo.set('roots(%ln::)', currentroots) |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
270 |
currentroots.intersection_update(ctx.node() for ctx in ctxs) |
22080
37f46575d9c2
phase: attach phase to the transaction instead of the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22079
diff
changeset
|
271 |
self._updateroots(targetphase, currentroots, tr) |
18105
312262ebc223
cache: group obscache and revsfiltercache invalidation in a single function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
18101
diff
changeset
|
272 |
repo.invalidatevolatilesets() |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
273 |
|
18220
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
274 |
def filterunknown(self, repo): |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
275 |
"""remove unknown nodes from the phase boundary |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
276 |
|
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
277 |
Nothing is lost as unknown nodes only hold data for their descendants. |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
278 |
""" |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
279 |
filtered = False |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
280 |
nodemap = repo.changelog.nodemap # to filter unknown nodes |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
281 |
for phase, nodes in enumerate(self.phaseroots): |
20550
1716a2671ec7
phases: make order of debug output 'removing unknown node' deterministic
Mads Kiilerich <madski@unity3d.com>
parents:
19984
diff
changeset
|
282 |
missing = sorted(node for node in nodes if node not in nodemap) |
18220
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
283 |
if missing: |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
284 |
for mnode in missing: |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
285 |
repo.ui.debug( |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
286 |
'removing unknown node %s from %i-phase boundary\n' |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
287 |
% (short(mnode), phase)) |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
288 |
nodes.symmetric_difference_update(missing) |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
289 |
filtered = True |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
290 |
if filtered: |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
291 |
self.dirty = True |
18983
31bcc5112191
destroyed: invalidate phraserevs cache in all case (issue3858)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18220
diff
changeset
|
292 |
# filterunknown is called by repo.destroyed, we may have no changes in |
19951
d51c4d85ec23
spelling: random spell checker fixes
Mads Kiilerich <madski@unity3d.com>
parents:
18983
diff
changeset
|
293 |
# root but phaserevs contents is certainly invalid (or at least we |
d51c4d85ec23
spelling: random spell checker fixes
Mads Kiilerich <madski@unity3d.com>
parents:
18983
diff
changeset
|
294 |
# have not proper way to check that). related to issue 3858. |
18983
31bcc5112191
destroyed: invalidate phraserevs cache in all case (issue3858)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18220
diff
changeset
|
295 |
# |
31bcc5112191
destroyed: invalidate phraserevs cache in all case (issue3858)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18220
diff
changeset
|
296 |
# The other caller is __init__ that have no _phaserevs initialized |
31bcc5112191
destroyed: invalidate phraserevs cache in all case (issue3858)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18220
diff
changeset
|
297 |
# anyway. If this change we should consider adding a dedicated |
19951
d51c4d85ec23
spelling: random spell checker fixes
Mads Kiilerich <madski@unity3d.com>
parents:
18983
diff
changeset
|
298 |
# "destroyed" function to phasecache or a proper cache key mechanism |
18983
31bcc5112191
destroyed: invalidate phraserevs cache in all case (issue3858)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18220
diff
changeset
|
299 |
# (see branchmap one) |
22893
9672f0b2cdd9
phases: add invalidate function
Durham Goode <durham@fb.com>
parents:
22080
diff
changeset
|
300 |
self.invalidate() |
18220
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
301 |
|
22069
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22052
diff
changeset
|
302 |
def advanceboundary(repo, tr, 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
|
303 |
"""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
|
304 |
|
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
305 |
This function move boundary *forward* this means that all nodes |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
306 |
are set 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
|
307 |
|
15482
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
308 |
Simplify boundary to contains phase roots only.""" |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
309 |
phcache = repo._phasecache.copy() |
22069
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22052
diff
changeset
|
310 |
phcache.advanceboundary(repo, tr, targetphase, nodes) |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
311 |
repo._phasecache.replace(phcache) |
15482
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
312 |
|
22070
c1ca47204590
phase: add a transaction argument to retractboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22069
diff
changeset
|
313 |
def retractboundary(repo, tr, targetphase, nodes): |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
314 |
"""Set nodes back to a phase changing other nodes phases if |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
315 |
necessary. |
15482
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
316 |
|
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
317 |
This function move boundary *backward* this means that all nodes |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
318 |
are set in the target phase or kept in a *higher* phase. |
15482
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
319 |
|
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
320 |
Simplify boundary to contains phase roots only.""" |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
321 |
phcache = repo._phasecache.copy() |
22070
c1ca47204590
phase: add a transaction argument to retractboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22069
diff
changeset
|
322 |
phcache.retractboundary(repo, tr, targetphase, nodes) |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
323 |
repo._phasecache.replace(phcache) |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
324 |
|
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
325 |
def listphases(repo): |
16724
00535da82faf
phases: fix typos in docstrings
Martin Geisler <martin@geisler.net>
parents:
16659
diff
changeset
|
326 |
"""List phases root for serialization over pushkey""" |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
327 |
keys = {} |
15892
592b3d1742a1
phases: simplify phase exchange and movement over pushkey
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15821
diff
changeset
|
328 |
value = '%i' % draft |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
329 |
for root in repo._phasecache.phaseroots[draft]: |
15892
592b3d1742a1
phases: simplify phase exchange and movement over pushkey
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15821
diff
changeset
|
330 |
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
|
331 |
|
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
332 |
if repo.ui.configbool('phases', 'publish', True): |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
333 |
# Add an extra data to let remote know we are a publishing |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
334 |
# repo. Publishing repo can't just pretend they are old repo. |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
335 |
# When pushing to a publishing repo, the client still need to |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
336 |
# push phase boundary |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
337 |
# |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
338 |
# Push do not only push changeset. It also push phase data. |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
339 |
# New phase data may apply to common changeset which won't be |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
340 |
# push (as they are common). Here is a very simple example: |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
341 |
# |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
342 |
# 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
|
343 |
# 2) repo B make changeset X public |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
344 |
# 3) repo B push to repo A. X is not pushed but the data that |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
345 |
# X as now public should |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
346 |
# |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
347 |
# The server can't handle it on it's own as it has no idea of |
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
348 |
# client phase data. |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
349 |
keys['publishing'] = 'True' |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
350 |
return keys |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
351 |
|
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
352 |
def pushphase(repo, nhex, oldphasestr, newphasestr): |
17535 | 353 |
"""List phases root for serialization over pushkey""" |
18002
9bc5873e52af
clfilter: phases logic should be unfiltered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17979
diff
changeset
|
354 |
repo = repo.unfiltered() |
22052
793f9276aeb9
pushkey: wrap pushkey phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20550
diff
changeset
|
355 |
tr = None |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
356 |
lock = repo.lock() |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
357 |
try: |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
358 |
currentphase = repo[nhex].phase() |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
359 |
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
|
360 |
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
|
361 |
if currentphase == oldphase and newphase < oldphase: |
22052
793f9276aeb9
pushkey: wrap pushkey phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20550
diff
changeset
|
362 |
tr = repo.transaction('pushkey-phase') |
22069
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22052
diff
changeset
|
363 |
advanceboundary(repo, tr, newphase, [bin(nhex)]) |
22052
793f9276aeb9
pushkey: wrap pushkey phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20550
diff
changeset
|
364 |
tr.close() |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
365 |
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
|
366 |
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
|
367 |
# 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
|
368 |
return 1 |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
369 |
else: |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
370 |
return 0 |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
371 |
finally: |
22052
793f9276aeb9
pushkey: wrap pushkey phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20550
diff
changeset
|
372 |
if tr: |
793f9276aeb9
pushkey: wrap pushkey phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20550
diff
changeset
|
373 |
tr.release() |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
374 |
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
|
375 |
|
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
376 |
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
|
377 |
"""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
|
378 |
|
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
379 |
* 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
|
380 |
* 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
|
381 |
|
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
382 |
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
|
383 |
""" |
18002
9bc5873e52af
clfilter: phases logic should be unfiltered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17979
diff
changeset
|
384 |
repo = repo.unfiltered() |
15649
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
385 |
# 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
|
386 |
draftroots = [] |
15902
4252d9f08d7e
phases: use nodemap to check for missing nodes
Sune Foldager <cryo@cyanite.org>
parents:
15892
diff
changeset
|
387 |
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
|
388 |
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
|
389 |
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
|
390 |
continue |
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
391 |
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
|
392 |
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
|
393 |
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
|
394 |
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
|
395 |
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
|
396 |
' 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
|
397 |
elif phase == 1: |
15902
4252d9f08d7e
phases: use nodemap to check for missing nodes
Sune Foldager <cryo@cyanite.org>
parents:
15892
diff
changeset
|
398 |
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
|
399 |
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
|
400 |
else: |
15953
52dc2b33d0be
phase: fix warning text from invalid remote phase
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15948
diff
changeset
|
401 |
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
|
402 |
% (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
|
403 |
# compute heads |
15954
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
404 |
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
|
405 |
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
|
406 |
|
15954
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
407 |
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
|
408 |
"""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
|
409 |
|
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
410 |
* `heads`: define the first subset |
17425
e95ec38f86b0
fix wording and not-completely-trivial spelling errors and bad docstrings
Mads Kiilerich <mads@kiilerich.com>
parents:
17424
diff
changeset
|
411 |
* `roots`: define the second we subtract from the first""" |
18002
9bc5873e52af
clfilter: phases logic should be unfiltered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17979
diff
changeset
|
412 |
repo = repo.unfiltered() |
15954
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
413 |
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
|
414 |
heads, roots, roots, heads) |
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
415 |
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
|
416 |
|
16030
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
417 |
|
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
418 |
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
|
419 |
"""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
|
420 |
|
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
421 |
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
|
422 |
|
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
423 |
""" |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
424 |
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
|
425 |
try: |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
426 |
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
|
427 |
except ValueError: |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
428 |
try: |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
429 |
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
|
430 |
except ValueError: |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
431 |
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
|
432 |
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
|
433 |
|
17671
fdd0fc046cf1
clfilter: introduce a `hassecret` function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17537
diff
changeset
|
434 |
def hassecret(repo): |
fdd0fc046cf1
clfilter: introduce a `hassecret` function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17537
diff
changeset
|
435 |
"""utility function that check if a repo have any secret changeset.""" |
fdd0fc046cf1
clfilter: introduce a `hassecret` function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17537
diff
changeset
|
436 |
return bool(repo._phasecache.phaseroots[2]) |