Mercurial > hg
annotate mercurial/phases.py @ 46466:3e3b81b6e7da
debugcommands: s/stdin/stdout in debugnodemap help
Differential Revision: https://phab.mercurial-scm.org/D9930
author | Pulkit Goyal <7895pulkit@gmail.com> |
---|---|
date | Mon, 25 Jan 2021 14:23:47 +0530 |
parents | 5d65e04b6a80 |
children | 77e129be10de |
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 |
25966
f14cea32e1d4
phases: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25660
diff
changeset
|
103 from __future__ import absolute_import |
f14cea32e1d4
phases: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25660
diff
changeset
|
104 |
15419
ccb7de21625a
phases: handle errors other than ENOENT appropriately
Matt Mackall <mpm@selenic.com>
parents:
15418
diff
changeset
|
105 import errno |
34319
5779d096a696
phases: move binary encoding into a reusable function
Boris Feld <boris.feld@octobus.net>
parents:
33460
diff
changeset
|
106 import struct |
25966
f14cea32e1d4
phases: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25660
diff
changeset
|
107 |
f14cea32e1d4
phases: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25660
diff
changeset
|
108 from .i18n import _ |
f14cea32e1d4
phases: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25660
diff
changeset
|
109 from .node import ( |
f14cea32e1d4
phases: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25660
diff
changeset
|
110 bin, |
f14cea32e1d4
phases: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25660
diff
changeset
|
111 hex, |
f14cea32e1d4
phases: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25660
diff
changeset
|
112 nullid, |
f14cea32e1d4
phases: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25660
diff
changeset
|
113 nullrev, |
f14cea32e1d4
phases: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25660
diff
changeset
|
114 short, |
44004
9c1fd975e9ac
phases: make the working directory consistently a draft
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
43730
diff
changeset
|
115 wdirrev, |
25966
f14cea32e1d4
phases: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25660
diff
changeset
|
116 ) |
43089
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43087
diff
changeset
|
117 from .pycompat import ( |
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43087
diff
changeset
|
118 getattr, |
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43087
diff
changeset
|
119 setattr, |
c59eb1560c44
py3: manually import getattr where it is needed
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43087
diff
changeset
|
120 ) |
25966
f14cea32e1d4
phases: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25660
diff
changeset
|
121 from . import ( |
f14cea32e1d4
phases: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25660
diff
changeset
|
122 error, |
35309
d13526333835
phases: drop the list with phase of each rev, always comput phase sets
Joerg Sonnenberger <joerg@bec.de>
parents:
34876
diff
changeset
|
123 pycompat, |
45372
77b8588dd84e
requirements: introduce new requirements related module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45356
diff
changeset
|
124 requirements, |
31016
bf81d3b7b2ba
phases: add a getrevset method to phasecache
Jun Wu <quark@fb.com>
parents:
30634
diff
changeset
|
125 smartset, |
31053
6afd8a87a657
phases: check HG_PENDING strictly
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents:
31016
diff
changeset
|
126 txnutil, |
32000
511a62669f1b
phases: emit phases to pushkey protocol in deterministic order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31342
diff
changeset
|
127 util, |
25966
f14cea32e1d4
phases: use absolute_import
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25660
diff
changeset
|
128 ) |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
129 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
130 _fphasesentry = struct.Struct(b'>i20s') |
34319
5779d096a696
phases: move binary encoding into a reusable function
Boris Feld <boris.feld@octobus.net>
parents:
33460
diff
changeset
|
131 |
39297
06c976acc581
phases: add an internal phases
Boris Feld <boris.feld@octobus.net>
parents:
39293
diff
changeset
|
132 # record phase index |
06c976acc581
phases: add an internal phases
Boris Feld <boris.feld@octobus.net>
parents:
39293
diff
changeset
|
133 public, draft, secret = range(3) |
45117
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
134 archived = 32 # non-continuous for compatibility |
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
135 internal = 96 # non-continuous for compatibility |
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
136 allphases = (public, draft, secret, archived, internal) |
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
137 trackedphases = (draft, secret, archived, internal) |
39297
06c976acc581
phases: add an internal phases
Boris Feld <boris.feld@octobus.net>
parents:
39293
diff
changeset
|
138 # record phase names |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
139 cmdphasenames = [b'public', b'draft', b'secret'] # known to `hg phase` command |
45117
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
140 phasenames = dict(enumerate(cmdphasenames)) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
141 phasenames[archived] = b'archived' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
142 phasenames[internal] = b'internal' |
45117
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
143 # map phase name to phase number |
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
144 phasenumber = {name: phase for phase, name in phasenames.items()} |
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
145 # like phasenumber, but also include maps for the numeric and binary |
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
146 # phase number to the phase number |
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
147 phasenumber2 = phasenumber.copy() |
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
148 phasenumber2.update({phase: phase for phase in phasenames}) |
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
149 phasenumber2.update({b'%i' % phase: phase for phase in phasenames}) |
39297
06c976acc581
phases: add an internal phases
Boris Feld <boris.feld@octobus.net>
parents:
39293
diff
changeset
|
150 # record phase property |
45117
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
151 mutablephases = (draft, secret, archived, internal) |
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
152 remotehiddenphases = (secret, archived, internal) |
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
153 localhiddenphases = (internal, archived) |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
154 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
155 |
39299
7775c1fb8fa0
phases: enforce internal phase support
Boris Feld <boris.feld@octobus.net>
parents:
39297
diff
changeset
|
156 def supportinternal(repo): |
7775c1fb8fa0
phases: enforce internal phase support
Boris Feld <boris.feld@octobus.net>
parents:
39297
diff
changeset
|
157 """True if the internal phase can be used on a repository""" |
45372
77b8588dd84e
requirements: introduce new requirements related module
Pulkit Goyal <7895pulkit@gmail.com>
parents:
45356
diff
changeset
|
158 return requirements.INTERNAL_PHASE_REQUIREMENT in repo.requirements |
39299
7775c1fb8fa0
phases: enforce internal phase support
Boris Feld <boris.feld@octobus.net>
parents:
39297
diff
changeset
|
159 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
160 |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
161 def _readroots(repo, phasedefaults=None): |
16625
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
162 """Read phase roots from disk |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
163 |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
164 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
|
165 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
|
166 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
|
167 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
|
168 |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
169 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
|
170 what is being stored. |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
171 """ |
18002
9bc5873e52af
clfilter: phases logic should be unfiltered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17979
diff
changeset
|
172 repo = repo.unfiltered() |
16625
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
173 dirty = False |
45131
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
174 roots = {i: set() for i in allphases} |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
175 try: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
176 f, pending = txnutil.trypending(repo.root, repo.svfs, b'phaseroots') |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
177 try: |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
178 for line in f: |
16588
72319bfd7966
phases: line.strip().split() == line.split()
Martin Geisler <mg@aragost.com>
parents:
16535
diff
changeset
|
179 phase, nh = line.split() |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
180 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
|
181 finally: |
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
182 f.close() |
25660
328739ea70c3
global: mass rewrite to use modern exception syntax
Gregory Szorc <gregory.szorc@gmail.com>
parents:
25624
diff
changeset
|
183 except IOError as inst: |
15419
ccb7de21625a
phases: handle errors other than ENOENT appropriately
Matt Mackall <mpm@selenic.com>
parents:
15418
diff
changeset
|
184 if inst.errno != errno.ENOENT: |
ccb7de21625a
phases: handle errors other than ENOENT appropriately
Matt Mackall <mpm@selenic.com>
parents:
15418
diff
changeset
|
185 raise |
16625
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
186 if phasedefaults: |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
187 for f in phasedefaults: |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
188 roots = f(repo, roots) |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
189 dirty = True |
df9df747070d
phases: stop modifying localrepo in readroots()
Patrick Mezard <patrick@mezard.eu>
parents:
16624
diff
changeset
|
190 return roots, dirty |
15418
cf729af26963
phases: basic I/O logic
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15417
diff
changeset
|
191 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
192 |
34319
5779d096a696
phases: move binary encoding into a reusable function
Boris Feld <boris.feld@octobus.net>
parents:
33460
diff
changeset
|
193 def binaryencode(phasemapping): |
5779d096a696
phases: move binary encoding into a reusable function
Boris Feld <boris.feld@octobus.net>
parents:
33460
diff
changeset
|
194 """encode a 'phase -> nodes' mapping into a binary stream |
5779d096a696
phases: move binary encoding into a reusable function
Boris Feld <boris.feld@octobus.net>
parents:
33460
diff
changeset
|
195 |
45117
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
196 The revision lists are encoded as (phase, root) pairs. |
34319
5779d096a696
phases: move binary encoding into a reusable function
Boris Feld <boris.feld@octobus.net>
parents:
33460
diff
changeset
|
197 """ |
5779d096a696
phases: move binary encoding into a reusable function
Boris Feld <boris.feld@octobus.net>
parents:
33460
diff
changeset
|
198 binarydata = [] |
45117
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
199 for phase, nodes in pycompat.iteritems(phasemapping): |
34319
5779d096a696
phases: move binary encoding into a reusable function
Boris Feld <boris.feld@octobus.net>
parents:
33460
diff
changeset
|
200 for head in nodes: |
5779d096a696
phases: move binary encoding into a reusable function
Boris Feld <boris.feld@octobus.net>
parents:
33460
diff
changeset
|
201 binarydata.append(_fphasesentry.pack(phase, head)) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
202 return b''.join(binarydata) |
34319
5779d096a696
phases: move binary encoding into a reusable function
Boris Feld <boris.feld@octobus.net>
parents:
33460
diff
changeset
|
203 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
204 |
34320
12c42bcd4133
phases: move the binary decoding function in the phases module
Boris Feld <boris.feld@octobus.net>
parents:
34319
diff
changeset
|
205 def binarydecode(stream): |
12c42bcd4133
phases: move the binary decoding function in the phases module
Boris Feld <boris.feld@octobus.net>
parents:
34319
diff
changeset
|
206 """decode a binary stream into a 'phase -> nodes' mapping |
12c42bcd4133
phases: move the binary decoding function in the phases module
Boris Feld <boris.feld@octobus.net>
parents:
34319
diff
changeset
|
207 |
45117
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
208 The (phase, root) pairs are turned back into a dictionary with |
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
209 the phase as index and the aggregated roots of that phase as value.""" |
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
210 headsbyphase = {i: [] for i in allphases} |
34320
12c42bcd4133
phases: move the binary decoding function in the phases module
Boris Feld <boris.feld@octobus.net>
parents:
34319
diff
changeset
|
211 entrysize = _fphasesentry.size |
12c42bcd4133
phases: move the binary decoding function in the phases module
Boris Feld <boris.feld@octobus.net>
parents:
34319
diff
changeset
|
212 while True: |
12c42bcd4133
phases: move the binary decoding function in the phases module
Boris Feld <boris.feld@octobus.net>
parents:
34319
diff
changeset
|
213 entry = stream.read(entrysize) |
12c42bcd4133
phases: move the binary decoding function in the phases module
Boris Feld <boris.feld@octobus.net>
parents:
34319
diff
changeset
|
214 if len(entry) < entrysize: |
12c42bcd4133
phases: move the binary decoding function in the phases module
Boris Feld <boris.feld@octobus.net>
parents:
34319
diff
changeset
|
215 if entry: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
216 raise error.Abort(_(b'bad phase-heads stream')) |
34320
12c42bcd4133
phases: move the binary decoding function in the phases module
Boris Feld <boris.feld@octobus.net>
parents:
34319
diff
changeset
|
217 break |
12c42bcd4133
phases: move the binary decoding function in the phases module
Boris Feld <boris.feld@octobus.net>
parents:
34319
diff
changeset
|
218 phase, node = _fphasesentry.unpack(entry) |
12c42bcd4133
phases: move the binary decoding function in the phases module
Boris Feld <boris.feld@octobus.net>
parents:
34319
diff
changeset
|
219 headsbyphase[phase].append(node) |
12c42bcd4133
phases: move the binary decoding function in the phases module
Boris Feld <boris.feld@octobus.net>
parents:
34319
diff
changeset
|
220 return headsbyphase |
12c42bcd4133
phases: move the binary decoding function in the phases module
Boris Feld <boris.feld@octobus.net>
parents:
34319
diff
changeset
|
221 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
222 |
44548
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
223 def _sortedrange_insert(data, idx, rev, t): |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
224 merge_before = False |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
225 if idx: |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
226 r1, t1 = data[idx - 1] |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
227 merge_before = r1[-1] + 1 == rev and t1 == t |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
228 merge_after = False |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
229 if idx < len(data): |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
230 r2, t2 = data[idx] |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
231 merge_after = r2[0] == rev + 1 and t2 == t |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
232 |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
233 if merge_before and merge_after: |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
234 data[idx - 1] = (pycompat.xrange(r1[0], r2[-1] + 1), t) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
235 data.pop(idx) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
236 elif merge_before: |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
237 data[idx - 1] = (pycompat.xrange(r1[0], rev + 1), t) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
238 elif merge_after: |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
239 data[idx] = (pycompat.xrange(rev, r2[-1] + 1), t) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
240 else: |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
241 data.insert(idx, (pycompat.xrange(rev, rev + 1), t)) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
242 |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
243 |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
244 def _sortedrange_split(data, idx, rev, t): |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
245 r1, t1 = data[idx] |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
246 if t == t1: |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
247 return |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
248 t = (t1[0], t[1]) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
249 if len(r1) == 1: |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
250 data.pop(idx) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
251 _sortedrange_insert(data, idx, rev, t) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
252 elif r1[0] == rev: |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
253 data[idx] = (pycompat.xrange(rev + 1, r1[-1] + 1), t1) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
254 _sortedrange_insert(data, idx, rev, t) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
255 elif r1[-1] == rev: |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
256 data[idx] = (pycompat.xrange(r1[0], rev), t1) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
257 _sortedrange_insert(data, idx + 1, rev, t) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
258 else: |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
259 data[idx : idx + 1] = [ |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
260 (pycompat.xrange(r1[0], rev), t1), |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
261 (pycompat.xrange(rev, rev + 1), t), |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
262 (pycompat.xrange(rev + 1, r1[-1] + 1), t1), |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
263 ] |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
264 |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
265 |
33451
e44d54260c32
phases: track phase movements in 'advanceboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33450
diff
changeset
|
266 def _trackphasechange(data, rev, old, new): |
44548
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
267 """add a phase move to the <data> list of ranges |
33451
e44d54260c32
phases: track phase movements in 'advanceboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33450
diff
changeset
|
268 |
e44d54260c32
phases: track phase movements in 'advanceboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33450
diff
changeset
|
269 If data is None, nothing happens. |
e44d54260c32
phases: track phase movements in 'advanceboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33450
diff
changeset
|
270 """ |
e44d54260c32
phases: track phase movements in 'advanceboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33450
diff
changeset
|
271 if data is None: |
e44d54260c32
phases: track phase movements in 'advanceboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33450
diff
changeset
|
272 return |
44548
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
273 |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
274 # If data is empty, create a one-revision range and done |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
275 if not data: |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
276 data.insert(0, (pycompat.xrange(rev, rev + 1), (old, new))) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
277 return |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
278 |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
279 low = 0 |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
280 high = len(data) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
281 t = (old, new) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
282 while low < high: |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
283 mid = (low + high) // 2 |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
284 revs = data[mid][0] |
45550
29a259be6424
phases: fix performance regression with Python 2
Joerg Sonnenberger <joerg@bec.de>
parents:
45372
diff
changeset
|
285 revs_low = revs[0] |
29a259be6424
phases: fix performance regression with Python 2
Joerg Sonnenberger <joerg@bec.de>
parents:
45372
diff
changeset
|
286 revs_high = revs[-1] |
44548
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
287 |
45550
29a259be6424
phases: fix performance regression with Python 2
Joerg Sonnenberger <joerg@bec.de>
parents:
45372
diff
changeset
|
288 if rev >= revs_low and rev <= revs_high: |
44548
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
289 _sortedrange_split(data, mid, rev, t) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
290 return |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
291 |
45550
29a259be6424
phases: fix performance regression with Python 2
Joerg Sonnenberger <joerg@bec.de>
parents:
45372
diff
changeset
|
292 if revs_low == rev + 1: |
44548
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
293 if mid and data[mid - 1][0][-1] == rev: |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
294 _sortedrange_split(data, mid - 1, rev, t) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
295 else: |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
296 _sortedrange_insert(data, mid, rev, t) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
297 return |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
298 |
45550
29a259be6424
phases: fix performance regression with Python 2
Joerg Sonnenberger <joerg@bec.de>
parents:
45372
diff
changeset
|
299 if revs_high == rev - 1: |
44548
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
300 if mid + 1 < len(data) and data[mid + 1][0][0] == rev: |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
301 _sortedrange_split(data, mid + 1, rev, t) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
302 else: |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
303 _sortedrange_insert(data, mid + 1, rev, t) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
304 return |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
305 |
45550
29a259be6424
phases: fix performance regression with Python 2
Joerg Sonnenberger <joerg@bec.de>
parents:
45372
diff
changeset
|
306 if revs_low > rev: |
44548
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
307 high = mid |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
308 else: |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
309 low = mid + 1 |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
310 |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
311 if low == len(data): |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
312 data.append((pycompat.xrange(rev, rev + 1), t)) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
313 return |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
314 |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
315 r1, t1 = data[low] |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
316 if r1[0] > rev: |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
317 data.insert(low, (pycompat.xrange(rev, rev + 1), t)) |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
318 else: |
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
319 data.insert(low + 1, (pycompat.xrange(rev, rev + 1), t)) |
33451
e44d54260c32
phases: track phase movements in 'advanceboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33450
diff
changeset
|
320 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
321 |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
322 class phasecache(object): |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
323 def __init__(self, repo, phasedefaults, _load=True): |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
324 if _load: |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
325 # Cheap trick to allow shallow-copy without copy module |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
326 self.phaseroots, self.dirty = _readroots(repo, phasedefaults) |
35442
56745e58df07
phases: initialize number of loaded revisions to 0
Yuya Nishihara <yuya@tcha.org>
parents:
35441
diff
changeset
|
327 self._loadedrevslen = 0 |
25190
22438cfd11b5
phases: add set per phase in C phase computation
Laurent Charignon <lcharignon@fb.com>
parents:
24599
diff
changeset
|
328 self._phasesets = None |
18220
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
329 self.filterunknown(repo) |
23878
37a92908a382
localrepo: remove all external users of localrepo.sopener
Angel Ezquerra <angel.ezquerra@gmail.com>
parents:
23631
diff
changeset
|
330 self.opener = repo.svfs |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
331 |
45114
e2d17974a869
phases: provide a test and accessor for non-public phase roots
Joerg Sonnenberger <joerg@bec.de>
parents:
45063
diff
changeset
|
332 def hasnonpublicphases(self, repo): |
e2d17974a869
phases: provide a test and accessor for non-public phase roots
Joerg Sonnenberger <joerg@bec.de>
parents:
45063
diff
changeset
|
333 """detect if there are revisions with non-public phase""" |
e2d17974a869
phases: provide a test and accessor for non-public phase roots
Joerg Sonnenberger <joerg@bec.de>
parents:
45063
diff
changeset
|
334 repo = repo.unfiltered() |
e2d17974a869
phases: provide a test and accessor for non-public phase roots
Joerg Sonnenberger <joerg@bec.de>
parents:
45063
diff
changeset
|
335 cl = repo.changelog |
e2d17974a869
phases: provide a test and accessor for non-public phase roots
Joerg Sonnenberger <joerg@bec.de>
parents:
45063
diff
changeset
|
336 if len(cl) >= self._loadedrevslen: |
e2d17974a869
phases: provide a test and accessor for non-public phase roots
Joerg Sonnenberger <joerg@bec.de>
parents:
45063
diff
changeset
|
337 self.invalidate() |
e2d17974a869
phases: provide a test and accessor for non-public phase roots
Joerg Sonnenberger <joerg@bec.de>
parents:
45063
diff
changeset
|
338 self.loadphaserevs(repo) |
45131
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
339 return any( |
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
340 revs |
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
341 for phase, revs in pycompat.iteritems(self.phaseroots) |
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
342 if phase != public |
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
343 ) |
45114
e2d17974a869
phases: provide a test and accessor for non-public phase roots
Joerg Sonnenberger <joerg@bec.de>
parents:
45063
diff
changeset
|
344 |
e2d17974a869
phases: provide a test and accessor for non-public phase roots
Joerg Sonnenberger <joerg@bec.de>
parents:
45063
diff
changeset
|
345 def nonpublicphaseroots(self, repo): |
e2d17974a869
phases: provide a test and accessor for non-public phase roots
Joerg Sonnenberger <joerg@bec.de>
parents:
45063
diff
changeset
|
346 """returns the roots of all non-public phases |
e2d17974a869
phases: provide a test and accessor for non-public phase roots
Joerg Sonnenberger <joerg@bec.de>
parents:
45063
diff
changeset
|
347 |
e2d17974a869
phases: provide a test and accessor for non-public phase roots
Joerg Sonnenberger <joerg@bec.de>
parents:
45063
diff
changeset
|
348 The roots are not minimized, so if the secret revisions are |
e2d17974a869
phases: provide a test and accessor for non-public phase roots
Joerg Sonnenberger <joerg@bec.de>
parents:
45063
diff
changeset
|
349 descendants of draft revisions, their roots will still be present. |
e2d17974a869
phases: provide a test and accessor for non-public phase roots
Joerg Sonnenberger <joerg@bec.de>
parents:
45063
diff
changeset
|
350 """ |
e2d17974a869
phases: provide a test and accessor for non-public phase roots
Joerg Sonnenberger <joerg@bec.de>
parents:
45063
diff
changeset
|
351 repo = repo.unfiltered() |
e2d17974a869
phases: provide a test and accessor for non-public phase roots
Joerg Sonnenberger <joerg@bec.de>
parents:
45063
diff
changeset
|
352 cl = repo.changelog |
e2d17974a869
phases: provide a test and accessor for non-public phase roots
Joerg Sonnenberger <joerg@bec.de>
parents:
45063
diff
changeset
|
353 if len(cl) >= self._loadedrevslen: |
e2d17974a869
phases: provide a test and accessor for non-public phase roots
Joerg Sonnenberger <joerg@bec.de>
parents:
45063
diff
changeset
|
354 self.invalidate() |
e2d17974a869
phases: provide a test and accessor for non-public phase roots
Joerg Sonnenberger <joerg@bec.de>
parents:
45063
diff
changeset
|
355 self.loadphaserevs(repo) |
45131
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
356 return set().union( |
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
357 *[ |
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
358 revs |
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
359 for phase, revs in pycompat.iteritems(self.phaseroots) |
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
360 if phase != public |
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
361 ] |
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
362 ) |
45114
e2d17974a869
phases: provide a test and accessor for non-public phase roots
Joerg Sonnenberger <joerg@bec.de>
parents:
45063
diff
changeset
|
363 |
35330
0c1aff6d73a7
revset: use phasecache.getrevset to calculate public()
Jun Wu <quark@fb.com>
parents:
35309
diff
changeset
|
364 def getrevset(self, repo, phases, subset=None): |
31016
bf81d3b7b2ba
phases: add a getrevset method to phasecache
Jun Wu <quark@fb.com>
parents:
30634
diff
changeset
|
365 """return a smartset for the given phases""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
366 self.loadphaserevs(repo) # ensure phase's sets are loaded |
35309
d13526333835
phases: drop the list with phase of each rev, always comput phase sets
Joerg Sonnenberger <joerg@bec.de>
parents:
34876
diff
changeset
|
367 phases = set(phases) |
44064
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
368 publicphase = public in phases |
44004
9c1fd975e9ac
phases: make the working directory consistently a draft
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
43730
diff
changeset
|
369 |
44064
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
370 if publicphase: |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
371 # In this case, phases keeps all the *other* phases. |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
372 phases = set(allphases).difference(phases) |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
373 if not phases: |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
374 return smartset.fullreposet(repo) |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
375 |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
376 # fast path: _phasesets contains the interesting sets, |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
377 # might only need a union and post-filtering. |
44065
ab41dad7345e
phases: make phasecache._phasesets immutable
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44064
diff
changeset
|
378 revsneedscopy = False |
44064
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
379 if len(phases) == 1: |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
380 [p] = phases |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
381 revs = self._phasesets[p] |
44065
ab41dad7345e
phases: make phasecache._phasesets immutable
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44064
diff
changeset
|
382 revsneedscopy = True # Don't modify _phasesets |
44064
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
383 else: |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
384 # revs has the revisions in all *other* phases. |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
385 revs = set.union(*[self._phasesets[p] for p in phases]) |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
386 |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
387 def _addwdir(wdirsubset, wdirrevs): |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
388 if wdirrev in wdirsubset and repo[None].phase() in phases: |
44065
ab41dad7345e
phases: make phasecache._phasesets immutable
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44064
diff
changeset
|
389 if revsneedscopy: |
ab41dad7345e
phases: make phasecache._phasesets immutable
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44064
diff
changeset
|
390 wdirrevs = wdirrevs.copy() |
44064
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
391 # The working dir would never be in the # cache, but it was in |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
392 # the subset being filtered for its phase (or filtered out, |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
393 # depending on publicphase), so add it to the output to be |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
394 # included (or filtered out). |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
395 wdirrevs.add(wdirrev) |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
396 return wdirrevs |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
397 |
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
398 if not publicphase: |
31016
bf81d3b7b2ba
phases: add a getrevset method to phasecache
Jun Wu <quark@fb.com>
parents:
30634
diff
changeset
|
399 if repo.changelog.filteredrevs: |
bf81d3b7b2ba
phases: add a getrevset method to phasecache
Jun Wu <quark@fb.com>
parents:
30634
diff
changeset
|
400 revs = revs - repo.changelog.filteredrevs |
44004
9c1fd975e9ac
phases: make the working directory consistently a draft
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
43730
diff
changeset
|
401 |
35330
0c1aff6d73a7
revset: use phasecache.getrevset to calculate public()
Jun Wu <quark@fb.com>
parents:
35309
diff
changeset
|
402 if subset is None: |
0c1aff6d73a7
revset: use phasecache.getrevset to calculate public()
Jun Wu <quark@fb.com>
parents:
35309
diff
changeset
|
403 return smartset.baseset(revs) |
0c1aff6d73a7
revset: use phasecache.getrevset to calculate public()
Jun Wu <quark@fb.com>
parents:
35309
diff
changeset
|
404 else: |
44064
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
405 revs = _addwdir(subset, revs) |
35330
0c1aff6d73a7
revset: use phasecache.getrevset to calculate public()
Jun Wu <quark@fb.com>
parents:
35309
diff
changeset
|
406 return subset & smartset.baseset(revs) |
31016
bf81d3b7b2ba
phases: add a getrevset method to phasecache
Jun Wu <quark@fb.com>
parents:
30634
diff
changeset
|
407 else: |
35330
0c1aff6d73a7
revset: use phasecache.getrevset to calculate public()
Jun Wu <quark@fb.com>
parents:
35309
diff
changeset
|
408 if subset is None: |
0c1aff6d73a7
revset: use phasecache.getrevset to calculate public()
Jun Wu <quark@fb.com>
parents:
35309
diff
changeset
|
409 subset = smartset.fullreposet(repo) |
44004
9c1fd975e9ac
phases: make the working directory consistently a draft
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
43730
diff
changeset
|
410 |
44064
8eb3c52337a6
phases: reduce code duplication in phasecache.getrevset
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
44004
diff
changeset
|
411 revs = _addwdir(subset, revs) |
44004
9c1fd975e9ac
phases: make the working directory consistently a draft
Rodrigo Damazio Bovendorp <rdamazio@google.com>
parents:
43730
diff
changeset
|
412 |
35309
d13526333835
phases: drop the list with phase of each rev, always comput phase sets
Joerg Sonnenberger <joerg@bec.de>
parents:
34876
diff
changeset
|
413 if not revs: |
35330
0c1aff6d73a7
revset: use phasecache.getrevset to calculate public()
Jun Wu <quark@fb.com>
parents:
35309
diff
changeset
|
414 return subset |
0c1aff6d73a7
revset: use phasecache.getrevset to calculate public()
Jun Wu <quark@fb.com>
parents:
35309
diff
changeset
|
415 return subset.filter(lambda r: r not in revs) |
31016
bf81d3b7b2ba
phases: add a getrevset method to phasecache
Jun Wu <quark@fb.com>
parents:
30634
diff
changeset
|
416 |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
417 def copy(self): |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
418 # Shallow copy meant to ensure isolation in |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
419 # advance/retractboundary(), nothing more. |
23631
b8260abfeb7d
bundlerepo: implement safe phasecache
Eric Sumner <ericsumner@fb.com>
parents:
23361
diff
changeset
|
420 ph = self.__class__(None, None, _load=False) |
45131
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
421 ph.phaseroots = self.phaseroots.copy() |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
422 ph.dirty = self.dirty |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
423 ph.opener = self.opener |
35441
98cc121099fe
phases: rename _phasemaxrev to _loadedrevslen to clarify it isn't max value
Yuya Nishihara <yuya@tcha.org>
parents:
35330
diff
changeset
|
424 ph._loadedrevslen = self._loadedrevslen |
25592
dd2349ccfa66
phase: also copy phase's sets when copying phase cache
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25527
diff
changeset
|
425 ph._phasesets = self._phasesets |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
426 return ph |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
427 |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
428 def replace(self, phcache): |
25613
a13c18c14ade
phase: document the replace method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25611
diff
changeset
|
429 """replace all values in 'self' with content of phcache""" |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
430 for a in ( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
431 b'phaseroots', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
432 b'dirty', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
433 b'opener', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
434 b'_loadedrevslen', |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
435 b'_phasesets', |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
436 ): |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
437 setattr(self, a, getattr(phcache, a)) |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
438 |
24599
2a73829ebe17
phases: make two functions private for phase computation
Laurent Charignon <lcharignon@fb.com>
parents:
24520
diff
changeset
|
439 def _getphaserevsnative(self, repo): |
24444
27e3ba73fbb1
phase: default to C implementation for phase computation
Laurent Charignon <lcharignon@fb.com>
parents:
23878
diff
changeset
|
440 repo = repo.unfiltered() |
45131
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
441 return repo.changelog.computephases(self.phaseroots) |
24444
27e3ba73fbb1
phase: default to C implementation for phase computation
Laurent Charignon <lcharignon@fb.com>
parents:
23878
diff
changeset
|
442 |
24599
2a73829ebe17
phases: make two functions private for phase computation
Laurent Charignon <lcharignon@fb.com>
parents:
24520
diff
changeset
|
443 def _computephaserevspure(self, repo): |
24519
de3acfabaddc
phases: move pure phase computation in a function
Laurent Charignon <lcharignon@fb.com>
parents:
24444
diff
changeset
|
444 repo = repo.unfiltered() |
35309
d13526333835
phases: drop the list with phase of each rev, always comput phase sets
Joerg Sonnenberger <joerg@bec.de>
parents:
34876
diff
changeset
|
445 cl = repo.changelog |
45131
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
446 self._phasesets = {phase: set() for phase in allphases} |
39271
fd7376fa60e7
phase: use `trackedphases` in `_getphaserevsnative`
Boris Feld <boris.feld@octobus.net>
parents:
39262
diff
changeset
|
447 lowerroots = set() |
fd7376fa60e7
phase: use `trackedphases` in `_getphaserevsnative`
Boris Feld <boris.feld@octobus.net>
parents:
39262
diff
changeset
|
448 for phase in reversed(trackedphases): |
fd7376fa60e7
phase: use `trackedphases` in `_getphaserevsnative`
Boris Feld <boris.feld@octobus.net>
parents:
39262
diff
changeset
|
449 roots = pycompat.maplist(cl.rev, self.phaseroots[phase]) |
fd7376fa60e7
phase: use `trackedphases` in `_getphaserevsnative`
Boris Feld <boris.feld@octobus.net>
parents:
39262
diff
changeset
|
450 if roots: |
fd7376fa60e7
phase: use `trackedphases` in `_getphaserevsnative`
Boris Feld <boris.feld@octobus.net>
parents:
39262
diff
changeset
|
451 ps = set(cl.descendants(roots)) |
fd7376fa60e7
phase: use `trackedphases` in `_getphaserevsnative`
Boris Feld <boris.feld@octobus.net>
parents:
39262
diff
changeset
|
452 for root in roots: |
fd7376fa60e7
phase: use `trackedphases` in `_getphaserevsnative`
Boris Feld <boris.feld@octobus.net>
parents:
39262
diff
changeset
|
453 ps.add(root) |
fd7376fa60e7
phase: use `trackedphases` in `_getphaserevsnative`
Boris Feld <boris.feld@octobus.net>
parents:
39262
diff
changeset
|
454 ps.difference_update(lowerroots) |
fd7376fa60e7
phase: use `trackedphases` in `_getphaserevsnative`
Boris Feld <boris.feld@octobus.net>
parents:
39262
diff
changeset
|
455 lowerroots.update(ps) |
fd7376fa60e7
phase: use `trackedphases` in `_getphaserevsnative`
Boris Feld <boris.feld@octobus.net>
parents:
39262
diff
changeset
|
456 self._phasesets[phase] = ps |
35441
98cc121099fe
phases: rename _phasemaxrev to _loadedrevslen to clarify it isn't max value
Yuya Nishihara <yuya@tcha.org>
parents:
35330
diff
changeset
|
457 self._loadedrevslen = len(cl) |
24519
de3acfabaddc
phases: move pure phase computation in a function
Laurent Charignon <lcharignon@fb.com>
parents:
24444
diff
changeset
|
458 |
25611
d89045a66e01
phase: rename getphaserevs to loadphaserevs
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25594
diff
changeset
|
459 def loadphaserevs(self, repo): |
d89045a66e01
phase: rename getphaserevs to loadphaserevs
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25594
diff
changeset
|
460 """ensure phase information is loaded in the object""" |
35309
d13526333835
phases: drop the list with phase of each rev, always comput phase sets
Joerg Sonnenberger <joerg@bec.de>
parents:
34876
diff
changeset
|
461 if self._phasesets is None: |
24444
27e3ba73fbb1
phase: default to C implementation for phase computation
Laurent Charignon <lcharignon@fb.com>
parents:
23878
diff
changeset
|
462 try: |
31152
b7cef987356d
phases: remove experimental.nativephaseskillswitch
Jun Wu <quark@fb.com>
parents:
31053
diff
changeset
|
463 res = self._getphaserevsnative(repo) |
35441
98cc121099fe
phases: rename _phasemaxrev to _loadedrevslen to clarify it isn't max value
Yuya Nishihara <yuya@tcha.org>
parents:
35330
diff
changeset
|
464 self._loadedrevslen, self._phasesets = res |
24444
27e3ba73fbb1
phase: default to C implementation for phase computation
Laurent Charignon <lcharignon@fb.com>
parents:
23878
diff
changeset
|
465 except AttributeError: |
24599
2a73829ebe17
phases: make two functions private for phase computation
Laurent Charignon <lcharignon@fb.com>
parents:
24520
diff
changeset
|
466 self._computephaserevspure(repo) |
22894
c40be72dc177
phases: move root phase assignment to it's own function
Durham Goode <durham@fb.com>
parents:
22893
diff
changeset
|
467 |
22893
9672f0b2cdd9
phases: add invalidate function
Durham Goode <durham@fb.com>
parents:
22080
diff
changeset
|
468 def invalidate(self): |
35442
56745e58df07
phases: initialize number of loaded revisions to 0
Yuya Nishihara <yuya@tcha.org>
parents:
35441
diff
changeset
|
469 self._loadedrevslen = 0 |
25593
9e551f155810
phase: invalidate the phase's set cache alongside the revs
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25592
diff
changeset
|
470 self._phasesets = None |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
471 |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
472 def phase(self, repo, rev): |
35309
d13526333835
phases: drop the list with phase of each rev, always comput phase sets
Joerg Sonnenberger <joerg@bec.de>
parents:
34876
diff
changeset
|
473 # We need a repo argument here to be able to build _phasesets |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
474 # if necessary. The repository instance is not stored in |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
475 # phasecache to avoid reference cycles. The changelog instance |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
476 # is not stored because it is a filecache() property and can |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
477 # be replaced without us being notified. |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
478 if rev == nullrev: |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
479 return public |
19984
7d5e7799a29f
rebase: fix rebase aborts when 'tip-1' is public (issue4082)
Durham Goode <durham@fb.com>
parents:
19951
diff
changeset
|
480 if rev < nullrev: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
481 raise ValueError(_(b'cannot lookup negative revision')) |
35441
98cc121099fe
phases: rename _phasemaxrev to _loadedrevslen to clarify it isn't max value
Yuya Nishihara <yuya@tcha.org>
parents:
35330
diff
changeset
|
482 if rev >= self._loadedrevslen: |
22893
9672f0b2cdd9
phases: add invalidate function
Durham Goode <durham@fb.com>
parents:
22080
diff
changeset
|
483 self.invalidate() |
25611
d89045a66e01
phase: rename getphaserevs to loadphaserevs
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
25594
diff
changeset
|
484 self.loadphaserevs(repo) |
35309
d13526333835
phases: drop the list with phase of each rev, always comput phase sets
Joerg Sonnenberger <joerg@bec.de>
parents:
34876
diff
changeset
|
485 for phase in trackedphases: |
d13526333835
phases: drop the list with phase of each rev, always comput phase sets
Joerg Sonnenberger <joerg@bec.de>
parents:
34876
diff
changeset
|
486 if rev in self._phasesets[phase]: |
d13526333835
phases: drop the list with phase of each rev, always comput phase sets
Joerg Sonnenberger <joerg@bec.de>
parents:
34876
diff
changeset
|
487 return phase |
d13526333835
phases: drop the list with phase of each rev, always comput phase sets
Joerg Sonnenberger <joerg@bec.de>
parents:
34876
diff
changeset
|
488 return public |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
489 |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
490 def write(self): |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
491 if not self.dirty: |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
492 return |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
493 f = self.opener(b'phaseroots', b'w', atomictemp=True, checkambig=True) |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
494 try: |
22079
5dcc58649b1a
phase: extract the phaseroots serialization in a dedicated method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22070
diff
changeset
|
495 self._write(f) |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
496 finally: |
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
497 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
|
498 |
5dcc58649b1a
phase: extract the phaseroots serialization in a dedicated method
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22070
diff
changeset
|
499 def _write(self, fp): |
45131
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
500 for phase, roots in pycompat.iteritems(self.phaseroots): |
36452
ab81e5a8fba5
phases: write phaseroots deterministically
Gregory Szorc <gregory.szorc@gmail.com>
parents:
35442
diff
changeset
|
501 for h in sorted(roots): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
502 fp.write(b'%i %s\n' % (phase, hex(h))) |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
503 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
|
504 |
22080
37f46575d9c2
phase: attach phase to the transaction instead of the lock
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22079
diff
changeset
|
505 def _updateroots(self, phase, newroots, tr): |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
506 self.phaseroots[phase] = newroots |
22893
9672f0b2cdd9
phases: add invalidate function
Durham Goode <durham@fb.com>
parents:
22080
diff
changeset
|
507 self.invalidate() |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
508 self.dirty = True |
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
509 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
510 tr.addfilegenerator(b'phase', (b'phaseroots',), self._write) |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
511 tr.hookargs[b'phases_moved'] = b'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
|
512 |
45790
5d65e04b6a80
phases: convert registernew users to use revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45789
diff
changeset
|
513 def registernew(self, repo, tr, targetphase, revs): |
33453
f6b7617a85bb
phases: add a 'registernew' method to set new phases
Boris Feld <boris.feld@octobus.net>
parents:
33452
diff
changeset
|
514 repo = repo.unfiltered() |
45790
5d65e04b6a80
phases: convert registernew users to use revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45789
diff
changeset
|
515 self._retractboundary(repo, tr, targetphase, [], revs=revs) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
516 if tr is not None and b'phases' in tr.changes: |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
517 phasetracking = tr.changes[b'phases'] |
33453
f6b7617a85bb
phases: add a 'registernew' method to set new phases
Boris Feld <boris.feld@octobus.net>
parents:
33452
diff
changeset
|
518 phase = self.phase |
45790
5d65e04b6a80
phases: convert registernew users to use revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45789
diff
changeset
|
519 for rev in sorted(revs): |
33453
f6b7617a85bb
phases: add a 'registernew' method to set new phases
Boris Feld <boris.feld@octobus.net>
parents:
33452
diff
changeset
|
520 revphase = phase(repo, rev) |
f6b7617a85bb
phases: add a 'registernew' method to set new phases
Boris Feld <boris.feld@octobus.net>
parents:
33452
diff
changeset
|
521 _trackphasechange(phasetracking, rev, None, revphase) |
f6b7617a85bb
phases: add a 'registernew' method to set new phases
Boris Feld <boris.feld@octobus.net>
parents:
33452
diff
changeset
|
522 repo.invalidatevolatilesets() |
f6b7617a85bb
phases: add a 'registernew' method to set new phases
Boris Feld <boris.feld@octobus.net>
parents:
33452
diff
changeset
|
523 |
45789
09735cde6275
phases: allow registration and boundary advancement with revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45550
diff
changeset
|
524 def advanceboundary( |
09735cde6275
phases: allow registration and boundary advancement with revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45550
diff
changeset
|
525 self, repo, tr, targetphase, nodes, revs=None, dryrun=None |
09735cde6275
phases: allow registration and boundary advancement with revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45550
diff
changeset
|
526 ): |
33450
d017f1d37378
phases: extract the intermediate set of affected revs
Boris Feld <boris.feld@octobus.net>
parents:
33449
diff
changeset
|
527 """Set all 'nodes' to phase 'targetphase' |
d017f1d37378
phases: extract the intermediate set of affected revs
Boris Feld <boris.feld@octobus.net>
parents:
33449
diff
changeset
|
528 |
d017f1d37378
phases: extract the intermediate set of affected revs
Boris Feld <boris.feld@octobus.net>
parents:
33449
diff
changeset
|
529 Nodes with a phase lower than 'targetphase' are not affected. |
38218
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
530 |
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
531 If dryrun is True, no actions will be performed |
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
532 |
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
533 Returns a set of revs whose phase is changed or should be changed |
33450
d017f1d37378
phases: extract the intermediate set of affected revs
Boris Feld <boris.feld@octobus.net>
parents:
33449
diff
changeset
|
534 """ |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
535 # 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
|
536 # phaseroots values, replace them. |
45789
09735cde6275
phases: allow registration and boundary advancement with revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45550
diff
changeset
|
537 if revs is None: |
09735cde6275
phases: allow registration and boundary advancement with revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45550
diff
changeset
|
538 revs = [] |
33451
e44d54260c32
phases: track phase movements in 'advanceboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33450
diff
changeset
|
539 if tr is None: |
e44d54260c32
phases: track phase movements in 'advanceboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33450
diff
changeset
|
540 phasetracking = None |
e44d54260c32
phases: track phase movements in 'advanceboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33450
diff
changeset
|
541 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
542 phasetracking = tr.changes.get(b'phases') |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
543 |
18002
9bc5873e52af
clfilter: phases logic should be unfiltered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17979
diff
changeset
|
544 repo = repo.unfiltered() |
45789
09735cde6275
phases: allow registration and boundary advancement with revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45550
diff
changeset
|
545 revs = [repo[n].rev() for n in nodes] + [r for r in revs] |
33451
e44d54260c32
phases: track phase movements in 'advanceboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33450
diff
changeset
|
546 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
547 changes = set() # set of revisions to be changed |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
548 delroots = [] # set of root deleted by this path |
45117
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
549 for phase in (phase for phase in allphases if phase > targetphase): |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
550 # filter nodes that are not in a compatible phase already |
45789
09735cde6275
phases: allow registration and boundary advancement with revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45550
diff
changeset
|
551 revs = [rev for rev in revs if self.phase(repo, rev) >= phase] |
09735cde6275
phases: allow registration and boundary advancement with revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45550
diff
changeset
|
552 if not revs: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
553 break # no roots to move anymore |
33450
d017f1d37378
phases: extract the intermediate set of affected revs
Boris Feld <boris.feld@octobus.net>
parents:
33449
diff
changeset
|
554 |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
555 olds = self.phaseroots[phase] |
33451
e44d54260c32
phases: track phase movements in 'advanceboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33450
diff
changeset
|
556 |
45789
09735cde6275
phases: allow registration and boundary advancement with revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45550
diff
changeset
|
557 affected = repo.revs(b'%ln::%ld', olds, revs) |
38218
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
558 changes.update(affected) |
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
559 if dryrun: |
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
560 continue |
33451
e44d54260c32
phases: track phase movements in 'advanceboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33450
diff
changeset
|
561 for r in affected: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
562 _trackphasechange( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
563 phasetracking, r, self.phase(repo, r), targetphase |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
564 ) |
33450
d017f1d37378
phases: extract the intermediate set of affected revs
Boris Feld <boris.feld@octobus.net>
parents:
33449
diff
changeset
|
565 |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44065
diff
changeset
|
566 roots = { |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
567 ctx.node() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
568 for ctx in repo.set(b'roots((%ln::) - %ld)', olds, affected) |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44065
diff
changeset
|
569 } |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
570 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
|
571 self._updateroots(phase, roots, tr) |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
572 # 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
|
573 delroots.extend(olds - roots) |
38218
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
574 if not dryrun: |
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
575 # declare deleted root in the target phase |
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
576 if targetphase != 0: |
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
577 self._retractboundary(repo, tr, targetphase, delroots) |
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
578 repo.invalidatevolatilesets() |
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
579 return changes |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
580 |
22070
c1ca47204590
phase: add a transaction argument to retractboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22069
diff
changeset
|
581 def retractboundary(self, repo, tr, targetphase, nodes): |
45131
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
582 oldroots = { |
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
583 phase: revs |
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
584 for phase, revs in pycompat.iteritems(self.phaseroots) |
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
585 if phase <= targetphase |
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
586 } |
33458
cf694e6422f0
phases: track phase changes from 'retractboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33457
diff
changeset
|
587 if tr is None: |
cf694e6422f0
phases: track phase changes from 'retractboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33457
diff
changeset
|
588 phasetracking = None |
cf694e6422f0
phases: track phase changes from 'retractboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33457
diff
changeset
|
589 else: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
590 phasetracking = tr.changes.get(b'phases') |
33458
cf694e6422f0
phases: track phase changes from 'retractboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33457
diff
changeset
|
591 repo = repo.unfiltered() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
592 if ( |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
593 self._retractboundary(repo, tr, targetphase, nodes) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
594 and phasetracking is not None |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
595 ): |
33458
cf694e6422f0
phases: track phase changes from 'retractboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33457
diff
changeset
|
596 |
cf694e6422f0
phases: track phase changes from 'retractboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33457
diff
changeset
|
597 # find the affected revisions |
cf694e6422f0
phases: track phase changes from 'retractboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33457
diff
changeset
|
598 new = self.phaseroots[targetphase] |
cf694e6422f0
phases: track phase changes from 'retractboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33457
diff
changeset
|
599 old = oldroots[targetphase] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
600 affected = set(repo.revs(b'(%ln::) - (%ln::)', new, old)) |
33458
cf694e6422f0
phases: track phase changes from 'retractboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33457
diff
changeset
|
601 |
cf694e6422f0
phases: track phase changes from 'retractboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33457
diff
changeset
|
602 # find the phase of the affected revision |
38783
e7aa113b14f7
global: use pycompat.xrange()
Gregory Szorc <gregory.szorc@gmail.com>
parents:
38683
diff
changeset
|
603 for phase in pycompat.xrange(targetphase, -1, -1): |
33458
cf694e6422f0
phases: track phase changes from 'retractboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33457
diff
changeset
|
604 if phase: |
45131
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
605 roots = oldroots.get(phase, []) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
606 revs = set(repo.revs(b'%ln::%ld', roots, affected)) |
33458
cf694e6422f0
phases: track phase changes from 'retractboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33457
diff
changeset
|
607 affected -= revs |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
608 else: # public phase |
33458
cf694e6422f0
phases: track phase changes from 'retractboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33457
diff
changeset
|
609 revs = affected |
44548
fdc802f29b2c
transactions: convert changes['phases'] to list of ranges
Joerg Sonnenberger <joerg@bec.de>
parents:
44452
diff
changeset
|
610 for r in sorted(revs): |
33458
cf694e6422f0
phases: track phase changes from 'retractboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33457
diff
changeset
|
611 _trackphasechange(phasetracking, r, phase, targetphase) |
33452
7b25a56366cf
phases: extract the core of boundary retraction in '_retractboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33451
diff
changeset
|
612 repo.invalidatevolatilesets() |
7b25a56366cf
phases: extract the core of boundary retraction in '_retractboundary'
Boris Feld <boris.feld@octobus.net>
parents:
33451
diff
changeset
|
613 |
45789
09735cde6275
phases: allow registration and boundary advancement with revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45550
diff
changeset
|
614 def _retractboundary(self, repo, tr, targetphase, nodes, revs=None): |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
615 # 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
|
616 # phaseroots values, replace them. |
45789
09735cde6275
phases: allow registration and boundary advancement with revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45550
diff
changeset
|
617 if revs is None: |
09735cde6275
phases: allow registration and boundary advancement with revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45550
diff
changeset
|
618 revs = [] |
40417
49c7b701fdc2
phase: add an archived phase
Boris Feld <boris.feld@octobus.net>
parents:
39299
diff
changeset
|
619 if targetphase in (archived, internal) and not supportinternal(repo): |
49c7b701fdc2
phase: add an archived phase
Boris Feld <boris.feld@octobus.net>
parents:
39299
diff
changeset
|
620 name = phasenames[targetphase] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
621 msg = b'this repository does not support the %s phase' % name |
39299
7775c1fb8fa0
phases: enforce internal phase support
Boris Feld <boris.feld@octobus.net>
parents:
39297
diff
changeset
|
622 raise error.ProgrammingError(msg) |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
623 |
18002
9bc5873e52af
clfilter: phases logic should be unfiltered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17979
diff
changeset
|
624 repo = repo.unfiltered() |
44988
fa151f7af275
phases: improve performance of _retractboundary
Joerg Sonnenberger <joerg@bec.de>
parents:
44548
diff
changeset
|
625 torev = repo.changelog.rev |
fa151f7af275
phases: improve performance of _retractboundary
Joerg Sonnenberger <joerg@bec.de>
parents:
44548
diff
changeset
|
626 tonode = repo.changelog.node |
fa151f7af275
phases: improve performance of _retractboundary
Joerg Sonnenberger <joerg@bec.de>
parents:
44548
diff
changeset
|
627 currentroots = {torev(node) for node in self.phaseroots[targetphase]} |
33457
61714c282106
phases: detect when boundaries has been actually retracted
Boris Feld <boris.feld@octobus.net>
parents:
33453
diff
changeset
|
628 finalroots = oldroots = set(currentroots) |
45789
09735cde6275
phases: allow registration and boundary advancement with revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45550
diff
changeset
|
629 newroots = [torev(node) for node in nodes] + [r for r in revs] |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
630 newroots = [ |
44988
fa151f7af275
phases: improve performance of _retractboundary
Joerg Sonnenberger <joerg@bec.de>
parents:
44548
diff
changeset
|
631 rev for rev in newroots if self.phase(repo, rev) < targetphase |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
632 ] |
44988
fa151f7af275
phases: improve performance of _retractboundary
Joerg Sonnenberger <joerg@bec.de>
parents:
44548
diff
changeset
|
633 |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
634 if newroots: |
44988
fa151f7af275
phases: improve performance of _retractboundary
Joerg Sonnenberger <joerg@bec.de>
parents:
44548
diff
changeset
|
635 if nullrev in newroots: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
636 raise error.Abort(_(b'cannot change null revision phase')) |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
637 currentroots.update(newroots) |
26909
e36118815a39
phase: improve retractboundary perf
Durham Goode <durham@fb.com>
parents:
26587
diff
changeset
|
638 |
e36118815a39
phase: improve retractboundary perf
Durham Goode <durham@fb.com>
parents:
26587
diff
changeset
|
639 # Only compute new roots for revs above the roots that are being |
e36118815a39
phase: improve retractboundary perf
Durham Goode <durham@fb.com>
parents:
26587
diff
changeset
|
640 # retracted. |
44988
fa151f7af275
phases: improve performance of _retractboundary
Joerg Sonnenberger <joerg@bec.de>
parents:
44548
diff
changeset
|
641 minnewroot = min(newroots) |
fa151f7af275
phases: improve performance of _retractboundary
Joerg Sonnenberger <joerg@bec.de>
parents:
44548
diff
changeset
|
642 aboveroots = [rev for rev in currentroots if rev >= minnewroot] |
44993
98f97026fa05
phases: remove useless lookup of repo[rev].rev() in _retractboundary
Yuya Nishihara <yuya@tcha.org>
parents:
44988
diff
changeset
|
643 updatedroots = repo.revs(b'roots(%ld::)', aboveroots) |
26909
e36118815a39
phase: improve retractboundary perf
Durham Goode <durham@fb.com>
parents:
26587
diff
changeset
|
644 |
44988
fa151f7af275
phases: improve performance of _retractboundary
Joerg Sonnenberger <joerg@bec.de>
parents:
44548
diff
changeset
|
645 finalroots = {rev for rev in currentroots if rev < minnewroot} |
44993
98f97026fa05
phases: remove useless lookup of repo[rev].rev() in _retractboundary
Yuya Nishihara <yuya@tcha.org>
parents:
44988
diff
changeset
|
646 finalroots.update(updatedroots) |
33457
61714c282106
phases: detect when boundaries has been actually retracted
Boris Feld <boris.feld@octobus.net>
parents:
33453
diff
changeset
|
647 if finalroots != oldroots: |
44988
fa151f7af275
phases: improve performance of _retractboundary
Joerg Sonnenberger <joerg@bec.de>
parents:
44548
diff
changeset
|
648 self._updateroots( |
fa151f7af275
phases: improve performance of _retractboundary
Joerg Sonnenberger <joerg@bec.de>
parents:
44548
diff
changeset
|
649 targetphase, {tonode(rev) for rev in finalroots}, tr |
fa151f7af275
phases: improve performance of _retractboundary
Joerg Sonnenberger <joerg@bec.de>
parents:
44548
diff
changeset
|
650 ) |
33457
61714c282106
phases: detect when boundaries has been actually retracted
Boris Feld <boris.feld@octobus.net>
parents:
33453
diff
changeset
|
651 return True |
61714c282106
phases: detect when boundaries has been actually retracted
Boris Feld <boris.feld@octobus.net>
parents:
33453
diff
changeset
|
652 return False |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
653 |
18220
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
654 def filterunknown(self, repo): |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
655 """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
|
656 |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
657 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
|
658 """ |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
659 filtered = False |
43539
44f54b8f9f10
index: use `index.has_node` in `phases.filterunknown`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43538
diff
changeset
|
660 has_node = repo.changelog.index.has_node # to filter unknown nodes |
45131
61e7464477ac
phases: sparsify phaseroots and phasesets
Joerg Sonnenberger <joerg@bec.de>
parents:
45117
diff
changeset
|
661 for phase, nodes in pycompat.iteritems(self.phaseroots): |
43539
44f54b8f9f10
index: use `index.has_node` in `phases.filterunknown`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43538
diff
changeset
|
662 missing = sorted(node for node in nodes if not has_node(node)) |
18220
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
663 if missing: |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
664 for mnode in missing: |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
665 repo.ui.debug( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
666 b'removing unknown node %s from %i-phase boundary\n' |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
667 % (short(mnode), phase) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
668 ) |
18220
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
669 nodes.symmetric_difference_update(missing) |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
670 filtered = True |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
671 if filtered: |
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
672 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
|
673 # filterunknown is called by repo.destroyed, we may have no changes in |
35309
d13526333835
phases: drop the list with phase of each rev, always comput phase sets
Joerg Sonnenberger <joerg@bec.de>
parents:
34876
diff
changeset
|
674 # root but _phasesets contents is certainly invalid (or at least we |
19951
d51c4d85ec23
spelling: random spell checker fixes
Mads Kiilerich <madski@unity3d.com>
parents:
18983
diff
changeset
|
675 # 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
|
676 # |
35309
d13526333835
phases: drop the list with phase of each rev, always comput phase sets
Joerg Sonnenberger <joerg@bec.de>
parents:
34876
diff
changeset
|
677 # The other caller is __init__ that have no _phasesets initialized |
18983
31bcc5112191
destroyed: invalidate phraserevs cache in all case (issue3858)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18220
diff
changeset
|
678 # 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
|
679 # "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
|
680 # (see branchmap one) |
22893
9672f0b2cdd9
phases: add invalidate function
Durham Goode <durham@fb.com>
parents:
22080
diff
changeset
|
681 self.invalidate() |
18220
767d1c602c8b
phases: make _filterunknown a member function of phasecache
Idan Kamara <idankk86@gmail.com>
parents:
18105
diff
changeset
|
682 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
683 |
45789
09735cde6275
phases: allow registration and boundary advancement with revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45550
diff
changeset
|
684 def advanceboundary(repo, tr, targetphase, nodes, revs=None, dryrun=None): |
15454
5a7dde5adec8
phases: add a moveboundary function to move phases boundaries
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15419
diff
changeset
|
685 """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
|
686 |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
687 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
|
688 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
|
689 |
38218
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
690 Simplify boundary to contains phase roots only. |
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
691 |
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
692 If dryrun is True, no actions will be performed |
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
693 |
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
694 Returns a set of revs whose phase is changed or should be changed |
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
695 """ |
45789
09735cde6275
phases: allow registration and boundary advancement with revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45550
diff
changeset
|
696 if revs is None: |
09735cde6275
phases: allow registration and boundary advancement with revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45550
diff
changeset
|
697 revs = [] |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
698 phcache = repo._phasecache.copy() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
699 changes = phcache.advanceboundary( |
45789
09735cde6275
phases: allow registration and boundary advancement with revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45550
diff
changeset
|
700 repo, tr, targetphase, nodes, revs=revs, dryrun=dryrun |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
701 ) |
38218
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
702 if not dryrun: |
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
703 repo._phasecache.replace(phcache) |
36ba5dba372d
advanceboundary: add dryrun parameter
Sushil khanchi <sushilkhanchi97@gmail.com>
parents:
38158
diff
changeset
|
704 return changes |
15482
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
705 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
706 |
22070
c1ca47204590
phase: add a transaction argument to retractboundary
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
22069
diff
changeset
|
707 def retractboundary(repo, tr, targetphase, nodes): |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
708 """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
|
709 necessary. |
15482
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
710 |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
711 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
|
712 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
|
713 |
a667c89e49b3
phases: add retractboundary function to move boundary backward
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15481
diff
changeset
|
714 Simplify boundary to contains phase roots only.""" |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
715 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
|
716 phcache.retractboundary(repo, tr, targetphase, nodes) |
16658
6b3d31d04a69
phases: make advance/retractboundary() atomic
Patrick Mezard <patrick@mezard.eu>
parents:
16657
diff
changeset
|
717 repo._phasecache.replace(phcache) |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
718 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
719 |
45790
5d65e04b6a80
phases: convert registernew users to use revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45789
diff
changeset
|
720 def registernew(repo, tr, targetphase, revs): |
33453
f6b7617a85bb
phases: add a 'registernew' method to set new phases
Boris Feld <boris.feld@octobus.net>
parents:
33452
diff
changeset
|
721 """register a new revision and its phase |
f6b7617a85bb
phases: add a 'registernew' method to set new phases
Boris Feld <boris.feld@octobus.net>
parents:
33452
diff
changeset
|
722 |
f6b7617a85bb
phases: add a 'registernew' method to set new phases
Boris Feld <boris.feld@octobus.net>
parents:
33452
diff
changeset
|
723 Code adding revisions to the repository should use this function to |
f6b7617a85bb
phases: add a 'registernew' method to set new phases
Boris Feld <boris.feld@octobus.net>
parents:
33452
diff
changeset
|
724 set new changeset in their target phase (or higher). |
f6b7617a85bb
phases: add a 'registernew' method to set new phases
Boris Feld <boris.feld@octobus.net>
parents:
33452
diff
changeset
|
725 """ |
f6b7617a85bb
phases: add a 'registernew' method to set new phases
Boris Feld <boris.feld@octobus.net>
parents:
33452
diff
changeset
|
726 phcache = repo._phasecache.copy() |
45790
5d65e04b6a80
phases: convert registernew users to use revision sets
Joerg Sonnenberger <joerg@bec.de>
parents:
45789
diff
changeset
|
727 phcache.registernew(repo, tr, targetphase, revs) |
33453
f6b7617a85bb
phases: add a 'registernew' method to set new phases
Boris Feld <boris.feld@octobus.net>
parents:
33452
diff
changeset
|
728 repo._phasecache.replace(phcache) |
f6b7617a85bb
phases: add a 'registernew' method to set new phases
Boris Feld <boris.feld@octobus.net>
parents:
33452
diff
changeset
|
729 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
730 |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
731 def listphases(repo): |
16724
00535da82faf
phases: fix typos in docstrings
Martin Geisler <martin@geisler.net>
parents:
16659
diff
changeset
|
732 """List phases root for serialization over pushkey""" |
32000
511a62669f1b
phases: emit phases to pushkey protocol in deterministic order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31342
diff
changeset
|
733 # Use ordered dictionary so behavior is deterministic. |
511a62669f1b
phases: emit phases to pushkey protocol in deterministic order
Gregory Szorc <gregory.szorc@gmail.com>
parents:
31342
diff
changeset
|
734 keys = util.sortdict() |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
735 value = b'%i' % draft |
34816
e2c42f751b06
phase: filter out non-draft item in "draft root"
Boris Feld <boris.feld@octobus.net>
parents:
34710
diff
changeset
|
736 cl = repo.unfiltered().changelog |
16657
b6081c2c4647
phases: introduce phasecache
Patrick Mezard <patrick@mezard.eu>
parents:
16626
diff
changeset
|
737 for root in repo._phasecache.phaseroots[draft]: |
34816
e2c42f751b06
phase: filter out non-draft item in "draft root"
Boris Feld <boris.feld@octobus.net>
parents:
34710
diff
changeset
|
738 if repo._phasecache.phase(repo, cl.rev(root)) <= draft: |
e2c42f751b06
phase: filter out non-draft item in "draft root"
Boris Feld <boris.feld@octobus.net>
parents:
34710
diff
changeset
|
739 keys[hex(root)] = value |
15892
592b3d1742a1
phases: simplify phase exchange and movement over pushkey
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15821
diff
changeset
|
740 |
25624
f0745da75056
publishing: use new helper method
Matt Mackall <mpm@selenic.com>
parents:
25614
diff
changeset
|
741 if repo.publishing(): |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
742 # 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
|
743 # 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
|
744 # 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
|
745 # push phase boundary |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
746 # |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
747 # 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
|
748 # 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
|
749 # 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
|
750 # |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
751 # 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
|
752 # 2) repo B make changeset X public |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
753 # 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
|
754 # X as now public should |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
755 # |
16725
b0fb4f57d076
phases: wrap docstrings at 70 characters
Martin Geisler <martin@geisler.net>
parents:
16724
diff
changeset
|
756 # 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
|
757 # client phase data. |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
758 keys[b'publishing'] = b'True' |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
759 return keys |
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
760 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
761 |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
762 def pushphase(repo, nhex, oldphasestr, newphasestr): |
17535 | 763 """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
|
764 repo = repo.unfiltered() |
27861
3315a9c2019c
with: use context manager for lock in pushphase
Bryan O'Sullivan <bryano@fb.com>
parents:
26909
diff
changeset
|
765 with repo.lock(): |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
766 currentphase = repo[nhex].phase() |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
767 newphase = abs(int(newphasestr)) # let's avoid negative index surprise |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
768 oldphase = abs(int(oldphasestr)) # let's avoid negative index surprise |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
769 if currentphase == oldphase and newphase < oldphase: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
770 with repo.transaction(b'pushkey-phase') as tr: |
27861
3315a9c2019c
with: use context manager for lock in pushphase
Bryan O'Sullivan <bryano@fb.com>
parents:
26909
diff
changeset
|
771 advanceboundary(repo, tr, newphase, [bin(nhex)]) |
32822
e65ff29dbeb0
pushkey: use False/True for return values from push functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
32000
diff
changeset
|
772 return True |
16051
2aa5b51f310f
phases: don't complain if cset is already public on pushkey (issue3230)
Matt Mackall <mpm@selenic.com>
parents:
16030
diff
changeset
|
773 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
|
774 # raced, but got correct result |
32822
e65ff29dbeb0
pushkey: use False/True for return values from push functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
32000
diff
changeset
|
775 return True |
15648
79cc89de5be1
phases: add basic pushkey support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15482
diff
changeset
|
776 else: |
32822
e65ff29dbeb0
pushkey: use False/True for return values from push functions
Martin von Zweigbergk <martinvonz@google.com>
parents:
32000
diff
changeset
|
777 return False |
15649
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
778 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
779 |
33031
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
32822
diff
changeset
|
780 def subsetphaseheads(repo, subset): |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
32822
diff
changeset
|
781 """Finds the phase heads for a subset of a history |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
32822
diff
changeset
|
782 |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
32822
diff
changeset
|
783 Returns a list indexed by phase number where each item is a list of phase |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
32822
diff
changeset
|
784 head nodes. |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
32822
diff
changeset
|
785 """ |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
32822
diff
changeset
|
786 cl = repo.changelog |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
32822
diff
changeset
|
787 |
45117
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
788 headsbyphase = {i: [] for i in allphases} |
33031
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
32822
diff
changeset
|
789 # No need to keep track of secret phase; any heads in the subset that |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
32822
diff
changeset
|
790 # are not mentioned are implicitly secret. |
39272
160bd45cc6af
phase: explicitly exclude secret phase and above
Boris Feld <boris.feld@octobus.net>
parents:
39271
diff
changeset
|
791 for phase in allphases[:secret]: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
792 revset = b"heads(%%ln & %s())" % phasenames[phase] |
33031
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
32822
diff
changeset
|
793 headsbyphase[phase] = [cl.node(r) for r in repo.revs(revset, subset)] |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
32822
diff
changeset
|
794 return headsbyphase |
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
32822
diff
changeset
|
795 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
796 |
34321
4ef472b975ff
bundle2: only grab a transaction when 'phase-heads' affect the repository
Boris Feld <boris.feld@octobus.net>
parents:
34320
diff
changeset
|
797 def updatephases(repo, trgetter, headsbyphase): |
33031
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
32822
diff
changeset
|
798 """Updates the repo with the given phase heads""" |
45116
361a7444bc41
phases: updatephases should not skip internal phase
Joerg Sonnenberger <joerg@bec.de>
parents:
45114
diff
changeset
|
799 # Now advance phase boundaries of all phases |
34321
4ef472b975ff
bundle2: only grab a transaction when 'phase-heads' affect the repository
Boris Feld <boris.feld@octobus.net>
parents:
34320
diff
changeset
|
800 # |
4ef472b975ff
bundle2: only grab a transaction when 'phase-heads' affect the repository
Boris Feld <boris.feld@octobus.net>
parents:
34320
diff
changeset
|
801 # run the update (and fetch transaction) only if there are actually things |
4ef472b975ff
bundle2: only grab a transaction when 'phase-heads' affect the repository
Boris Feld <boris.feld@octobus.net>
parents:
34320
diff
changeset
|
802 # to update. This avoid creating empty transaction during no-op operation. |
4ef472b975ff
bundle2: only grab a transaction when 'phase-heads' affect the repository
Boris Feld <boris.feld@octobus.net>
parents:
34320
diff
changeset
|
803 |
45116
361a7444bc41
phases: updatephases should not skip internal phase
Joerg Sonnenberger <joerg@bec.de>
parents:
45114
diff
changeset
|
804 for phase in allphases: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
805 revset = b'%ln - _phase(%s)' |
39293
278eb4541758
phases: simplify revset in updatephases
Boris Feld <boris.feld@octobus.net>
parents:
39275
diff
changeset
|
806 heads = [c.node() for c in repo.set(revset, headsbyphase[phase], phase)] |
34321
4ef472b975ff
bundle2: only grab a transaction when 'phase-heads' affect the repository
Boris Feld <boris.feld@octobus.net>
parents:
34320
diff
changeset
|
807 if heads: |
4ef472b975ff
bundle2: only grab a transaction when 'phase-heads' affect the repository
Boris Feld <boris.feld@octobus.net>
parents:
34320
diff
changeset
|
808 advanceboundary(repo, trgetter(), phase, heads) |
33031
e8c8d81eb864
bundle: add config option to include phases
Martin von Zweigbergk <martinvonz@google.com>
parents:
32822
diff
changeset
|
809 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
810 |
15649
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
811 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
|
812 """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
|
813 |
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
814 * 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
|
815 * 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
|
816 |
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
817 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
|
818 """ |
18002
9bc5873e52af
clfilter: phases logic should be unfiltered
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17979
diff
changeset
|
819 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
|
820 # 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
|
821 draftroots = [] |
43538
9970412d2ce3
index: use `index.has_node` in `analyzeremotephases`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43106
diff
changeset
|
822 has_node = repo.changelog.index.has_node # to filter unknown nodes |
43106
d783f945a701
py3: finish porting iteritems() to pycompat and remove source transformer
Gregory Szorc <gregory.szorc@gmail.com>
parents:
43089
diff
changeset
|
823 for nhex, phase in pycompat.iteritems(roots): |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
824 if nhex == b'publishing': # ignore data related to publish option |
15649
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
825 continue |
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
826 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
|
827 phase = int(phase) |
28174
f16b84b1e40e
phases: use constants for phase values
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27874
diff
changeset
|
828 if phase == public: |
15892
592b3d1742a1
phases: simplify phase exchange and movement over pushkey
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15821
diff
changeset
|
829 if node != nullid: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
830 repo.ui.warn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
831 _( |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
832 b'ignoring inconsistent public root' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
833 b' from remote: %s\n' |
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
834 ) |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
835 % nhex |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
836 ) |
28174
f16b84b1e40e
phases: use constants for phase values
Gregory Szorc <gregory.szorc@gmail.com>
parents:
27874
diff
changeset
|
837 elif phase == draft: |
43538
9970412d2ce3
index: use `index.has_node` in `analyzeremotephases`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43106
diff
changeset
|
838 if has_node(node): |
15892
592b3d1742a1
phases: simplify phase exchange and movement over pushkey
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15821
diff
changeset
|
839 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
|
840 else: |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
841 repo.ui.warn( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
842 _(b'ignoring unexpected root from remote: %i %s\n') |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
843 % (phase, nhex) |
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
844 ) |
15649
ca7c4254a21a
phases: add a function to compute heads from root
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
15648
diff
changeset
|
845 # compute heads |
15954
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
846 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
|
847 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
|
848 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
849 |
34819
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34816
diff
changeset
|
850 class remotephasessummary(object): |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34816
diff
changeset
|
851 """summarize phase information on the remote side |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34816
diff
changeset
|
852 |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34816
diff
changeset
|
853 :publishing: True is the remote is publishing |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34816
diff
changeset
|
854 :publicheads: list of remote public phase heads (nodes) |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34816
diff
changeset
|
855 :draftheads: list of remote draft phase heads (nodes) |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34816
diff
changeset
|
856 :draftroots: list of remote draft phase root (nodes) |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34816
diff
changeset
|
857 """ |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34816
diff
changeset
|
858 |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34816
diff
changeset
|
859 def __init__(self, repo, remotesubset, remoteroots): |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34816
diff
changeset
|
860 unfi = repo.unfiltered() |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34816
diff
changeset
|
861 self._allremoteroots = remoteroots |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34816
diff
changeset
|
862 |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
863 self.publishing = remoteroots.get(b'publishing', False) |
34819
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34816
diff
changeset
|
864 |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34816
diff
changeset
|
865 ana = analyzeremotephases(repo, remotesubset, remoteroots) |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34816
diff
changeset
|
866 self.publicheads, self.draftroots = ana |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34816
diff
changeset
|
867 # Get the list of all "heads" revs draft on remote |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
868 dheads = unfi.set(b'heads(%ln::%ln)', self.draftroots, remotesubset) |
34819
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34816
diff
changeset
|
869 self.draftheads = [c.node() for c in dheads] |
eb6375651974
phase: gather remote phase information in a summary object
Boris Feld <boris.feld@octobus.net>
parents:
34816
diff
changeset
|
870 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
871 |
15954
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
872 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
|
873 """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
|
874 |
b345f851d056
phase: extracts heads computation logics from analyzeremotephases
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
15953
diff
changeset
|
875 * `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
|
876 * `roots`: define the second we subtract from the first""" |
39146
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
877 # prevent an import cycle |
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
878 # phases > dagop > patch > copies > scmutil > obsolete > obsutil > phases |
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
879 from . import dagop |
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
880 |
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
881 repo = repo.unfiltered() |
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
882 cl = repo.changelog |
43556
505a2bc53759
index: use `index.get_rev` in `phases.newheads`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
43539
diff
changeset
|
883 rev = cl.index.get_rev |
39146
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
884 if not roots: |
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
885 return heads |
39199
d8ac2ad55d9c
phases: fix `nullid` reference in newheads
Boris Feld <boris.feld@octobus.net>
parents:
39146
diff
changeset
|
886 if not heads or heads == [nullid]: |
39146
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
887 return [] |
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
888 # The logic operated on revisions, convert arguments early for convenience |
44452
9d2b2df2c2ba
cleanup: run pyupgrade on our source tree to clean up varying things
Augie Fackler <augie@google.com>
parents:
44065
diff
changeset
|
889 new_heads = {rev(n) for n in heads if n != nullid} |
39146
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
890 roots = [rev(n) for n in roots] |
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
891 # compute the area we need to remove |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
892 affected_zone = repo.revs(b"(%ld::%ld)", roots, new_heads) |
39146
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
893 # heads in the area are no longer heads |
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
894 new_heads.difference_update(affected_zone) |
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
895 # revisions in the area have children outside of it, |
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
896 # They might be new heads |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
897 candidates = repo.revs( |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
898 b"parents(%ld + (%ld and merge())) and not null", roots, affected_zone |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
899 ) |
39146
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
900 candidates -= affected_zone |
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
901 if new_heads or candidates: |
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
902 # remove candidate that are ancestors of other heads |
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
903 new_heads.update(candidates) |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
904 prunestart = repo.revs(b"parents(%ld) and not null", new_heads) |
39146
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
905 pruned = dagop.reachableroots(repo, candidates, prunestart) |
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
906 new_heads.difference_update(pruned) |
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
907 |
f736fdbe546a
remotephase: avoid full changelog iteration (issue5964)
Boris Feld <boris.feld@octobus.net>
parents:
39141
diff
changeset
|
908 return pycompat.maplist(cl.node, sorted(new_heads)) |
16030
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
909 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
910 |
16030
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
911 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
|
912 """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
|
913 |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
914 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
|
915 |
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
916 """ |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
917 v = ui.config(b'phases', b'new-commit') |
16030
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
918 try: |
45117
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
919 return phasenumber2[v] |
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
920 except KeyError: |
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
921 raise error.ConfigError( |
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
922 _(b"phases.new-commit: not a valid phase name ('%s')") % v |
b1e51ef4e536
phases: sparsify phase lists
Joerg Sonnenberger <joerg@bec.de>
parents:
45116
diff
changeset
|
923 ) |
16030
308406677e9d
phases: allow phase name in phases.new-commit settings
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
16025
diff
changeset
|
924 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
925 |
17671
fdd0fc046cf1
clfilter: introduce a `hassecret` function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17537
diff
changeset
|
926 def hassecret(repo): |
fdd0fc046cf1
clfilter: introduce a `hassecret` function
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17537
diff
changeset
|
927 """utility function that check if a repo have any secret changeset.""" |
45063
6232d732658c
phases: replace magic number by constant
Joerg Sonnenberger <joerg@bec.de>
parents:
44993
diff
changeset
|
928 return bool(repo._phasecache.phaseroots[secret]) |
34710
cdf833d7de98
phase: add a dedicated txnclose-phase hook
Boris Feld <boris.feld@octobus.net>
parents:
34563
diff
changeset
|
929 |
43076
2372284d9457
formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents:
40580
diff
changeset
|
930 |
34710
cdf833d7de98
phase: add a dedicated txnclose-phase hook
Boris Feld <boris.feld@octobus.net>
parents:
34563
diff
changeset
|
931 def preparehookargs(node, old, new): |
cdf833d7de98
phase: add a dedicated txnclose-phase hook
Boris Feld <boris.feld@octobus.net>
parents:
34563
diff
changeset
|
932 if old is None: |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
933 old = b'' |
34710
cdf833d7de98
phase: add a dedicated txnclose-phase hook
Boris Feld <boris.feld@octobus.net>
parents:
34563
diff
changeset
|
934 else: |
34876
eb1b964b354b
phases: pass phase names to hooks instead of internal values
Kevin Bullock <kbullock+mercurial@ringworld.org>
parents:
34819
diff
changeset
|
935 old = phasenames[old] |
43077
687b865b95ad
formatting: byteify all mercurial/ and hgext/ string literals
Augie Fackler <augie@google.com>
parents:
43076
diff
changeset
|
936 return {b'node': node, b'oldphase': old, b'phase': phasenames[new]} |