Mercurial > evolve
annotate states.py @ 7:cc592295900f
Add write protocol support for private.
Writeprotocol repo doesn't need to _reducehead locally. It's the heads command
implementation server side that handle the filtering.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Mon, 23 May 2011 15:41:20 +0200 |
parents | 9445ce78a935 |
children | 1f84a74df837 |
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 ''' |
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 |
7
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
32 from mercurial import wireproto |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
33 |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
34 |
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
|
35 _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
|
36 |
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
|
37 STATES = (0, _NOPULLPUSH) |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
38 def statename(state): |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
39 return str(STATES) |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
40 |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
41 |
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 # 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
|
43 ############################# |
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 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
|
45 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
|
46 scmutil.revrange(repo, revsets)) |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
47 |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
48 # Patch changectx |
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 |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
51 def state(ctx): |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
52 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
|
53 context.changectx.state = state |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
54 |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
55 # improve template |
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 |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
58 def showstate(ctx, **args): |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
59 return ctx.state() |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
60 |
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
|
61 # 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
|
62 ############################# |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
63 |
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
|
64 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
|
65 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
|
66 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
|
67 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
|
68 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
|
69 |
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 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
|
71 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
|
72 |
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 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
|
74 |
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 # 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
|
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 |
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 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
|
79 """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
|
80 #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
|
81 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
|
82 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
|
83 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
|
84 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
|
85 |
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 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
|
87 '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
|
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 |
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 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
|
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 |
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
|
98 def uisetup(ui): |
2
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
99 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
|
100 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
|
101 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
|
102 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
|
103 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
|
104 heads = remote._reducehead(heads) |
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
105 return common, anyinc, heads |
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
106 |
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
107 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
|
108 extensions.wrapfunction(discovery, 'findcommonincoming', filterprivatein) |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
109 |
7
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
110 # Write protocols |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
111 #################### |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
112 def heads(repo, proto): |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
113 h = repo._publicheads |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
114 return wireproto.encodelist(h) + "\n" |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
115 |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
116 def _reducehead(wirerepo, heads): |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
117 """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
|
118 return heads |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
119 |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
120 wireproto.wirerepository._reducehead = _reducehead |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
121 wireproto.commands['heads'] = (heads, '') |
cc592295900f
Add write protocol support for private.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
5
diff
changeset
|
122 |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
123 def reposetup(ui, repo): |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
124 |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
125 if not repo.local(): |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
126 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
|
127 |
5 | 128 o_cancopy =repo.cancopy |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
129 class statefulrepo(repo.__class__): |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
130 |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
131 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
|
132 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
|
133 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
|
134 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
|
135 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
|
136 return STATES[1] |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
137 return STATES[0] |
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
138 |
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
|
139 @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
|
140 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
|
141 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
|
142 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
|
143 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
|
144 |
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 @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
|
146 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
|
147 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
|
148 |
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 |
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 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
|
151 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
|
152 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
|
153 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
|
154 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
|
155 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
|
156 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
|
157 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
|
158 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
|
159 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
|
160 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
|
161 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
|
162 |
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 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
|
164 # 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
|
165 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
|
166 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
|
167 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
|
168 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
|
169 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
|
170 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
|
171 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
|
172 |
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
|
173 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
|
174 """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
|
175 |
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 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
|
177 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
|
178 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
|
179 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
|
180 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
|
181 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
|
182 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
|
183 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
|
184 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
|
185 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
|
186 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
|
187 |
2
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
188 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
|
189 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
|
190 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
|
191 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
|
192 ok = True |
2
166694e62daf
hide private changeset to inc and pull.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
1
diff
changeset
|
193 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
|
194 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
|
195 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
|
196 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
|
197 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
|
198 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
|
199 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
|
200 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
|
201 |
5 | 202 def cancopy(self): |
203 return o_cancopy() and (self._publicheads == self.heads()) | |
204 | |
0
bbeef801409c
minimalistic state concept.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
205 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
|
206 |