Mercurial > evolve
annotate hgext/states.py @ 57:62f2fe22bd42
Use dedicated mechanism to report pushkey success
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Fri, 09 Sep 2011 11:15:44 +0200 |
parents | cf4626a13345 |
children | 02fba620d139 |
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 |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
12 Change can be in the following state: |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
13 |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
14 0 immutable |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
15 1 mutable |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
16 2 private |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
17 |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
18 name are not fixed yet. |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
19 ''' |
23
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
20 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
|
21 from functools import partial |
23
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
22 |
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
|
23 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
|
24 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
|
25 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
|
26 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
|
27 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
|
28 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
|
29 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
|
30 from mercurial import node |
9
1f84a74df837
introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7
diff
changeset
|
31 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
|
32 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
|
33 from mercurial import extensions |
7
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
34 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
|
35 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
|
36 from mercurial import error |
23
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
37 from mercurial.lock import release |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
38 |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
39 |
10
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
40 _NOSHARE=2 |
9
1f84a74df837
introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7
diff
changeset
|
41 _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
|
42 |
10
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
43 class state(object): |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
44 |
19
8784a989a572
introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18
diff
changeset
|
45 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
|
46 self.name = name |
19
8784a989a572
introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18
diff
changeset
|
47 self.properties = properties |
10
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
48 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
|
49 self.next = next |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
50 |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
51 def __repr__(self): |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
52 return 'state(%s)' % self.name |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
53 |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
54 def __str__(self): |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
55 return self.name |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
56 |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
57 @util.propertycache |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
58 def trackheads(self): |
11
47ba990eff0e
update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
10
diff
changeset
|
59 """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
|
60 |
47ba990eff0e
update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
10
diff
changeset
|
61 We don't need to track heads for the last state as this is repos heads""" |
10
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
62 return self.next is not None |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
63 |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
64 def __cmp__(self, other): |
19
8784a989a572
introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18
diff
changeset
|
65 return cmp(self.properties, other.properties) |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
66 |
10
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
67 @util.propertycache |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
68 def _revsetheads(self): |
11
47ba990eff0e
update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
10
diff
changeset
|
69 """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
|
70 assert self.trackheads |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
71 def revsetheads(repo, subset, x): |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
72 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
|
73 heads = [] |
ad1a4fb0fc49
Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
51
diff
changeset
|
74 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
|
75 try: |
ad1a4fb0fc49
Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
51
diff
changeset
|
76 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
|
77 except error.LookupError: |
ad1a4fb0fc49
Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
51
diff
changeset
|
78 pass |
10
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
79 heads.sort() |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
80 return heads |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
81 return revsetheads |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
82 |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
83 @util.propertycache |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
84 def headssymbol(self): |
11
47ba990eff0e
update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
10
diff
changeset
|
85 """name of the revset symbols""" |
10
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
86 if self.trackheads: |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
87 return "%sheads" % self.name |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
88 else: |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
89 return 'heads' |
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
90 |
12
6312fc525a54
rename state related attributes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
11
diff
changeset
|
91 ST2 = state('draft', _NOSHARE | _MUTABLE) |
6312fc525a54
rename state related attributes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
11
diff
changeset
|
92 ST1 = state('ready', _MUTABLE, next=ST2) |
6312fc525a54
rename state related attributes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
11
diff
changeset
|
93 ST0 = state('published', next=ST1) |
10
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
94 |
12
6312fc525a54
rename state related attributes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
11
diff
changeset
|
95 STATES = (ST0, ST1, ST2) |
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
|
96 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
|
97 |
21
aa0870d093b8
Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20
diff
changeset
|
98 @util.cachefunc |
19
8784a989a572
introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18
diff
changeset
|
99 def laststatewithout(prop): |
8784a989a572
introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18
diff
changeset
|
100 for state in STATES: |
8784a989a572
introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18
diff
changeset
|
101 if not state.properties & prop: |
8784a989a572
introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18
diff
changeset
|
102 candidate = state |
8784a989a572
introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18
diff
changeset
|
103 else: |
8784a989a572
introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18
diff
changeset
|
104 return candidate |
8784a989a572
introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18
diff
changeset
|
105 |
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
|
106 # 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
|
107 ############################# |
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
|
108 def noderange(repo, revsets): |
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
|
109 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
|
110 scmutil.revrange(repo, revsets)) |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
111 |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
112 # Patch changectx |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
113 ############################# |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
114 |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
115 def state(ctx): |
27
31906bc290ff
Working directory is draft.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
26
diff
changeset
|
116 if ctx.node()is None: |
31906bc290ff
Working directory is draft.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
26
diff
changeset
|
117 return STATES[-1] |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
118 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
|
119 context.changectx.state = state |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
120 |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
121 # improve template |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
122 ############################# |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
123 |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
124 def showstate(ctx, **args): |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
125 return ctx.state() |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
126 |
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
|
127 |
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
|
128 # 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
|
129 ############################# |
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
|
130 |
26
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
131 |
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
132 def cmdstates(ui, repo, *states, **opt): |
33
dca86448d736
Add some doc.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
31
diff
changeset
|
133 """view and modify activated states. |
dca86448d736
Add some doc.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
31
diff
changeset
|
134 |
dca86448d736
Add some doc.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
31
diff
changeset
|
135 With no argument, list activated state. |
dca86448d736
Add some doc.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
31
diff
changeset
|
136 |
dca86448d736
Add some doc.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
31
diff
changeset
|
137 With argument, activate the state in argument. |
dca86448d736
Add some doc.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
31
diff
changeset
|
138 |
dca86448d736
Add some doc.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
31
diff
changeset
|
139 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
|
140 |
dca86448d736
Add some doc.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
31
diff
changeset
|
141 note: published state are alway activated.""" |
dca86448d736
Add some doc.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
31
diff
changeset
|
142 |
26
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
143 if not states: |
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
144 for st in sorted(repo._enabledstates): |
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
145 ui.write('%s\n' % st) |
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
146 else: |
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
147 off = opt.get('off', False) |
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
148 for state_name in states: |
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
149 for st in STATES: |
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
150 if st.name == state_name: |
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
151 break |
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
152 else: |
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
153 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
|
154 return 1 |
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
155 if off and st in repo._enabledstates: |
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
156 repo._enabledstates.remove(st) |
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
157 else: |
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
158 repo._enabledstates.add(st) |
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
159 repo._writeenabledstates() |
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
160 return 0 |
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
161 |
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
162 cmdtable = {'states': (cmdstates, [ ('', 'off', False, _('desactivate the state') )], '<state>')} |
c9da15600775
add a states command
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
25
diff
changeset
|
163 #cmdtable = {'states': (cmdstates, [], '<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
|
164 |
18
9ffe946febc0
Autogenerate command table.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17
diff
changeset
|
165 def makecmd(state): |
9ffe946febc0
Autogenerate command table.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17
diff
changeset
|
166 def cmdmoveheads(ui, repo, *changesets): |
25
b372166d460d
Add docstring to move head command.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
24
diff
changeset
|
167 """set a revision in %s state""" % state |
18
9ffe946febc0
Autogenerate command table.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17
diff
changeset
|
168 revs = scmutil.revrange(repo, changesets) |
9ffe946febc0
Autogenerate command table.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17
diff
changeset
|
169 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
|
170 return 0 |
9ffe946febc0
Autogenerate command table.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17
diff
changeset
|
171 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
|
172 |
18
9ffe946febc0
Autogenerate command table.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17
diff
changeset
|
173 for state in STATES: |
9ffe946febc0
Autogenerate command table.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17
diff
changeset
|
174 if state.trackheads: |
9ffe946febc0
Autogenerate command table.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17
diff
changeset
|
175 cmdmoveheads = makecmd(state) |
9ffe946febc0
Autogenerate command table.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17
diff
changeset
|
176 cmdtable[state.name] = (cmdmoveheads, [], '<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
|
177 |
21
aa0870d093b8
Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20
diff
changeset
|
178 # 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
|
179 ######################################### |
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
|
180 |
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
|
181 def pushstatesheads(repo, key, old, new): |
cf4626a13345
Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
54
diff
changeset
|
182 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
|
183 w = repo.wlock() |
aa0870d093b8
Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20
diff
changeset
|
184 try: |
54
ad1a4fb0fc49
Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
51
diff
changeset
|
185 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
|
186 try: |
62f2fe22bd42
Use dedicated mechanism to report pushkey success
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
55
diff
changeset
|
187 repo[newhead] |
62f2fe22bd42
Use dedicated mechanism to report pushkey success
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
55
diff
changeset
|
188 except error.RepoLookupError: |
62f2fe22bd42
Use dedicated mechanism to report pushkey success
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
55
diff
changeset
|
189 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
|
190 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
|
191 return True |
21
aa0870d093b8
Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20
diff
changeset
|
192 finally: |
aa0870d093b8
Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20
diff
changeset
|
193 w.release() |
aa0870d093b8
Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20
diff
changeset
|
194 |
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
|
195 def liststatesheads(repo): |
cf4626a13345
Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
54
diff
changeset
|
196 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
|
197 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
|
198 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
|
199 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
|
200 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
|
201 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
|
202 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
|
203 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
|
204 return keys |
21
aa0870d093b8
Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20
diff
changeset
|
205 |
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
|
206 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
|
207 |
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
|
208 |
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
|
209 |
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
|
210 |
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
|
211 |
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
|
212 def uisetup(ui): |
2
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
213 def filterprivateout(orig, repo, *args,**kwargs): |
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
|
214 common, heads = orig(repo, *args, **kwargs) |
2
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
215 return common, repo._reducehead(heads) |
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
216 def filterprivatein(orig, repo, remote, *args, **kwargs): |
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
217 common, anyinc, heads = orig(repo, remote, *args, **kwargs) |
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
218 heads = remote._reducehead(heads) |
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
219 return common, anyinc, heads |
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
220 |
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
221 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
|
222 extensions.wrapfunction(discovery, 'findcommonincoming', filterprivatein) |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
223 |
7
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
224 # Write protocols |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
225 #################### |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
226 def heads(repo, proto): |
19
8784a989a572
introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18
diff
changeset
|
227 st = laststatewithout(_NOSHARE) |
8784a989a572
introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18
diff
changeset
|
228 h = repo.stateheads(st) |
7
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
229 return wireproto.encodelist(h) + "\n" |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
230 |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
231 def _reducehead(wirerepo, heads): |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
232 """heads filtering is done repo side""" |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
233 return heads |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
234 |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
235 wireproto.wirerepository._reducehead = _reducehead |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
236 wireproto.commands['heads'] = (heads, '') |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
237 |
17
6aa349f47e7c
add templatekeyword in a proper location
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
16
diff
changeset
|
238 templatekw.keywords['state'] = showstate |
6aa349f47e7c
add templatekeyword in a proper location
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
16
diff
changeset
|
239 |
14
f5e1055a3f68
reorder extsetup
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13
diff
changeset
|
240 def extsetup(ui): |
f5e1055a3f68
reorder extsetup
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13
diff
changeset
|
241 for state in STATES: |
f5e1055a3f68
reorder extsetup
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13
diff
changeset
|
242 if state.trackheads: |
f5e1055a3f68
reorder extsetup
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13
diff
changeset
|
243 revset.symbols[state.headssymbol] = state._revsetheads |
f5e1055a3f68
reorder extsetup
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
13
diff
changeset
|
244 |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
245 def reposetup(ui, repo): |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
246 |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
247 if not repo.local(): |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
248 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
|
249 |
21
aa0870d093b8
Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20
diff
changeset
|
250 ocancopy =repo.cancopy |
22
93dd72d028a1
Automatically publish on tag.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
21
diff
changeset
|
251 opull = repo.pull |
93dd72d028a1
Automatically publish on tag.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
21
diff
changeset
|
252 opush = repo.push |
93dd72d028a1
Automatically publish on tag.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
21
diff
changeset
|
253 o_tag = repo._tag |
23
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
254 orollback = repo.rollback |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
255 o_writejournal = repo._writejournal |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
256 class statefulrepo(repo.__class__): |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
257 |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
258 def nodestate(self, 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
|
259 rev = self.changelog.rev(node) |
30
a2189159e92f
fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
29
diff
changeset
|
260 |
29
52c227772dad
fix nodestate computation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
28
diff
changeset
|
261 for state in STATES: |
13
e95e8cf7988f
Get ride of dedicated heads property.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
12
diff
changeset
|
262 # XXX avoid for untracked heads |
e95e8cf7988f
Get ride of dedicated heads property.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
12
diff
changeset
|
263 if state.next is not None: |
30
a2189159e92f
fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
29
diff
changeset
|
264 ancestors = map(self.changelog.rev, self.stateheads(state)) |
a2189159e92f
fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
29
diff
changeset
|
265 ancestors.extend(self.changelog.ancestors(*ancestors)) |
a2189159e92f
fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
29
diff
changeset
|
266 if rev in ancestors: |
29
52c227772dad
fix nodestate computation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
28
diff
changeset
|
267 break |
13
e95e8cf7988f
Get ride of dedicated heads property.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
12
diff
changeset
|
268 return state |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
269 |
12
6312fc525a54
rename state related attributes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
11
diff
changeset
|
270 |
9
1f84a74df837
introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7
diff
changeset
|
271 |
13
e95e8cf7988f
Get ride of dedicated heads property.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
12
diff
changeset
|
272 def stateheads(self, state): |
20
9983f240ac63
Smarter states heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19
diff
changeset
|
273 # 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
|
274 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
|
275 state = state.next |
9983f240ac63
Smarter states heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19
diff
changeset
|
276 # 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
|
277 if state.trackheads: |
20
9983f240ac63
Smarter states heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
19
diff
changeset
|
278 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
|
279 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
|
280 |
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
|
281 @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
|
282 def _statesheads(self): |
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
|
283 return self._readstatesheads() |
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
|
284 |
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
|
285 |
9
1f84a74df837
introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7
diff
changeset
|
286 def _readheadsfile(self, filename): |
1f84a74df837
introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7
diff
changeset
|
287 heads = [nullid] |
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
|
288 try: |
9
1f84a74df837
introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7
diff
changeset
|
289 f = self.opener(filename) |
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
|
290 try: |
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
|
291 heads = sorted([node.bin(n) for n in f.read().split() if n]) |
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
|
292 finally: |
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
|
293 f.close() |
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
|
294 except IOError: |
9
1f84a74df837
introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7
diff
changeset
|
295 pass |
1f84a74df837
introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7
diff
changeset
|
296 return heads |
23
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
297 |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
298 def _readstatesheads(self, undo=False): |
9
1f84a74df837
introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7
diff
changeset
|
299 statesheads = {} |
12
6312fc525a54
rename state related attributes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
11
diff
changeset
|
300 for state in STATES: |
6312fc525a54
rename state related attributes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
11
diff
changeset
|
301 if state.trackheads: |
23
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
302 filemask = 'states/%s-heads' |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
303 filename = filemask % state.name |
12
6312fc525a54
rename state related attributes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
11
diff
changeset
|
304 statesheads[state] = self._readheadsfile(filename) |
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
|
305 return statesheads |
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
|
306 |
9
1f84a74df837
introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7
diff
changeset
|
307 def _writeheadsfile(self, filename, heads): |
1f84a74df837
introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7
diff
changeset
|
308 f = self.opener(filename, 'w', atomictemp=True) |
1f84a74df837
introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7
diff
changeset
|
309 try: |
1f84a74df837
introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7
diff
changeset
|
310 for h in heads: |
1f84a74df837
introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7
diff
changeset
|
311 f.write(hex(h) + '\n') |
1f84a74df837
introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7
diff
changeset
|
312 f.rename() |
1f84a74df837
introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7
diff
changeset
|
313 finally: |
1f84a74df837
introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7
diff
changeset
|
314 f.close() |
1f84a74df837
introduce a third state
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
7
diff
changeset
|
315 |
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
|
316 def _writestateshead(self): |
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
|
317 # transaction! |
12
6312fc525a54
rename state related attributes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
11
diff
changeset
|
318 for state in STATES: |
6312fc525a54
rename state related attributes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
11
diff
changeset
|
319 if state.trackheads: |
6312fc525a54
rename state related attributes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
11
diff
changeset
|
320 filename = 'states/%s-heads' % state.name |
6312fc525a54
rename state related attributes
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
11
diff
changeset
|
321 self._writeheadsfile(filename, 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
|
322 |
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
|
323 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
|
324 """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
|
325 |
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
|
326 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
|
327 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
|
328 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
|
329 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
|
330 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
|
331 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
|
332 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
|
333 if olds != heads: |
10
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
334 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
|
335 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
|
336 if 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
|
337 self._writestateshead() |
10
91169d2d7f1b
state are now object.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
9
diff
changeset
|
338 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
|
339 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
|
340 |
2
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
341 def _reducehead(self, candidates): |
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
|
342 selected = set() |
19
8784a989a572
introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18
diff
changeset
|
343 st = laststatewithout(_NOSHARE) |
30
a2189159e92f
fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
29
diff
changeset
|
344 candidates = set(map(self.changelog.rev, candidates)) |
a2189159e92f
fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
29
diff
changeset
|
345 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
|
346 shareable = set(self.changelog.ancestors(*heads)) |
a2189159e92f
fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
29
diff
changeset
|
347 shareable.update(heads) |
a2189159e92f
fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
29
diff
changeset
|
348 selected = candidates & shareable |
a2189159e92f
fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
29
diff
changeset
|
349 unselected = candidates - shareable |
a2189159e92f
fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
29
diff
changeset
|
350 for rev in unselected: |
a2189159e92f
fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
29
diff
changeset
|
351 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
|
352 if self.changelog.descendant(revh, rev): |
30
a2189159e92f
fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
29
diff
changeset
|
353 selected.add(revh) |
a2189159e92f
fix outgoing filtering.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
29
diff
changeset
|
354 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
|
355 |
24
20ac7fa3fd29
Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
23
diff
changeset
|
356 ### 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
|
357 |
20ac7fa3fd29
Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
23
diff
changeset
|
358 @util.propertycache |
20ac7fa3fd29
Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
23
diff
changeset
|
359 def _enabledstates(self): |
20ac7fa3fd29
Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
23
diff
changeset
|
360 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
|
361 |
20ac7fa3fd29
Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
23
diff
changeset
|
362 def _readenabledstates(self): |
20ac7fa3fd29
Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
23
diff
changeset
|
363 states = set() |
28
0918e3b54f0b
published is always enabled.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
27
diff
changeset
|
364 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
|
365 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
|
366 try: |
20ac7fa3fd29
Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
23
diff
changeset
|
367 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
|
368 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
|
369 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
|
370 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
|
371 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
|
372 finally: |
20ac7fa3fd29
Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
23
diff
changeset
|
373 return states |
20ac7fa3fd29
Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
23
diff
changeset
|
374 |
20ac7fa3fd29
Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
23
diff
changeset
|
375 def _writeenabledstates(self): |
20ac7fa3fd29
Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
23
diff
changeset
|
376 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
|
377 try: |
20ac7fa3fd29
Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
23
diff
changeset
|
378 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
|
379 f.write(st.name + '\n') |
20ac7fa3fd29
Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
23
diff
changeset
|
380 f.rename() |
20ac7fa3fd29
Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
23
diff
changeset
|
381 finally: |
20ac7fa3fd29
Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
23
diff
changeset
|
382 f.close() |
20ac7fa3fd29
Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
23
diff
changeset
|
383 |
20ac7fa3fd29
Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
23
diff
changeset
|
384 ### 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
|
385 |
5 | 386 def cancopy(self): |
19
8784a989a572
introduce a ``laststatewithout`` method
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
18
diff
changeset
|
387 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
|
388 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
|
389 |
24
20ac7fa3fd29
Move state activitation in a dedicated file repo-side
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
23
diff
changeset
|
390 ### 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
|
391 |
21
aa0870d093b8
Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20
diff
changeset
|
392 def pull(self, remote, *args, **kwargs): |
aa0870d093b8
Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20
diff
changeset
|
393 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
|
394 remoteheads = self._pullstatesheads(remote) |
21
aa0870d093b8
Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20
diff
changeset
|
395 #print [node.short(h) for h in remoteheads] |
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
|
396 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
|
397 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
|
398 return result |
aa0870d093b8
Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20
diff
changeset
|
399 |
aa0870d093b8
Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20
diff
changeset
|
400 def push(self, remote, *args, **opts): |
aa0870d093b8
Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20
diff
changeset
|
401 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
|
402 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
|
403 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
|
404 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
|
405 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
|
406 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
|
407 return result |
aa0870d093b8
Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20
diff
changeset
|
408 |
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
|
409 def _pushstatesheads(self, remote, state, 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
|
410 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
|
411 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
|
412 while missing: |
ad1a4fb0fc49
Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
51
diff
changeset
|
413 h = missing.pop() |
57
62f2fe22bd42
Use dedicated mechanism to report pushkey success
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
55
diff
changeset
|
414 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
|
415 if not ok: |
54
ad1a4fb0fc49
Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
51
diff
changeset
|
416 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
|
417 |
aa0870d093b8
Add pull and push support for relevant heads.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
20
diff
changeset
|
418 |
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
|
419 def _pullstatesheads(self, 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
|
420 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
|
421 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
|
422 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
|
423 self.ui.debug('states-heads not enabled on the 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
|
424 'marking everything as published') |
cf4626a13345
Update pushkey code to be able to push ready heads too.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
54
diff
changeset
|
425 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
|
426 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
|
427 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
|
428 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
|
429 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
|
430 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
|
431 return remoteheads |
5 | 432 |
23
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
433 ### Tag support |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
434 |
22
93dd72d028a1
Automatically publish on tag.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
21
diff
changeset
|
435 def _tag(self, names, node, *args, **kwargs): |
93dd72d028a1
Automatically publish on tag.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
21
diff
changeset
|
436 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
|
437 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
|
438 self.setstate(ST0, [node, tagnode]) |
22
93dd72d028a1
Automatically publish on tag.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
21
diff
changeset
|
439 return tagnode |
93dd72d028a1
Automatically publish on tag.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
21
diff
changeset
|
440 |
23
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
441 ### rollback support |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
442 |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
443 def _writejournal(self, desc): |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
444 entries = list(o_writejournal(desc)) |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
445 for state in STATES: |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
446 if state.trackheads: |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
447 filename = 'states/%s-heads' % state.name |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
448 filepath = self.join(filename) |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
449 if os.path.exists(filepath): |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
450 journalname = 'states/journal.%s-heads' % state.name |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
451 journalpath = self.join(journalname) |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
452 util.copyfile(filepath, journalpath) |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
453 entries.append(journalpath) |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
454 return tuple(entries) |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
455 |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
456 def rollback(self, dryrun=False): |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
457 wlock = lock = None |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
458 try: |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
459 wlock = self.wlock() |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
460 lock = self.lock() |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
461 ret = orollback(dryrun) |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
462 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
|
463 for state in STATES: |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
464 if state.trackheads: |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
465 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
|
466 dest = self.join('states/%s-heads') % state.name |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
467 if os.path.exists(src): |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
468 util.rename(src, dest) |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
469 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
|
470 os.unlink(dest) |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
471 self.__dict__.pop('_statesheads', None) |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
472 return ret |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
473 finally: |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
474 release(lock, wlock) |
423c62a146c7
add rollback support.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
22
diff
changeset
|
475 |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
476 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
|
477 |