author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
Mon, 23 May 2011 14:25:22 +0200 | |
changeset 3 | b4932dff9bd8 |
parent 2 | 166694e62daf |
child 5 | 9445ce78a935 |
permissions | -rw-r--r-- |
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 |
''' |
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
|
20 |
from functools import partial |
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 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
|
22 |
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
|
23 |
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
|
24 |
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
|
25 |
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
|
26 |
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
|
27 |
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
|
28 |
from mercurial import 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
|
29 |
from mercurial.node import nullid |
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 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
|
31 |
from mercurial import extensions |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
32 |
|
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
33 |
|
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
|
34 |
_NOPULLPUSH=2 |
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
|
35 |
|
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
|
36 |
STATES = (0, _NOPULLPUSH) |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
37 |
def statename(state): |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
38 |
return str(STATES) |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
39 |
|
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
40 |
|
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
|
41 |
# 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
|
42 |
############################# |
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
|
43 |
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
|
44 |
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
|
45 |
scmutil.revrange(repo, revsets)) |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
46 |
|
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
47 |
# Patch changectx |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
48 |
############################# |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
49 |
|
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
50 |
def state(ctx): |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
51 |
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
|
52 |
context.changectx.state = state |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
53 |
|
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
54 |
# improve template |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
55 |
############################# |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
56 |
|
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
57 |
def showstate(ctx, **args): |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
58 |
return ctx.state() |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
59 |
|
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
|
60 |
# New revset predicate |
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
|
61 |
############################# |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
62 |
|
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
|
63 |
def revsetpublicheads(repo, subset, x): |
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
|
64 |
args = revset.getargs(x, 0, 0, 'publicheads takes no arguments') |
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
|
65 |
heads = map(repo.changelog.rev, repo._statesheads[0]) |
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
|
66 |
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
|
67 |
return 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
|
68 |
|
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
|
69 |
def extsetup(ui): |
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
|
70 |
revset.symbols['publicheads'] = revsetpublicheads |
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
|
71 |
|
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
|
72 |
REVSETHEADS = {0: 'publicheads()'} |
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
|
73 |
|
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
|
74 |
# 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
|
75 |
############################# |
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
|
76 |
|
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
|
77 |
def cmdsetstate(ui, repo, state, *changesets): |
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
|
78 |
"""turn private changesets into public ones""" |
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
|
79 |
#assert repo.ui.configbool('private', 'enable', False) |
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
|
80 |
state = int(state) #for now |
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
|
81 |
revs = scmutil.revrange(repo, changesets) |
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
|
82 |
repo.setstate(state, [repo.changelog.node(rev) for rev in revs]) |
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
|
83 |
return 0 |
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
|
84 |
|
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
|
85 |
cmdtable = { |
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
|
86 |
'setstate': (cmdsetstate, [], _('state <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
|
87 |
} |
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
|
88 |
|
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
|
89 |
|
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
|
90 |
templatekw.keywords['state'] = showstate |
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
|
91 |
|
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
|
92 |
|
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
|
93 |
|
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
|
94 |
|
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
|
95 |
|
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
|
96 |
|
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
|
97 |
def uisetup(ui): |
2
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
98 |
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
|
99 |
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
|
100 |
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
|
101 |
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
|
102 |
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
|
103 |
heads = remote._reducehead(heads) |
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
104 |
return common, anyinc, heads |
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
105 |
|
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
106 |
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
|
107 |
extensions.wrapfunction(discovery, 'findcommonincoming', filterprivatein) |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
108 |
|
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
109 |
def reposetup(ui, repo): |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
110 |
|
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
111 |
if not repo.local(): |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
112 |
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
|
113 |
|
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
114 |
class statefulrepo(repo.__class__): |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
115 |
|
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
116 |
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
|
117 |
rev = self.changelog.rev(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
|
118 |
for head in self._publicheads: |
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 |
revhead = self.changelog.rev(head) |
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
|
120 |
if self.changelog.descendant(revhead, rev): |
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
|
121 |
return STATES[1] |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
122 |
return STATES[0] |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
123 |
|
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
|
124 |
@property |
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
|
125 |
def _publicheads(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
|
126 |
if self.ui.configbool('states', 'private', False): |
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 |
return self._statesheads[0] |
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 |
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
|
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 |
@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
|
131 |
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
|
132 |
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
|
133 |
|
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
|
134 |
|
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
|
135 |
def _readstatesheads(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
|
136 |
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
|
137 |
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
|
138 |
f = self.opener('publicheads') |
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
|
139 |
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
|
140 |
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
|
141 |
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
|
142 |
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
|
143 |
except IOError: |
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
|
144 |
heads = [nullid] |
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
|
145 |
statesheads[0] = 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
|
146 |
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
|
147 |
|
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
|
148 |
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
|
149 |
# transaction! |
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
|
150 |
f = self.opener('publicheads', 'w', atomictemp=True) |
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
|
151 |
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
|
152 |
for h in self._statesheads[0]: |
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
|
153 |
f.write(node.hex(h) + '\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
|
154 |
f.rename() |
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
|
155 |
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
|
156 |
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
|
157 |
|
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
|
158 |
def setstate(self, state, 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
|
159 |
"""freeze targets changeset and it's ancestors. |
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
|
160 |
|
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
|
161 |
Simplify the list of head.""" |
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
|
162 |
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
|
163 |
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
|
164 |
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
|
165 |
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
|
166 |
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
|
167 |
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
|
168 |
heads[:] = noderange(repo, ["heads(::%s)" % REVSETHEADS[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
|
169 |
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
|
170 |
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
|
171 |
self._writestateshead() |
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
|
172 |
|
2
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
173 |
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
|
174 |
selected = set() |
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
|
175 |
for candidate in candidates: |
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
|
176 |
rev = self.changelog.rev(candidate) |
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 |
ok = True |
2
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
178 |
for h in self._publicheads: |
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
|
179 |
revh = self.changelog.rev(h) |
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 |
if self.changelog.descendant(revh, rev): |
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
|
181 |
ok = False |
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
|
182 |
selected.add(h) |
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
|
183 |
if ok: |
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
|
184 |
selected.add(candidate) |
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
|
185 |
return sorted(selected) |
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
|
186 |
|
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
187 |
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
|
188 |