Mercurial > hg
annotate mercurial/phases.py @ 23438:6e0ecb9a2e19
bundle2.processbundle: let callers request default behavior
This patch series is intended to allow bundle2 push reply part handlers to
make changes to the local repository; it has been developed in parallel with
an extension that allows the server to rebase incoming changesets while applying
them.
The default transaction getter for processbundle is a private function that
raises an exception; this diff lets calling code pass None as the transaction
getter to explicitly request this default behavior.
The next diff will check a config option to determine whether to provide a
transaction to the reply bundle processor. If one shouldn't be provided, the
code needs a way to specify that the default behavior should be used.
author | Eric Sumner <ericsumner@fb.com> |
---|---|
date | Mon, 24 Nov 2014 16:04:44 -0800 |
parents | 936b0ff34346 |
children | b8260abfeb7d |
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 |
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 |
23361
936b0ff34346
phases: read pending data when appropriate
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22940
diff
changeset
|
103 import os |
15419
ccb7de21625a
phases: handle errors other than ENOENT appropriately
Matt Mackall <mpm@selenic.com>
parents:
15418
diff
changeset
|
104 import errno |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
105 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
|
106 from i18n import _ |
17979
b3ec0b5fd777
phases: fix missing "error" module import (issue3707)
André Sintzoff <andre.sintzoff@gmail.com>
parents:
17671
diff
changeset
|
107 import util, error |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
108 |
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
|
109 allphases = public, draft, secret = range(3) |
15417
5261140d9322
phases: Minimal first add.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
diff
changeset
|
110 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
|
111 phasenames = ['public', 'draft', 'secret'] |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
112 |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
113 def _readroots(repo, phasedefaults=None): |
16625
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
114 """Read phase roots from disk |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
115 |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
116 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
|
117 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
|
118 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
|
119 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
|
120 |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
121 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
|
122 what is being stored. |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
123 """ |
18002
9bc5873e52af
clfilter: phases logic should be unfiltered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17979
diff
changeset
|
124 repo = repo.unfiltered() |
16625
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
125 dirty = False |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
126 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
|
127 try: |
23361
936b0ff34346
phases: read pending data when appropriate
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22940
diff
changeset
|
128 f = None |
936b0ff34346
phases: read pending data when appropriate
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22940
diff
changeset
|
129 if 'HG_PENDING' in os.environ: |
936b0ff34346
phases: read pending data when appropriate
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22940
diff
changeset
|
130 try: |
936b0ff34346
phases: read pending data when appropriate
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22940
diff
changeset
|
131 f = repo.svfs('phaseroots.pending') |
936b0ff34346
phases: read pending data when appropriate
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22940
diff
changeset
|
132 except IOError, inst: |
936b0ff34346
phases: read pending data when appropriate
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22940
diff
changeset
|
133 if inst.errno != errno.ENOENT: |
936b0ff34346
phases: read pending data when appropriate
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22940
diff
changeset
|
134 raise |
936b0ff34346
phases: read pending data when appropriate
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22940
diff
changeset
|
135 if f is None: |
936b0ff34346
phases: read pending data when appropriate
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22940
diff
changeset
|
136 f = repo.sopener('phaseroots') |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
137 try: |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
138 for line in f: |
16588
72319bfd7966
phases: line.strip().split() == line.split()
Martin Geisler <mg@aragost.com>
parents:
16535
diff
changeset
|
139 phase, nh = line.split() |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
140 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
|
141 finally: |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
142 f.close() |
15419
ccb7de21625a
phases: handle errors other than ENOENT appropriately
Matt Mackall <mpm@selenic.com>
parents:
15418
diff
changeset
|
143 except IOError, inst: |
ccb7de21625a
phases: handle errors other than ENOENT appropriately
Matt Mackall <mpm@selenic.com>
parents:
15418
diff
changeset
|
144 if inst.errno != errno.ENOENT: |
ccb7de21625a
phases: handle errors other than ENOENT appropriately
Matt Mackall <mpm@selenic.com>
parents:
15418
diff
changeset
|
145 raise |
16625
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
146 if phasedefaults: |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
147 for f in phasedefaults: |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
148 roots = f(repo, roots) |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
149 dirty = True |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
150 return roots, dirty |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
151 |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
152 class phasecache(object): |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
153 def __init__(self, repo, phasedefaults, _load=True): |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
154 if _load: |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
155 # Cheap trick to allow shallow-copy without copy module |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
156 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
|
157 self._phaserevs = None |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
158 self.filterunknown(repo) |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
159 self.opener = repo.sopener |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
160 |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
161 def copy(self): |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
162 # Shallow copy meant to ensure isolation in |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
163 # advance/retractboundary(), nothing more. |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
164 ph = phasecache(None, None, _load=False) |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
165 ph.phaseroots = self.phaseroots[:] |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
166 ph.dirty = self.dirty |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
167 ph.opener = self.opener |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
168 ph._phaserevs = self._phaserevs |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
169 return ph |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
170 |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
171 def replace(self, phcache): |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
172 for a in 'phaseroots dirty opener _phaserevs'.split(): |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
173 setattr(self, a, getattr(phcache, a)) |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
174 |
22893
9672f0b2cdd9
phases: add invalidate function
Durham Goode <durham@fb.com>
parents:
22080
diff
changeset
|
175 def getphaserevs(self, repo): |
9672f0b2cdd9
phases: add invalidate function
Durham Goode <durham@fb.com>
parents:
22080
diff
changeset
|
176 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
|
177 repo = repo.unfiltered() |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
178 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
|
179 self._phaserevs = revs |
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
180 self._populatephaseroots(repo) |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
181 for phase in trackedphases: |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
182 roots = map(repo.changelog.rev, self.phaseroots[phase]) |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
183 if roots: |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
184 for rev in roots: |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
185 revs[rev] = phase |
16867
1093ad1e8903
revlog: descendants(*revs) becomes descendants(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents:
16725
diff
changeset
|
186 for rev in repo.changelog.descendants(roots): |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
187 revs[rev] = phase |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
188 return self._phaserevs |
22894
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
189 |
22893
9672f0b2cdd9
phases: add invalidate function
Durham Goode <durham@fb.com>
parents:
22080
diff
changeset
|
190 def invalidate(self): |
9672f0b2cdd9
phases: add invalidate function
Durham Goode <durham@fb.com>
parents:
22080
diff
changeset
|
191 self._phaserevs = None |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
192 |
22894
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
193 def _populatephaseroots(self, repo): |
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
194 """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
|
195 """ |
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
196 cl = repo.changelog |
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
197 phaserevs = self._phaserevs |
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
198 for phase in trackedphases: |
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
199 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
|
200 for root in roots: |
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
201 phaserevs[root] = phase |
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
202 |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
203 def phase(self, repo, rev): |
17424
e7cfe3587ea4
fix trivial spelling errors
Mads Kiilerich <mads@kiilerich.com>
parents:
17205
diff
changeset
|
204 # 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
|
205 # if necessary. The repository instance is not stored in |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
206 # phasecache to avoid reference cycles. The changelog instance |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
207 # is not stored because it is a filecache() property and can |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
208 # be replaced without us being notified. |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
209 if rev == nullrev: |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
210 return public |
19984
7d5e7799a29f
rebase: fix rebase aborts when 'tip-1' is public (issue4082)
Durham Goode <durham@fb.com>
parents:
19951
diff
changeset
|
211 if rev < nullrev: |
7d5e7799a29f
rebase: fix rebase aborts when 'tip-1' is public (issue4082)
Durham Goode <durham@fb.com>
parents:
19951
diff
changeset
|
212 raise ValueError(_('cannot lookup negative revision')) |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
213 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
|
214 self.invalidate() |
9672f0b2cdd9
phases: add invalidate function
Durham Goode <durham@fb.com>
parents:
22080
diff
changeset
|
215 self._phaserevs = self.getphaserevs(repo) |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
216 return self._phaserevs[rev] |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
217 |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
218 def write(self): |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
219 if not self.dirty: |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
220 return |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
221 f = self.opener('phaseroots', 'w', atomictemp=True) |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
222 try: |
22079
5dcc58649b1a
phase: extract the phaseroots serialization in a dedicated method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22070
diff
changeset
|
223 self._write(f) |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
224 finally: |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
225 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
|
226 |
5dcc58649b1a
phase: extract the phaseroots serialization in a dedicated method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22070
diff
changeset
|
227 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
|
228 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
|
229 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
|
230 fp.write('%i %s\n' % (phase, hex(h))) |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
231 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
|
232 |
22080
37f46575d9c2
phase: attach phase to the transaction instead of the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22079
diff
changeset
|
233 def _updateroots(self, phase, newroots, tr): |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
234 self.phaseroots[phase] = newroots |
22893
9672f0b2cdd9
phases: add invalidate function
Durham Goode <durham@fb.com>
parents:
22080
diff
changeset
|
235 self.invalidate() |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
236 self.dirty = True |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
237 |
22080
37f46575d9c2
phase: attach phase to the transaction instead of the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22079
diff
changeset
|
238 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
|
239 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
|
240 |
22069
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22052
diff
changeset
|
241 def advanceboundary(self, repo, tr, targetphase, nodes): |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
242 # 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
|
243 # phaseroots values, replace them. |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
244 |
18002
9bc5873e52af
clfilter: phases logic should be unfiltered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17979
diff
changeset
|
245 repo = repo.unfiltered() |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
246 delroots = [] # set of root deleted by this path |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
247 for phase in xrange(targetphase + 1, len(allphases)): |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
248 # 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
|
249 nodes = [n for n in nodes |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
250 if self.phase(repo, repo[n].rev()) >= phase] |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
251 if not nodes: |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
252 break # no roots to move anymore |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
253 olds = self.phaseroots[phase] |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
254 roots = set(ctx.node() for ctx in repo.set( |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
255 'roots((%ln::) - (%ln::%ln))', olds, olds, nodes)) |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
256 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
|
257 self._updateroots(phase, roots, tr) |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
258 # 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
|
259 delroots.extend(olds - roots) |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
260 # declare deleted root in the target phase |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
261 if targetphase != 0: |
22070
c1ca47204590
phase: add a transaction argument to retractboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22069
diff
changeset
|
262 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
|
263 repo.invalidatevolatilesets() |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
264 |
22070
c1ca47204590
phase: add a transaction argument to retractboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22069
diff
changeset
|
265 def retractboundary(self, repo, tr, targetphase, nodes): |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
266 # 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
|
267 # phaseroots values, replace them. |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
268 |
18002
9bc5873e52af
clfilter: phases logic should be unfiltered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17979
diff
changeset
|
269 repo = repo.unfiltered() |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
270 currentroots = self.phaseroots[targetphase] |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
271 newroots = [n for n in nodes |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
272 if self.phase(repo, repo[n].rev()) < targetphase] |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
273 if newroots: |
16659
58edd786e96f
phase: make if abort on nullid for the good reason
Patrick Mezard <patrick@mezard.eu>
parents:
16658
diff
changeset
|
274 if nullid in newroots: |
58edd786e96f
phase: make if abort on nullid for the good reason
Patrick Mezard <patrick@mezard.eu>
parents:
16658
diff
changeset
|
275 raise util.Abort(_('cannot change null revision phase')) |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
276 currentroots = currentroots.copy() |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
277 currentroots.update(newroots) |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
278 ctxs = repo.set('roots(%ln::)', currentroots) |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
279 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
|
280 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
|
281 repo.invalidatevolatilesets() |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
282 |
18220
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
283 def filterunknown(self, repo): |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
284 """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
|
285 |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
286 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
|
287 """ |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
288 filtered = False |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
289 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
|
290 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
|
291 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
|
292 if missing: |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
293 for mnode in missing: |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
294 repo.ui.debug( |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
295 '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
|
296 % (short(mnode), phase)) |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
297 nodes.symmetric_difference_update(missing) |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
298 filtered = True |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
299 if filtered: |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
300 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
|
301 # 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
|
302 # 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
|
303 # 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
|
304 # |
31bcc5112191
destroyed: invalidate phraserevs cache in all case (issue3858)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18220
diff
changeset
|
305 # 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
|
306 # 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
|
307 # "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
|
308 # (see branchmap one) |
22893
9672f0b2cdd9
phases: add invalidate function
Durham Goode <durham@fb.com>
parents:
22080
diff
changeset
|
309 self.invalidate() |
18220
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
310 |
22069
616a455b02ca
phase: add a transaction argument to advanceboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22052
diff
changeset
|
311 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
|
312 """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
|
313 |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
314 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
|
315 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
|
316 |
15482
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
317 Simplify boundary to contains phase roots only.""" |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
318 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
|
319 phcache.advanceboundary(repo, tr, targetphase, nodes) |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
320 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
|
321 |
22070
c1ca47204590
phase: add a transaction argument to retractboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22069
diff
changeset
|
322 def retractboundary(repo, tr, targetphase, nodes): |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
323 """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
|
324 necessary. |
15482
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
325 |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
326 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
|
327 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
|
328 |
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
329 Simplify boundary to contains phase roots only.""" |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
330 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
|
331 phcache.retractboundary(repo, tr, targetphase, nodes) |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
332 repo._phasecache.replace(phcache) |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
333 |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
334 def listphases(repo): |
16724
00535da82faf
phases: fix typos in docstrings
Martin Geisler <martin@geisler.net>
parents:
16659
diff
changeset
|
335 """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
|
336 keys = {} |
15892
592b3d1742a1
phases: simplify phase exchange and movement over pushkey
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15821
diff
changeset
|
337 value = '%i' % draft |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
338 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
|
339 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
|
340 |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
341 if repo.ui.configbool('phases', 'publish', True): |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
342 # 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
|
343 # 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
|
344 # 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
|
345 # push phase boundary |
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 # 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
|
348 # 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
|
349 # 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
|
350 # |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
351 # 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
|
352 # 2) repo B make changeset X public |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
353 # 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
|
354 # X as now public should |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
355 # |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
356 # 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
|
357 # client phase data. |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
358 keys['publishing'] = 'True' |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
359 return keys |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
360 |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
361 def pushphase(repo, nhex, oldphasestr, newphasestr): |
17535 | 362 """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
|
363 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
|
364 tr = None |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
365 lock = repo.lock() |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
366 try: |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
367 currentphase = repo[nhex].phase() |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
368 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
|
369 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
|
370 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
|
371 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
|
372 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
|
373 tr.close() |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
374 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
|
375 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
|
376 # 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
|
377 return 1 |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
378 else: |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
379 return 0 |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
380 finally: |
22052
793f9276aeb9
pushkey: wrap pushkey phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20550
diff
changeset
|
381 if tr: |
793f9276aeb9
pushkey: wrap pushkey phase movement in a transaction
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
20550
diff
changeset
|
382 tr.release() |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
383 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
|
384 |
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
385 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
|
386 """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
|
387 |
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
388 * 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
|
389 * 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
|
390 |
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
391 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
|
392 """ |
18002
9bc5873e52af
clfilter: phases logic should be unfiltered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17979
diff
changeset
|
393 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
|
394 # 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
|
395 draftroots = [] |
15902
4252d9f08d7e
phases: use nodemap to check for missing nodes
Sune Foldager <cryo@cyanite.org>
parents:
15892
diff
changeset
|
396 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
|
397 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
|
398 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
|
399 continue |
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
400 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
|
401 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
|
402 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
|
403 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
|
404 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
|
405 ' 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
|
406 elif phase == 1: |
15902
4252d9f08d7e
phases: use nodemap to check for missing nodes
Sune Foldager <cryo@cyanite.org>
parents:
15892
diff
changeset
|
407 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
|
408 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
|
409 else: |
15953
52dc2b33d0be
phase: fix warning text from invalid remote phase
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15948
diff
changeset
|
410 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
|
411 % (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
|
412 # compute heads |
15954
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
413 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
|
414 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
|
415 |
15954
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
416 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
|
417 """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
|
418 |
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
419 * `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
|
420 * `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
|
421 repo = repo.unfiltered() |
15954
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
422 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
|
423 heads, roots, roots, heads) |
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
424 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
|
425 |
16030
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
426 |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
427 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
|
428 """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
|
429 |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
430 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
|
431 |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
432 """ |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
433 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
|
434 try: |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
435 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
|
436 except ValueError: |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
437 try: |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
438 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
|
439 except ValueError: |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
440 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
|
441 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
|
442 |
17671
fdd0fc046cf1
clfilter: introduce a `hassecret` function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17537
diff
changeset
|
443 def hassecret(repo): |
fdd0fc046cf1
clfilter: introduce a `hassecret` function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17537
diff
changeset
|
444 """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
|
445 return bool(repo._phasecache.phaseroots[2]) |