annotate hgext/states.py @ 105:6300dd1c2df7

Add missing break line at the end of a debug message
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Mon, 28 Nov 2011 00:57:49 +0100
parents 5111329280f1
children 03bbce26553e
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
1 # states.py - introduce the state concept for mercurial changeset
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
2 #
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
3 # Copyright 2011 Pierre-Yves David <pierre-yves.david@ens-lyon.org>
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
4 # Logilab SA <contact@logilab.fr>
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
5 # Augie Fackler <durin42@gmail.com>
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
6 #
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
7 # This software may be used and distributed according to the terms of the
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
8 # GNU General Public License version 2 or any later version.
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
9
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
10 '''introduce the state concept for mercurial changeset
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
11
59
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
12 (see http://mercurial.selenic.com/wiki/StatesPlan)
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
13
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
14 General concept
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
15 ===============
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
16
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
17 This extension adds the state concept. A changeset are now in a specific state
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
18 that control they mutability and they exchange.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
19
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
20 States properties
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
21 .................
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
22
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
23 The states extension currently alter two property for changeset
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
24
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
25 :mutability: history rewritten tool should refuse to work on immutable changeset
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
26 :sharing: shared changeset are exchanged during pull and push. other are not
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
27
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
28 Here is a small summary of the current property of state existing state::
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
29
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
30 || || mutable || shared ||
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
31 || published || || x ||
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
32 || ready || x || x ||
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
33 || draft || x || ||
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
34
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
35 States consistency and ordering
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
36 ...............................
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
37
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
38 States of changesets have to be consistent with each other. A changeset can only have ancestors of it's state (or a compatible states)
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
39
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
40 Example:
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
41
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
42 A ``published`` changeset can't have a ``draft`` parent.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
43
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
44 a state is compatible with itself and all "smaller" states. Order is as follow::
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
45
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
46 published < ready < draft
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
47
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
48
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
49 .. note:
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
50
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
51 This section if probably far too conceptual for people. The result is just
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
52 that: A ``published`` changeset can only have ``published`` ancestors. A
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
53 ``ready`` changeset can only have ``published`` or ``ready`` ancestors.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
54
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
55 Moreover There is a need for a nice word to refer to "a state smaller than another"
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
56
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
57
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
58 States details
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
59 ==============
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
60
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
61
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
62 published
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
63 Changesets in the ``published`` state are the core of the history. They are
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
64 changesets that you published to the world. People can expect them to always
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
65 exist. They are changesets as you know them. **By default all changesets
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
66 are published**
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
67
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
68 - They are exchanged with other repositories (included in pull//push).
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
69
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
70 - They are not mutable, extensions rewriting history should refuse to
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
71 rewrite them.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
72
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
73 ready
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
74 Changesets in the ``ready`` state have not yet been accepted in the
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
75 immutable history. You can share them with others for review, testing or
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
76 improvement. Any ``ready`` changeset can either be included in the
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
77 published history (and become immutable) or be rewritten and never make it
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
78 to the published history.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
79
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
80 - They are exchanged with other repositories (included in pull//push).
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
81
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
82 - They are mutable, extensions rewriting history accept to work on them.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
83
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
84 draft
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
85
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
86 Changesets in the ``draft`` state are heavy work in progress you are not
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
87 yet willing to share with others.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
88
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
89 - They are not exchanged with other repositories. pull//push do not see them.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
90 - They are mutable, extensions rewriting history accept to work on them.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
91
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
92 --
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
93
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
94 .. note:
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
95
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
96 The Dead states mentionned in on the wiki page are missing. There is two main reason for it:
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
97
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
98 1. The ``dead`` state has a different behaviour that requires more work to be
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
99 implemented.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
100
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
101 2. I believe that the use cases of ``dead changeset`` are better covered by
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
102 the ``obsolete`` extension.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
103
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
104 --
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
105
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
106 .. note:
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
107
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
108 I'm tempted to add a state with the same property that ``ready`` for review
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
109 workflow.::
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
110
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
111 || || mutable || shared ||
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
112 || published || || x ||
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
113 || ready || x || x ||
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
114 || inprogress|| x || x ||
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
115 || draft || x || ||
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
116
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
117 The ``ready`` state would be for changeset that wait review of someone that
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
118 can "publish" them.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
119
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
120
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
121
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
122 Current Feature and usage
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
123 =========================
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
124
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
125
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
126 Enabling states
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
127 ...............
0
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
128
59
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
129 The extension adds a :hg:`hg states` command to display and choose which states
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
130 are used by a repository, see :hg:`hg states` for details.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
131
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
132 By default all changesets in the repository are ``published``. Other states
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
133 must be explicitly activated. Changeset in a remote repository that doesn't
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
134 support states are all seen as ``published``.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
135
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
136 .. note:
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
137
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
138 When a state is not activated, changesets in this state are handled as
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
139 changesets of the previous state it (``draft`` are handled as ``ready``,
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
140 ``ready`` are handled as ``published``).
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
141
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
142 TODO:
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
143
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
144 - have a configuration in hgrc::
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
145
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
146 [states]
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
147 ready=(off|on)(-inherit)?
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
148 <state>=(off|on)(-inherit)?
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
149
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
150 :off: state disabled for new repo
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
151 :on: state enabled for new repo
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
152 :inherit: if present, inherit states of source on :hg:`clone`.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
153
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
154 - display the number of changesets that change state when activating a state.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
155
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
156
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
157
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
158 State transition
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
159 ................
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
160
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
161 Changeset you create locally will be in the ``draft`` state. (or any previous
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
162 state if draft isn't enabled)
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
163
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
164 There is some situation where the state of a changeset will change
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
165 automatically. Automatic movement always go in the same direction.: ``draft ->
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
166 ``ready`` -> ``published``
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
167
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
168 1. When you pull or push boundary move. Common changeset that are ``published`` in
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
169 one of the two repository are set to ``published``. Same goes for ``ready`` etc
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
170 (states are evaluated from in increasing order XXX I bet no one understand this
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
171 parenthesis. Pull operation alter the local repository. push alter both local
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
172 and remote repository.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
173
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
174 .. note:
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
175
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
176 As Repository without any specific state have all their changeset
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
177 ``published``, Pushing to such repo will ``publish`` all common changeset.
59
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
178
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
179 2. Tagged changeset get automatically Published. The tagging changeset is
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
180 tagged too... This doesn't apply to local tag.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
181
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
182
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
183 You can also manually change changeset state with a dedicated command for each
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
184 state. See :hg:`published`, :hg:`ready` and :hg:`draft` for details.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
185
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
186 XXX maybe we can details the general behaviour here
0
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
187
59
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
188 :hg <state> revs: move boundary of state so it includes revs
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
189 ( revs included in ::<state>heads())
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
190 :hg --exact <state> revs: move boundary so that revs are exactly in state
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
191 <state> ( all([rev.state == <state> for rev in
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
192 revs]))
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
193 :hg --exact --force <state> revs: move boundary event if it create inconsistency
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
194 (with tag for example)
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
195
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
196 TODO:
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
197
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
198 - implement consistency check
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
199
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
200 - implement --force
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
201
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
202
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
203 Existing command change
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
204 .......................
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
205
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
206 As said in the previous section:
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
207
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
208 :commit: Create draft changeset (or the first enabled previous changeset).
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
209 :tag: Move tagged and tagging changeset in the ``published`` state.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
210 :incoming: Exclude ``draft`` changeset of remote repository.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
211 :outgoing: Exclude ``draft`` changeset of local repository.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
212 :pull: As :hg:`in` + change state of local changeset according to remote side.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
213 :push: As :hg:`out` + sync state of common changeset on both side
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
214 :rollback: rollback restore states heads as before the last transaction (see bookmark)
59
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
215
61
0dfe459c7b1c [states] add a small paragraph about controlling permision to move the boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 60
diff changeset
216 State Transition control
0dfe459c7b1c [states] add a small paragraph about controlling permision to move the boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 60
diff changeset
217 .........................
0dfe459c7b1c [states] add a small paragraph about controlling permision to move the boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 60
diff changeset
218
0dfe459c7b1c [states] add a small paragraph about controlling permision to move the boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 60
diff changeset
219 There is currently no way to control who can alter boundary (The most notable
0dfe459c7b1c [states] add a small paragraph about controlling permision to move the boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 60
diff changeset
220 usecase is about the published one).
0dfe459c7b1c [states] add a small paragraph about controlling permision to move the boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 60
diff changeset
221
0dfe459c7b1c [states] add a small paragraph about controlling permision to move the boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 60
diff changeset
222 This is probably needed quickly
0dfe459c7b1c [states] add a small paragraph about controlling permision to move the boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 60
diff changeset
223
0dfe459c7b1c [states] add a small paragraph about controlling permision to move the boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 60
diff changeset
224 XXX TODO: Proper behaviour when heads file are chmoded whould be a first step.
0dfe459c7b1c [states] add a small paragraph about controlling permision to move the boundary
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 60
diff changeset
225
76
e68f6821ae84 mention plan for hook in the documentation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 68
diff changeset
226 XXX We are going to need hooks (pre and post) hook on state transition too.
e68f6821ae84 mention plan for hook in the documentation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 68
diff changeset
227
59
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
228 Template
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
229 ........
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
230
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
231 A new template keyword ``{state}`` has been added.
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
232
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
233 Revset
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
234 ......
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
235
68
6f7824dbce24 [state] Update doc on the mutable property of state (and the way it's implemented)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 67
diff changeset
236 We add new ``readyheads()`` and ``publishedheads()`` revset directives. This
6f7824dbce24 [state] Update doc on the mutable property of state (and the way it's implemented)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 67
diff changeset
237 returns the heads of each state **as if all of them were activated**.
59
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
238
68
6f7824dbce24 [state] Update doc on the mutable property of state (and the way it's implemented)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 67
diff changeset
239 XXX TODO - I would like to
6f7824dbce24 [state] Update doc on the mutable property of state (and the way it's implemented)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 67
diff changeset
240
6f7824dbce24 [state] Update doc on the mutable property of state (and the way it's implemented)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 67
diff changeset
241 - move the current ``<state>heads()`` directives to
6f7824dbce24 [state] Update doc on the mutable property of state (and the way it's implemented)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 67
diff changeset
242 _``<state>heads()``
59
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
243
68
6f7824dbce24 [state] Update doc on the mutable property of state (and the way it's implemented)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 67
diff changeset
244 - add ``<state>heads()`` directives to that return the currently in used heads
6f7824dbce24 [state] Update doc on the mutable property of state (and the way it's implemented)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 67
diff changeset
245
6f7824dbce24 [state] Update doc on the mutable property of state (and the way it's implemented)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 67
diff changeset
246 - add ``<state>()`` directives that match all node in a state.
59
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
247
68
6f7824dbce24 [state] Update doc on the mutable property of state (and the way it's implemented)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 67
diff changeset
248 Context
6f7824dbce24 [state] Update doc on the mutable property of state (and the way it's implemented)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 67
diff changeset
249 .......
59
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
250
68
6f7824dbce24 [state] Update doc on the mutable property of state (and the way it's implemented)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 67
diff changeset
251 The ``context`` class gain a new method ``states()`` that return a ``state`` object. The
6f7824dbce24 [state] Update doc on the mutable property of state (and the way it's implemented)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 67
diff changeset
252 most notable property of this states object are ```name`` and ``mutable``.
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
253
63
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
254 Other extensions
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
255 ................
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
256
64
6a7dc5ca05b8 [states] add mq support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 63
diff changeset
257 :rebase: can't rebase immutable changeset.
6a7dc5ca05b8 [states] add mq support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 63
diff changeset
258 :mq: can't qimport immutable changeset.
63
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
259
66
b1e64d8783f0 [states] add a todo related to MQ
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 65
diff changeset
260 TODO: publishing a changeset should qfinish mq patches.
b1e64d8783f0 [states] add a todo related to MQ
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 65
diff changeset
261
63
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
262
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
263
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
264 Implementation
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
265 ==============
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
266
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
267 State definition
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
268 ................
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
269
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
270 Conceptually:
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
271
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
272 The set of node in the states are defined by the set of the state heads. This allow
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
273 easy storage, exchange and consistency.
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
274
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
275 .. note: A cache of the complete set of node that belong to a states will
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
276 probably be need for performance.
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
277
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
278 Code wise:
59
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
279
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
280 There is a ``state`` class that hold the state property and several useful
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
281 logic (name, revset entry etc).
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
282
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
283 All defined states are accessible thought the STATES tuple at the ROOT of the
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
284 module. Or the STATESMAP dictionary that allow to fetch a state from it's
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
285 name.
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
286
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
287 You can get and edit the list head node that define a state with two methods on
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
288 repo.
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
289
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
290 :stateheads(<state>): Returns the list of heads node that define a states
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
291 :setstate(<state>, [nodes]): Move states boundary forward to include the given
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
292 nodes in the given states.
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
293
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
294 Those methods handle ``node`` and not rev as it seems more resilient to me that
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
295 rev in a mutable world. Maybe it' would make more sens to have ``node`` store
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
296 on disk but revision in the code.
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
297
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
298 Storage
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
299 .......
59
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
300
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
301 States related data are stored in the ``.hg/states/`` directory.
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
302
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
303 The ``.hg/states/Enabled`` file list the states enabled in this
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
304 repository. This data is *not* stored in the .hg/hgrc because the .hg/hgrc
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
305 might be ignored for trust reason. As missing und with states can be pretty
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
306 annoying. (publishing unfinalized changeset, pulling draft one etc) we don't
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
307 want trust issue to interfer with enabled states information.
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
308
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
309 ``.hg/states/<state>-heads`` file list the nodes that define a states.
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
310
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
311 _NOSHARE filtering
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
312 ..................
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
313
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
314 Any changeset in a state with a _NOSHARE property will be exclude from pull,
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
315 push, clone, incoming, outgoing and bundle. It is done through three mechanism:
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
316
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
317 1. Wrapping the findcommonincoming and findcommonoutgoing code with (not very
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
318 efficient) logic that recompute the exchanged heads.
59
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
319
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
320 2. Altering ``heads`` wireprotocol command to return sharead heads.
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
321
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
322 3. Disabling hardlink cloning when there is _NOSHARE changeset available.
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
323
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
324 Internal plumbery
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
325 -----------------
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
326
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
327 sum up of what we do:
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
328
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
329 * state are object
59
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
330
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
331 * repo.__class__ is extended
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
332
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
333 * discovery is wrapped up
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
334
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
335 * wire protocol is patched
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
336
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
337 * transaction and rollback mechanism are wrapped up.
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
338
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
339 * XXX we write new version of the boundard whenever something happen. We need a
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
340 smarter and faster way to do this.
59
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
341
02fba620d139 move part of the readme about states in states itself.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 57
diff changeset
342
0
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
343 '''
23
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
344 import os
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
345 from functools import partial
102
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
346 from operator import or_
23
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
347
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
348 from mercurial.i18n import _
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
349 from mercurial import cmdutil
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
350 from mercurial import scmutil
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
351 from mercurial import context
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
352 from mercurial import revset
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
353 from mercurial import templatekw
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
354 from mercurial import util
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
355 from mercurial import node
9
1f84a74df837 introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 7
diff changeset
356 from mercurial.node import nullid, hex, short
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
357 from mercurial import discovery
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
358 from mercurial import extensions
7
cc592295900f Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5
diff changeset
359 from mercurial import wireproto
21
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
360 from mercurial import pushkey
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
361 from mercurial import error
102
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
362 from mercurial import repair
23
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
363 from mercurial.lock import release
0
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
364
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
365
102
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
366
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
367 # states property constante
10
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
368 _NOSHARE=2
9
1f84a74df837 introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 7
diff changeset
369 _MUTABLE=1
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
370
10
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
371 class state(object):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
372 """State of changeset
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
373
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
374 An utility object that handle several behaviour and containts useful code
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
375
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
376 A state is defined by:
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
377 - It's name
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
378 - It's property (defined right above)
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
379
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
380 - It's next state.
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
381
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
382 XXX maybe we could stick description of the state semantic here.
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
383 """
10
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
384
67
e62ffb77bf8c [state] add mutable property to state object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 66
diff changeset
385 # plumbery utily
19
8784a989a572 introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18
diff changeset
386 def __init__(self, name, properties=0, next=None):
10
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
387 self.name = name
19
8784a989a572 introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18
diff changeset
388 self.properties = properties
10
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
389 assert next is None or self < next
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
390 self.next = next
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
391 @util.propertycache
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
392 def trackheads(self):
11
47ba990eff0e update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 10
diff changeset
393 """Do we need to track heads of changeset in this state ?
47ba990eff0e update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 10
diff changeset
394
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
395 We don't need to track heads for the last state as this is repo heads"""
10
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
396 return self.next is not None
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
397
67
e62ffb77bf8c [state] add mutable property to state object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 66
diff changeset
398 # public utility
10
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
399 def __cmp__(self, other):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
400 """Use property to compare states.
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
401
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
402 This is a naiv approach that assume the the next state are strictly
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
403 more property than the one before
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
404 # assert min(self, other).properties = self.properties & other.properties
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
405 """
19
8784a989a572 introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18
diff changeset
406 return cmp(self.properties, other.properties)
0
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
407
68
6f7824dbce24 [state] Update doc on the mutable property of state (and the way it's implemented)
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 67
diff changeset
408 @property
67
e62ffb77bf8c [state] add mutable property to state object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 66
diff changeset
409 def mutable(self):
e62ffb77bf8c [state] add mutable property to state object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 66
diff changeset
410 return bool(self.properties & _MUTABLE)
e62ffb77bf8c [state] add mutable property to state object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 66
diff changeset
411
e62ffb77bf8c [state] add mutable property to state object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 66
diff changeset
412 # display code
e62ffb77bf8c [state] add mutable property to state object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 66
diff changeset
413 def __repr__(self):
e62ffb77bf8c [state] add mutable property to state object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 66
diff changeset
414 return 'state(%s)' % self.name
e62ffb77bf8c [state] add mutable property to state object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 66
diff changeset
415
e62ffb77bf8c [state] add mutable property to state object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 66
diff changeset
416 def __str__(self):
e62ffb77bf8c [state] add mutable property to state object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 66
diff changeset
417 return self.name
e62ffb77bf8c [state] add mutable property to state object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 66
diff changeset
418
e62ffb77bf8c [state] add mutable property to state object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 66
diff changeset
419
e62ffb77bf8c [state] add mutable property to state object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 66
diff changeset
420 # revset utility
e62ffb77bf8c [state] add mutable property to state object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 66
diff changeset
421 @util.propertycache
10
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
422 def _revsetheads(self):
11
47ba990eff0e update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 10
diff changeset
423 """function to be used by revset to finds heads of this states"""
10
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
424 assert self.trackheads
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
425 def revsetheads(repo, subset, x):
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
426 args = revset.getargs(x, 0, 0, 'publicheads takes no arguments')
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
427 heads = []
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
428 for h in repo._statesheads[self]:
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
429 try:
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
430 heads.append(repo.changelog.rev(h))
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
431 except error.LookupError:
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
432 pass
10
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
433 heads.sort()
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
434 return heads
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
435 return revsetheads
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
436
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
437 @util.propertycache
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
438 def headssymbol(self):
11
47ba990eff0e update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 10
diff changeset
439 """name of the revset symbols"""
10
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
440 if self.trackheads:
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
441 return "%sheads" % self.name
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
442 else:
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
443 return 'heads'
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
444
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
445 # Actual state definition
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
446
12
6312fc525a54 rename state related attributes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 11
diff changeset
447 ST2 = state('draft', _NOSHARE | _MUTABLE)
6312fc525a54 rename state related attributes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 11
diff changeset
448 ST1 = state('ready', _MUTABLE, next=ST2)
6312fc525a54 rename state related attributes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 11
diff changeset
449 ST0 = state('published', next=ST1)
10
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
450
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
451 # all available state
12
6312fc525a54 rename state related attributes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 11
diff changeset
452 STATES = (ST0, ST1, ST2)
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
453 # all available state by name
55
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
454 STATESMAP =dict([(st.name, st) for st in STATES])
0
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
455
21
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
456 @util.cachefunc
19
8784a989a572 introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18
diff changeset
457 def laststatewithout(prop):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
458 """Find the states with the most property but <prop>
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
459
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
460 (This function is necessary because the whole state stuff are abstracted)"""
19
8784a989a572 introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18
diff changeset
461 for state in STATES:
8784a989a572 introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18
diff changeset
462 if not state.properties & prop:
8784a989a572 introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18
diff changeset
463 candidate = state
8784a989a572 introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18
diff changeset
464 else:
8784a989a572 introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18
diff changeset
465 return candidate
8784a989a572 introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18
diff changeset
466
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
467 # util function
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
468 #############################
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
469 def noderange(repo, revsets):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
470 """The same as revrange but return node"""
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
471 return map(repo.changelog.node,
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
472 scmutil.revrange(repo, revsets))
0
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
473
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
474 # Patch changectx
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
475 #############################
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
476
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
477 def state(ctx):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
478 """return the state objet associated to the context"""
27
31906bc290ff Working directory is draft.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 26
diff changeset
479 if ctx.node()is None:
31906bc290ff Working directory is draft.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 26
diff changeset
480 return STATES[-1]
0
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
481 return ctx._repo.nodestate(ctx.node())
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
482 context.changectx.state = state
0
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
483
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
484 # improve template
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
485 #############################
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
486
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
487 def showstate(ctx, **args):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
488 """Show the name of the state associated with the context"""
0
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
489 return ctx.state()
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
490
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
491
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
492 # New commands
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
493 #############################
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
494
26
c9da15600775 add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 25
diff changeset
495
c9da15600775 add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 25
diff changeset
496 def cmdstates(ui, repo, *states, **opt):
33
dca86448d736 Add some doc.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 31
diff changeset
497 """view and modify activated states.
dca86448d736 Add some doc.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 31
diff changeset
498
dca86448d736 Add some doc.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 31
diff changeset
499 With no argument, list activated state.
dca86448d736 Add some doc.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 31
diff changeset
500
dca86448d736 Add some doc.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 31
diff changeset
501 With argument, activate the state in argument.
dca86448d736 Add some doc.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 31
diff changeset
502
dca86448d736 Add some doc.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 31
diff changeset
503 With argument plus the --off switch, deactivate the state in argument.
dca86448d736 Add some doc.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 31
diff changeset
504
dca86448d736 Add some doc.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 31
diff changeset
505 note: published state are alway activated."""
dca86448d736 Add some doc.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 31
diff changeset
506
26
c9da15600775 add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 25
diff changeset
507 if not states:
c9da15600775 add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 25
diff changeset
508 for st in sorted(repo._enabledstates):
c9da15600775 add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 25
diff changeset
509 ui.write('%s\n' % st)
c9da15600775 add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 25
diff changeset
510 else:
c9da15600775 add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 25
diff changeset
511 off = opt.get('off', False)
c9da15600775 add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 25
diff changeset
512 for state_name in states:
c9da15600775 add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 25
diff changeset
513 for st in STATES:
c9da15600775 add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 25
diff changeset
514 if st.name == state_name:
c9da15600775 add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 25
diff changeset
515 break
c9da15600775 add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 25
diff changeset
516 else:
c9da15600775 add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 25
diff changeset
517 ui.write_err(_('no state named %s\n') % state_name)
c9da15600775 add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 25
diff changeset
518 return 1
90
a5f6194eb05c [states] do not activate deactivated state with ``hg states --off <state>``
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 83
diff changeset
519 if off:
a5f6194eb05c [states] do not activate deactivated state with ``hg states --off <state>``
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 83
diff changeset
520 if st in repo._enabledstates:
97
e672cb1263cb [states] make disabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 96
diff changeset
521 repo.disablestate(st)
90
a5f6194eb05c [states] do not activate deactivated state with ``hg states --off <state>``
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 83
diff changeset
522 else:
a5f6194eb05c [states] do not activate deactivated state with ``hg states --off <state>``
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 83
diff changeset
523 ui.write_err(_('state %s already deactivated\n') %
a5f6194eb05c [states] do not activate deactivated state with ``hg states --off <state>``
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 83
diff changeset
524 state_name)
a5f6194eb05c [states] do not activate deactivated state with ``hg states --off <state>``
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 83
diff changeset
525
26
c9da15600775 add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 25
diff changeset
526 else:
98
8ad5c760c708 [states] make enabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 97
diff changeset
527 repo.enablestate(st, not opt.get('clever'))
26
c9da15600775 add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 25
diff changeset
528 repo._writeenabledstates()
c9da15600775 add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 25
diff changeset
529 return 0
c9da15600775 add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 25
diff changeset
530
98
8ad5c760c708 [states] make enabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 97
diff changeset
531 cmdtable = {'states': (cmdstates, [
8ad5c760c708 [states] make enabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 97
diff changeset
532 ('', 'off', False, _('desactivate the state') ),
8ad5c760c708 [states] make enabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 97
diff changeset
533 ('', 'clever', False, _('do not fix lower when activating the state') )],
8ad5c760c708 [states] make enabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 97
diff changeset
534 '<state>')}
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
535
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
536 # automatic generation of command that set state
18
9ffe946febc0 Autogenerate command table.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17
diff changeset
537 def makecmd(state):
96
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
538 def cmdmoveheads(ui, repo, *changesets, **opts):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
539 """set revisions in %s state
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
540
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
541 This command also alter state of ancestors if necessary.
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
542 """ % state
96
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
543 if not state in repo._enabledstates:
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
544 raise error.Abort(
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
545 _('state %s is not activated' % state),
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
546 hint=_('try ``hg states %s`` before' % state))
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
547 if opts.get('exact'):
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
548 repo.setstate_unsafe(state, changesets)
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
549 return 0
18
9ffe946febc0 Autogenerate command table.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17
diff changeset
550 revs = scmutil.revrange(repo, changesets)
9ffe946febc0 Autogenerate command table.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17
diff changeset
551 repo.setstate(state, [repo.changelog.node(rev) for rev in revs])
9ffe946febc0 Autogenerate command table.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17
diff changeset
552 return 0
9ffe946febc0 Autogenerate command table.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17
diff changeset
553 return cmdmoveheads
24
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
554
18
9ffe946febc0 Autogenerate command table.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 17
diff changeset
555 for state in STATES:
96
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
556 cmdmoveheads = makecmd(state)
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
557 cmdtable[state.name] = (cmdmoveheads, [
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
558 ('e', 'exact', False, _('move boundary so that revs are exactly in '
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
559 'state <state> ( all([rev.state == <state> for '
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
560 'rev in revs]))'))
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
561 ], '<revset>')
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
562
21
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
563 # Pushkey mechanism for mutable
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
564 #########################################
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
565
55
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
566 def pushstatesheads(repo, key, old, new):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
567 """receive a new state for a revision via pushkey
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
568
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
569 It only move revision from a state to a <= one
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
570
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
571 Return True if the <key> revision exist in the repository
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
572 Return False otherwise. (and doesn't alter any state)"""
55
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
573 st = STATESMAP[new]
21
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
574 w = repo.wlock()
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
575 try:
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
576 newhead = node.bin(key)
57
62f2fe22bd42 Use dedicated mechanism to report pushkey success
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 55
diff changeset
577 try:
62f2fe22bd42 Use dedicated mechanism to report pushkey success
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 55
diff changeset
578 repo[newhead]
62f2fe22bd42 Use dedicated mechanism to report pushkey success
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 55
diff changeset
579 except error.RepoLookupError:
62f2fe22bd42 Use dedicated mechanism to report pushkey success
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 55
diff changeset
580 return False
55
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
581 repo.setstate(st, [newhead])
57
62f2fe22bd42 Use dedicated mechanism to report pushkey success
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 55
diff changeset
582 return True
21
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
583 finally:
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
584 w.release()
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
585
55
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
586 def liststatesheads(repo):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
587 """List the boundary of all states.
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
588
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
589 {"node-hex" -> "comma separated list of state",}
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
590 """
55
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
591 keys = {}
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
592 for state in [st for st in STATES if st.trackheads]:
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
593 for head in repo.stateheads(state):
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
594 head = node.hex(head)
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
595 if head in keys:
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
596 keys[head] += ',' + state.name
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
597 else:
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
598 keys[head] = state.name
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
599 return keys
21
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
600
55
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
601 pushkey.register('states-heads', pushstatesheads, liststatesheads)
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
602
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
603
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
604 # Wrap discovery
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
605 ####################
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
606 def filterprivateout(orig, repo, *args,**kwargs):
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
607 """wrapper for findcommonoutgoing that remove _NOSHARE"""
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
608 common, heads = orig(repo, *args, **kwargs)
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
609 if getattr(repo, '_reducehead', None) is not None:
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
610 return common, repo._reducehead(heads)
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
611 def filterprivatein(orig, repo, remote, *args, **kwargs):
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
612 """wrapper for findcommonincoming that remove _NOSHARE"""
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
613 common, anyinc, heads = orig(repo, remote, *args, **kwargs)
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
614 if getattr(remote, '_reducehead', None) is not None:
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
615 heads = remote._reducehead(heads)
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
616 return common, anyinc, heads
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
617
62
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
618 # states boundary IO
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
619 #####################
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
620
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
621 def _readheadsfile(repo, filename):
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
622 """read head from the given file
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
623
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
624 XXX move me elsewhere"""
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
625 heads = [nullid]
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
626 try:
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
627 f = repo.opener(filename)
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
628 try:
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
629 heads = sorted([node.bin(n) for n in f.read().split() if n])
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
630 finally:
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
631 f.close()
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
632 except IOError:
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
633 pass
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
634 return heads
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
635
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
636 def _readstatesheads(repo, undo=False):
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
637 """read all state heads
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
638
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
639 XXX move me elsewhere"""
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
640 statesheads = {}
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
641 for state in STATES:
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
642 if state.trackheads:
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
643 filemask = 'states/%s-heads'
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
644 filename = filemask % state.name
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
645 statesheads[state] = _readheadsfile(repo, filename)
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
646 return statesheads
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
647
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
648 def _writeheadsfile(repo, filename, heads):
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
649 """write given <heads> in the file with at <filename>
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
650
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
651 XXX move me elsewhere"""
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
652 f = repo.opener(filename, 'w', atomictemp=True)
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
653 try:
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
654 for h in heads:
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
655 f.write(hex(h) + '\n')
83
97a5c943db19 Compat with mercurial 1.9.2
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 78
diff changeset
656 try:
97a5c943db19 Compat with mercurial 1.9.2
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 78
diff changeset
657 f.rename()
97a5c943db19 Compat with mercurial 1.9.2
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 78
diff changeset
658 except AttributeError: # old version
97a5c943db19 Compat with mercurial 1.9.2
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 78
diff changeset
659 f.close()
62
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
660 finally:
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
661 f.close()
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
662
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
663 def _writestateshead(repo):
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
664 """write all heads
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
665
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
666 XXX move me elsewhere"""
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
667 # XXX transaction!
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
668 for state in STATES:
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
669 if state.trackheads:
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
670 filename = 'states/%s-heads' % state.name
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
671 _writeheadsfile(repo, filename, repo._statesheads[state])
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
672
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
673 # WireProtocols
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
674 ####################
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
675 def wireheads(repo, proto):
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
676 """Altered head command that doesn't include _NOSHARE
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
677
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
678 This is a write protocol command"""
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
679 st = laststatewithout(_NOSHARE)
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
680 h = repo.stateheads(st)
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
681 return wireproto.encodelist(h) + "\n"
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
682
63
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
683 # Other extension support
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
684 #########################
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
685
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
686 def wraprebasebuildstate(orig, repo, *args, **kwargs):
78
ddcc4bb6c4d4 [states] add some documentation for extension wrapping
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 77
diff changeset
687 """Wrapped rebuild state that check for immutable changeset
ddcc4bb6c4d4 [states] add some documentation for extension wrapping
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 77
diff changeset
688
ddcc4bb6c4d4 [states] add some documentation for extension wrapping
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 77
diff changeset
689 buildstate are the best place i found to hook :-/"""
ddcc4bb6c4d4 [states] add some documentation for extension wrapping
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 77
diff changeset
690 result = orig(repo, *args, **kwargs)
ddcc4bb6c4d4 [states] add some documentation for extension wrapping
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 77
diff changeset
691 if result is not None:
65
7c8f992d567e [states] fix a bug with rebase --detach
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 64
diff changeset
692 # rebase.nullmerge is issued in the detach case
7c8f992d567e [states] fix a bug with rebase --detach
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 64
diff changeset
693 rebase = extensions.find('rebase')
7c8f992d567e [states] fix a bug with rebase --detach
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 64
diff changeset
694 rebased = [rev for rev, rbst in result[2].items() if rbst != rebase.nullmerge]
7c8f992d567e [states] fix a bug with rebase --detach
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 64
diff changeset
695 base = repo.changelog.node(min(rebased))
63
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
696 state = repo.nodestate(base)
67
e62ffb77bf8c [state] add mutable property to state object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 66
diff changeset
697 if not state.mutable:
63
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
698 raise util.Abort(_('can not rebase published changeset %s')
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
699 % node.short(base),
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
700 hint=_('see `hg help --extension states` for details'))
78
ddcc4bb6c4d4 [states] add some documentation for extension wrapping
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 77
diff changeset
701 return result
63
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
702
64
6a7dc5ca05b8 [states] add mq support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 63
diff changeset
703 def wrapmqqimport(orig, queue, repo, *args, **kwargs):
78
ddcc4bb6c4d4 [states] add some documentation for extension wrapping
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 77
diff changeset
704 """Wrapper for rebuild state that deny importing immutable changeset
ddcc4bb6c4d4 [states] add some documentation for extension wrapping
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 77
diff changeset
705 """
ddcc4bb6c4d4 [states] add some documentation for extension wrapping
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 77
diff changeset
706 if 'rev' in kwargs:
77
45afdbf062f4 [states] update qimport code so it doesn't fails on qimport without -r
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 76
diff changeset
707 # we can take the min as non linear import will break
45afdbf062f4 [states] update qimport code so it doesn't fails on qimport without -r
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 76
diff changeset
708 # anyway
45afdbf062f4 [states] update qimport code so it doesn't fails on qimport without -r
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 76
diff changeset
709 revs = scmutil.revrange(repo, kwargs['rev'])
45afdbf062f4 [states] update qimport code so it doesn't fails on qimport without -r
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 76
diff changeset
710 if revs:
45afdbf062f4 [states] update qimport code so it doesn't fails on qimport without -r
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 76
diff changeset
711 base = min(revs)
45afdbf062f4 [states] update qimport code so it doesn't fails on qimport without -r
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 76
diff changeset
712 basenode = repo.changelog.node(base)
45afdbf062f4 [states] update qimport code so it doesn't fails on qimport without -r
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 76
diff changeset
713 state = repo.nodestate(basenode)
45afdbf062f4 [states] update qimport code so it doesn't fails on qimport without -r
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 76
diff changeset
714 if not state.mutable:
45afdbf062f4 [states] update qimport code so it doesn't fails on qimport without -r
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 76
diff changeset
715 raise util.Abort(_('can not qimport published changeset %s')
45afdbf062f4 [states] update qimport code so it doesn't fails on qimport without -r
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 76
diff changeset
716 % node.short(basenode),
45afdbf062f4 [states] update qimport code so it doesn't fails on qimport without -r
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 76
diff changeset
717 hint=_('see `hg help --extension states` for details'))
78
ddcc4bb6c4d4 [states] add some documentation for extension wrapping
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 77
diff changeset
718 return orig(queue, repo, *args, **kwargs)
64
6a7dc5ca05b8 [states] add mq support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 63
diff changeset
719
102
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
720 def strip(orig, ui, repo, node, backup="all"):
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
721 cl = repo.changelog
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
722 striprev = cl.rev(node)
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
723 revstostrip = set(cl.descendants(striprev))
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
724 revstostrip.add(striprev)
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
725 tostrip = set(map(cl.node, revstostrip))
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
726 # compute the potentially new created states bondaries which are any
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
727 # parent of the stripped node that are not stripped (may not be heads)
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
728 newbondaries = set(par for nod in tostrip for par in cl.parents(nod)
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
729 if par not in tostrip)
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
730 # save the current states of newbondaries in a chache as repo.nodestate
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
731 # must work along the loop. We will use the next loop to add them.
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
732 statesheads={}
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
733 for nd in newbondaries:
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
734 state = repo.nodestate(nd)
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
735 if state.trackheads:
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
736 statesheads.setdefault(state, set([])).add(nd)
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
737
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
738 for state, heads in repo._statesheads.iteritems():
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
739 if not state.trackheads:
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
740 continue
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
741 heads = set(heads) - tostrip | statesheads.get(state, set([]))
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
742 # reduce heads (make them really heads)
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
743 revs = set(map(cl.rev, heads))
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
744 minrev = min(revs)
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
745 for rev in cl.ancestors(*revs):
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
746 if rev >= minrev:
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
747 revs.discard(rev)
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
748 repo._statesheads[state] = map(cl.node, revs)
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
749 _writestateshead(repo)
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
750
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
751 return orig(ui, repo, node, backup)
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
752
63
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
753
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
754 def uisetup(ui):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
755 """
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
756 * patch stuff for the _NOSHARE property
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
757 * add template keyword
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
758 """
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
759 # patch discovery
2
166694e62daf hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 1
diff changeset
760 extensions.wrapfunction(discovery, 'findcommonoutgoing', filterprivateout)
166694e62daf hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 1
diff changeset
761 extensions.wrapfunction(discovery, 'findcommonincoming', filterprivatein)
102
5111329280f1 monkeypatch strip fancier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 101
diff changeset
762 extensions.wrapfunction(repair, 'strip', strip)
0
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
763
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
764 # patch wireprotocol
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
765 wireproto.commands['heads'] = (wireheads, '')
7
cc592295900f Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 5
diff changeset
766
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
767 # add template keyword
17
6aa349f47e7c add templatekeyword in a proper location
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 16
diff changeset
768 templatekw.keywords['state'] = showstate
6aa349f47e7c add templatekeyword in a proper location
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 16
diff changeset
769
14
f5e1055a3f68 reorder extsetup
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 13
diff changeset
770 def extsetup(ui):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
771 """Extension setup
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
772
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
773 * add revset entry"""
14
f5e1055a3f68 reorder extsetup
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 13
diff changeset
774 for state in STATES:
f5e1055a3f68 reorder extsetup
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 13
diff changeset
775 if state.trackheads:
f5e1055a3f68 reorder extsetup
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 13
diff changeset
776 revset.symbols[state.headssymbol] = state._revsetheads
64
6a7dc5ca05b8 [states] add mq support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 63
diff changeset
777 # wrap rebase
63
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
778 try:
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
779 rebase = extensions.find('rebase')
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
780 if rebase:
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
781 extensions.wrapfunction(rebase, 'buildstate', wraprebasebuildstate)
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
782 except KeyError:
f47a5f990eb2 [states] add rebase support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 62
diff changeset
783 pass # rebase not found
64
6a7dc5ca05b8 [states] add mq support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 63
diff changeset
784 # wrap mq
6a7dc5ca05b8 [states] add mq support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 63
diff changeset
785 try:
6a7dc5ca05b8 [states] add mq support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 63
diff changeset
786 mq = extensions.find('mq')
6a7dc5ca05b8 [states] add mq support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 63
diff changeset
787 if mq:
6a7dc5ca05b8 [states] add mq support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 63
diff changeset
788 extensions.wrapfunction(mq.queue, 'qimport', wrapmqqimport)
6a7dc5ca05b8 [states] add mq support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 63
diff changeset
789 except KeyError:
6a7dc5ca05b8 [states] add mq support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 63
diff changeset
790 pass # mq not found
14
f5e1055a3f68 reorder extsetup
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 13
diff changeset
791
62
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
792
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
793
0
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
794 def reposetup(ui, repo):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
795 """Repository setup
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
796
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
797 * extend repo class with states logic"""
0
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
798
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
799 if not repo.local():
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
800 return
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
801
21
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
802 ocancopy =repo.cancopy
22
93dd72d028a1 Automatically publish on tag.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 21
diff changeset
803 opull = repo.pull
93dd72d028a1 Automatically publish on tag.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 21
diff changeset
804 opush = repo.push
93dd72d028a1 Automatically publish on tag.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 21
diff changeset
805 o_tag = repo._tag
23
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
806 orollback = repo.rollback
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
807 o_writejournal = repo._writejournal
0
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
808 class statefulrepo(repo.__class__):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
809 """An extension of repo class that handle state logic
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
810
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
811 - nodestate
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
812 - stateheads
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
813 """
0
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
814
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
815 def nodestate(self, node):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
816 """return the state object associated to the given node"""
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
817 rev = self.changelog.rev(node)
29
52c227772dad fix nodestate computation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 28
diff changeset
818 for state in STATES:
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
819 # avoid for untracked heads
13
e95e8cf7988f Get ride of dedicated heads property.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 12
diff changeset
820 if state.next is not None:
30
a2189159e92f fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 29
diff changeset
821 ancestors = map(self.changelog.rev, self.stateheads(state))
a2189159e92f fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 29
diff changeset
822 ancestors.extend(self.changelog.ancestors(*ancestors))
a2189159e92f fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 29
diff changeset
823 if rev in ancestors:
29
52c227772dad fix nodestate computation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 28
diff changeset
824 break
13
e95e8cf7988f Get ride of dedicated heads property.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 12
diff changeset
825 return state
0
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
826
98
8ad5c760c708 [states] make enabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 97
diff changeset
827 def enablestate(self, state, fix_lower=True):
8ad5c760c708 [states] make enabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 97
diff changeset
828 if fix_lower:
8ad5c760c708 [states] make enabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 97
diff changeset
829 # at least published which is always activated
8ad5c760c708 [states] make enabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 97
diff changeset
830 lower = max(st for st in self._enabledstates if st < state)
8ad5c760c708 [states] make enabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 97
diff changeset
831 self.setstate(lower, self.stateheads(state))
8ad5c760c708 [states] make enabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 97
diff changeset
832 self._enabledstates.add(state)
8ad5c760c708 [states] make enabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 97
diff changeset
833
97
e672cb1263cb [states] make disabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 96
diff changeset
834 def disablestate(self, state):
e672cb1263cb [states] make disabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 96
diff changeset
835 """Disable empty state.
e672cb1263cb [states] make disabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 96
diff changeset
836 Raise error.Abort if the state is not empty.
e672cb1263cb [states] make disabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 96
diff changeset
837 """
e672cb1263cb [states] make disabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 96
diff changeset
838 # the lowest is mandatory
e672cb1263cb [states] make disabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 96
diff changeset
839 if state == ST0:
e672cb1263cb [states] make disabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 96
diff changeset
840 raise error.Abort(_('could not disable %s' % state.name))
e672cb1263cb [states] make disabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 96
diff changeset
841 enabled = self._enabledstates
e672cb1263cb [states] make disabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 96
diff changeset
842 # look up for lower state that is enabled (at least published)
e672cb1263cb [states] make disabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 96
diff changeset
843 lower = max(st for st in self._enabledstates if st < state)
e672cb1263cb [states] make disabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 96
diff changeset
844 if repo.stateheads(state) != repo.stateheads(lower):
e672cb1263cb [states] make disabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 96
diff changeset
845 raise error.Abort(
e672cb1263cb [states] make disabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 96
diff changeset
846 _('could not disable non empty state %s' % state.name),
e672cb1263cb [states] make disabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 96
diff changeset
847 hint=_("You may want to use `hg %s '%sheads()'`"
e672cb1263cb [states] make disabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 96
diff changeset
848 % (lower.name, state.name))
e672cb1263cb [states] make disabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 96
diff changeset
849 )
e672cb1263cb [states] make disabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 96
diff changeset
850 else:
e672cb1263cb [states] make disabling state saftier
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 96
diff changeset
851 enabled.remove(state)
9
1f84a74df837 introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 7
diff changeset
852
13
e95e8cf7988f Get ride of dedicated heads property.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 12
diff changeset
853 def stateheads(self, state):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
854 """Return the set of head that define the state"""
20
9983f240ac63 Smarter states heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 19
diff changeset
855 # look for a relevant state
24
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
856 while state.trackheads and state.next not in self._enabledstates:
20
9983f240ac63 Smarter states heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 19
diff changeset
857 state = state.next
9983f240ac63 Smarter states heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 19
diff changeset
858 # last state have no cached head.
13
e95e8cf7988f Get ride of dedicated heads property.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 12
diff changeset
859 if state.trackheads:
20
9983f240ac63 Smarter states heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 19
diff changeset
860 return self._statesheads[state]
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
861 return self.heads()
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
862
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
863 @util.propertycache
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
864 def _statesheads(self):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
865 """{ state-object -> set(defining head)} mapping"""
62
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
866 return _readstatesheads(self)
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
867
96
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
868 def setstate_unsafe(self, state, changesets):
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
869 """Change state of targets changesets and it's ancestors.
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
870
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
871 Simplify the list of heads.
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
872
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
873 Unlike ``setstate``, the "lower" states are also changed
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
874 """
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
875 #modify "lower" states
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
876 req_nodes_rst = '|'.join('((%s)::)' % rst for rst in changesets)
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
877 for st in STATES:
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
878 if st >= state: # only modify lower state heads for now
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
879 continue
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
880 try:
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
881 heads = self._statesheads[st]
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
882 except KeyError: # forget non-activated states
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
883 continue
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
884 olds = heads[:]
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
885 rst = "heads((::%s()) - (%s))" % (st.headssymbol, req_nodes_rst)
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
886 heads[:] = noderange(repo, [rst])
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
887 if olds != heads:
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
888 _writestateshead(self)
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
889 #modify the state
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
890 if state in self._statesheads:
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
891 revs = scmutil.revrange(repo, changesets)
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
892 repo.setstate(state, [repo.changelog.node(rev) for rev in revs])
d5170cc7881c [states] add --exact option to `hg <state> <nodes>` that allows to backward states bondaries
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 90
diff changeset
893
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
894 def setstate(self, state, nodes):
21
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
895 """change state of targets changeset and it's ancestors.
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
896
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
897 Simplify the list of head."""
55
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
898 assert not isinstance(nodes, basestring), repr(nodes)
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
899 heads = self._statesheads[state]
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
900 olds = heads[:]
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
901 heads.extend(nodes)
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
902 heads[:] = set(heads)
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
903 heads.sort()
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
904 if olds != heads:
10
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
905 heads[:] = noderange(repo, ["heads(::%s())" % state.headssymbol])
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
906 heads.sort()
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
907 if olds != heads:
62
bd33e749dfcc [states] move IO logic outside the repository subclass
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 61
diff changeset
908 _writestateshead(self)
10
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
909 if state.next is not None and state.next.trackheads:
91169d2d7f1b state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 9
diff changeset
910 self.setstate(state.next, nodes) # cascading
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
911
2
166694e62daf hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 1
diff changeset
912 def _reducehead(self, candidates):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
913 """recompute a set of heads so it doesn't include _NOSHARE changeset
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
914
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
915 This is basically a complicated method that compute
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
916 heads(::candidates - _NOSHARE)
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
917 """
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
918 selected = set()
19
8784a989a572 introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18
diff changeset
919 st = laststatewithout(_NOSHARE)
30
a2189159e92f fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 29
diff changeset
920 candidates = set(map(self.changelog.rev, candidates))
a2189159e92f fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 29
diff changeset
921 heads = set(map(self.changelog.rev, self.stateheads(st)))
a2189159e92f fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 29
diff changeset
922 shareable = set(self.changelog.ancestors(*heads))
a2189159e92f fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 29
diff changeset
923 shareable.update(heads)
a2189159e92f fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 29
diff changeset
924 selected = candidates & shareable
a2189159e92f fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 29
diff changeset
925 unselected = candidates - shareable
a2189159e92f fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 29
diff changeset
926 for rev in unselected:
a2189159e92f fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 29
diff changeset
927 for revh in heads:
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
928 if self.changelog.descendant(revh, rev):
30
a2189159e92f fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 29
diff changeset
929 selected.add(revh)
a2189159e92f fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 29
diff changeset
930 return sorted(map(self.changelog.node, selected))
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
931
24
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
932 ### enable // disable logic
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
933
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
934 @util.propertycache
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
935 def _enabledstates(self):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
936 """The set of state enabled in this repository"""
24
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
937 return self._readenabledstates()
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
938
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
939 def _readenabledstates(self):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
940 """read enabled state from disk"""
24
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
941 states = set()
28
0918e3b54f0b published is always enabled.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 27
diff changeset
942 states.add(ST0)
24
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
943 mapping = dict([(st.name, st) for st in STATES])
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
944 try:
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
945 f = self.opener('states/Enabled')
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
946 for line in f:
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
947 st = mapping.get(line.strip())
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
948 if st is not None:
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
949 states.add(st)
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
950 finally:
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
951 return states
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
952
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
953 def _writeenabledstates(self):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
954 """read enabled state to disk"""
24
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
955 f = self.opener('states/Enabled', 'w', atomictemp=True)
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
956 try:
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
957 for st in self._enabledstates:
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
958 f.write(st.name + '\n')
83
97a5c943db19 Compat with mercurial 1.9.2
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 78
diff changeset
959 try:
97a5c943db19 Compat with mercurial 1.9.2
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 78
diff changeset
960 f.rename()
97a5c943db19 Compat with mercurial 1.9.2
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 78
diff changeset
961 except AttributeError: # old version
97a5c943db19 Compat with mercurial 1.9.2
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 78
diff changeset
962 f.close()
24
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
963 finally:
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
964 f.close()
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
965
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
966 ### local clone support
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
967
5
9445ce78a935 fix clone
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 2
diff changeset
968 def cancopy(self):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
969 """deny copy if there is _NOSHARE changeset"""
19
8784a989a572 introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 18
diff changeset
970 st = laststatewithout(_NOSHARE)
21
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
971 return ocancopy() and (self.stateheads(st) == self.heads())
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
972
24
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
973 ### pull // push support
20ac7fa3fd29 Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 23
diff changeset
974
21
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
975 def pull(self, remote, *args, **kwargs):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
976 """altered pull that also update states heads on local repo"""
21
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
977 result = opull(remote, *args, **kwargs)
55
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
978 remoteheads = self._pullstatesheads(remote)
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
979 for st, heads in remoteheads.iteritems():
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
980 self.setstate(st, heads)
21
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
981 return result
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
982
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
983 def push(self, remote, *args, **opts):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
984 """altered push that also update states heads on local and remote"""
21
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
985 result = opush(remote, *args, **opts)
55
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
986 remoteheads = self._pullstatesheads(remote)
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
987 for st, heads in remoteheads.iteritems():
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
988 self.setstate(st, heads)
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
989 if heads != self.stateheads(st):
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
990 self._pushstatesheads(remote, st, heads)
21
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
991 return result
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
992
55
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
993 def _pushstatesheads(self, remote, state, remoteheads):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
994 """push head of a given state for remote
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
995
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
996 This handle pushing boundary that does exist on remote host
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
997 This is done a very naive way"""
55
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
998 local = set(self.stateheads(state))
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
999 missing = local - set(remoteheads)
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
1000 while missing:
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
1001 h = missing.pop()
57
62f2fe22bd42 Use dedicated mechanism to report pushkey success
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 55
diff changeset
1002 ok = remote.pushkey('states-heads', node.hex(h), '', state.name)
62f2fe22bd42 Use dedicated mechanism to report pushkey success
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 55
diff changeset
1003 if not ok:
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
1004 missing.update(p.node() for p in repo[h].parents())
21
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
1005
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
1006
55
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
1007 def _pullstatesheads(self, remote):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
1008 """pull all remote states boundary locally
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
1009
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
1010 This can only make the boundary move on a newer changeset"""
55
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
1011 remoteheads = {}
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
1012 self.ui.debug('checking for states-heads on remote server')
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
1013 if 'states-heads' not in remote.listkeys('namespaces'):
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
1014 self.ui.debug('states-heads not enabled on the remote server, '
105
6300dd1c2df7 Add missing break line at the end of a debug message
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 102
diff changeset
1015 'marking everything as published\n')
55
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
1016 remoteheads[ST0] = remote.heads()
21
aa0870d093b8 Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 20
diff changeset
1017 else:
55
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
1018 self.ui.debug('server has states-heads enabled, merging lists')
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
1019 for hex, statenames in remote.listkeys('states-heads').iteritems():
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
1020 for stn in statenames.split(','):
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
1021 remoteheads.setdefault(STATESMAP[stn], []).append(node.bin(hex))
cf4626a13345 Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
1022 return remoteheads
5
9445ce78a935 fix clone
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 2
diff changeset
1023
23
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1024 ### Tag support
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1025
22
93dd72d028a1 Automatically publish on tag.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 21
diff changeset
1026 def _tag(self, names, node, *args, **kwargs):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
1027 """Altered version of _tag that make tag (and tagging) published"""
22
93dd72d028a1 Automatically publish on tag.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 21
diff changeset
1028 tagnode = o_tag(names, node, *args, **kwargs)
31
1fef89f56588 tag: do not publish for local tag.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 30
diff changeset
1029 if tagnode is not None: # do nothing for local one
1fef89f56588 tag: do not publish for local tag.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 30
diff changeset
1030 self.setstate(ST0, [node, tagnode])
22
93dd72d028a1 Automatically publish on tag.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 21
diff changeset
1031 return tagnode
93dd72d028a1 Automatically publish on tag.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 21
diff changeset
1032
23
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1033 ### rollback support
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1034
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1035 def _writejournal(self, desc):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
1036 """extended _writejournal that also save states"""
23
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1037 entries = list(o_writejournal(desc))
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1038 for state in STATES:
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1039 if state.trackheads:
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1040 filename = 'states/%s-heads' % state.name
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1041 filepath = self.join(filename)
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1042 if os.path.exists(filepath):
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1043 journalname = 'states/journal.%s-heads' % state.name
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1044 journalpath = self.join(journalname)
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1045 util.copyfile(filepath, journalpath)
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1046 entries.append(journalpath)
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1047 return tuple(entries)
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1048
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1049 def rollback(self, dryrun=False):
60
14a4499d2cd6 small refactoring and big doc update.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 59
diff changeset
1050 """extended rollback that also restore states"""
23
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1051 wlock = lock = None
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1052 try:
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1053 wlock = self.wlock()
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1054 lock = self.lock()
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1055 ret = orollback(dryrun)
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1056 if not (ret or dryrun): #rollback did not failed
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1057 for state in STATES:
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1058 if state.trackheads:
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1059 src = self.join('states/undo.%s-heads') % state.name
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1060 dest = self.join('states/%s-heads') % state.name
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1061 if os.path.exists(src):
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1062 util.rename(src, dest)
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1063 elif os.path.exists(dest): #unlink in any case
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1064 os.unlink(dest)
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1065 self.__dict__.pop('_statesheads', None)
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1066 return ret
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1067 finally:
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1068 release(lock, wlock)
423c62a146c7 add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 22
diff changeset
1069
0
bbeef801409c minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
1070 repo.__class__ = statefulrepo
1
beabde937e36 Add "private" concept (2). private changeset are hiden suppose to be hidden for
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 0
diff changeset
1071