annotate hgext/obsolete.py @ 115:d60eddda9546

add an option to ensure unstable are secret
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Thu, 22 Dec 2011 15:26:42 +0100
parents 1a64195e2b09
children ba45bb2d35cb
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
1 # obsolete.py - introduce the obsolete concept in mercurial.
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
2 #
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
3 # Copyright 2011 Pierre-Yves David <pierre-yves.david@ens-lyon.org>
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
4 # Logilab SA <contact@logilab.fr>
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
5 #
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
6 # This software may be used and distributed according to the terms of the
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
7 # GNU General Public License version 2 or any later version.
69
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
8 """Introduce the Obsolete concept to mercurial
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
9
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
10 General concept
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
11 ===============
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
12
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
13 This extension introduces the *obsolete* concept. It adds a new *obsolete*
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
14 relation between two changesets. A relation ``<changeset B> obsolete <changeset
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
15 A>`` is set to denote that ``<changeset B>`` is new version of ``<changeset
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
16 A>``.
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
17
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
18 The *obsolete* relation act as a **perpendicular history** to the standard
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
19 changeset history. Standard changeset history versions files. The *obsolete*
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
20 relation versions changesets.
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
21
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
22 :obsolete: a changeset that have been replace by another one.
85
531058dbd703 [obsolete] vocabulary update suggestion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 84
diff changeset
23 :unstable: a non-obsolet changeset based on another one.
531058dbd703 [obsolete] vocabulary update suggestion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 84
diff changeset
24 :suspended: an obsolete changeset with unstable descendant.
531058dbd703 [obsolete] vocabulary update suggestion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 84
diff changeset
25
531058dbd703 [obsolete] vocabulary update suggestion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 84
diff changeset
26 Another name for unstable could be out of sync.
69
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
27
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
28
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
29
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
30 Usage and Feature
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
31 =================
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
32
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
33
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
34 Display and Exchange
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
35 ....................
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
36
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
37 obsolete changesets are hidden. (except if they have non obsolete changeset)
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
38
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
39 obsolete changesets are currently not exchange. This will probably change later
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
40 but it was the simpler solution for now.
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
41
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
42 New commands
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
43 ............
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
44
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
45 a ``debugobsolete`` command has been added.
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
46
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
47 It add an obsolete relation between too relation.
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
48
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
49 Context object
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
50 ..............
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
51
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
52 Context gain a ``obsolete`` method that return True if a changeset is obsolete
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
53 False otherwise.
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
54
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
55 revset
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
56 ......
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
57
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
58 Add an ``obsolete()`` entry.
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
59
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
60 repo extension
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
61 ..............
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
62
69
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
63 To Do
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
64 -----
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
65
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
66 * refuse to obsolete published changesets
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
67
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
68 * handle split
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
69
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
70 * handle conflict
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
71
85
531058dbd703 [obsolete] vocabulary update suggestion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 84
diff changeset
72 * handle unstable // out of sync
69
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
73
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
74 """
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
75 import os
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
76 try:
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
77 from cStringIO import StringIO
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
78 except ImportError:
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
79 from StringIO import StringIO
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
80
75
d7b11772f0b5 [obsolete] published changeset can't be obsoleted
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 74
diff changeset
81 from mercurial.i18n import _
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
82
89
757153438e58 [obsolet] base64 encore obsolete rel for pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
83 import base64
757153438e58 [obsolet] base64 encore obsolete rel for pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
84
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
85 from mercurial import util
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
86 from mercurial import context
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
87 from mercurial import revset
40
b9a5a596d9ef proper computation of hidden changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 39
diff changeset
88 from mercurial import scmutil
42
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
89 from mercurial import extensions
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
90 from mercurial import pushkey
46
3b0364fc822f Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 44
diff changeset
91 from mercurial import discovery
3b0364fc822f Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 44
diff changeset
92 from mercurial import error
79
9906560f585e [obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 75
diff changeset
93 from mercurial import commands
114
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
94 from mercurial import changelog
115
d60eddda9546 add an option to ensure unstable are secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 114
diff changeset
95 from mercurial import phases
80
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
96 from mercurial.node import hex, bin, short, nullid
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
97 from mercurial.lock import release
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
98
72
774932a6cc0d [obsolete] rationalize doc header.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 71
diff changeset
99 ### Patch changectx
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
100 #############################
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
101
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
102 def obsolete(ctx):
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
103 """is the changeset obsolete by other"""
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
104 if ctx.node()is None:
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
105 return False
112
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
106 return bool(ctx._repo.obsoletedby(ctx.node())) and ctx.phase()
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
107
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
108 context.changectx.obsolete = obsolete
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
109
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
110
72
774932a6cc0d [obsolete] rationalize doc header.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 71
diff changeset
111 ### revset
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
112 #############################
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
113
112
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
114 def revsetpublic(repo, subset, x):
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
115 args = revset.getargs(x, 0, 0, 'publicheads takes no arguments')
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
116 # XXX slow stop using context
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
117 return [r for r in subset if repo._phaserev[r] == 0]
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
118
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
119 def revsetobsolete(repo, subset, x):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
120 """filter obsolet entry"""
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
121 args = revset.getargs(x, 0, 0, 'publicheads takes no arguments')
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
122 # XXX slow stop using context
112
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
123 return [r for r in subset if r in repo._obsoleteset and repo._phaserev[r] > 0]
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
124
71
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
125 ### Other Extension compat
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
126 ############################
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
127
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
128 def concludenode(orig, repo, rev, *args, **kwargs):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
129 """wrapper for rebase 's concludenode that set obsolete relation"""
71
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
130 newrev = orig(repo, rev, *args, **kwargs)
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
131 oldnode = repo[rev].node()
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
132 newnode = repo[newrev].node()
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
133 repo.addobsolete(newnode, oldnode)
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
134 return newrev
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
135
84
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
136 def cmdrebase(orig, repo, ui, *args, **kwargs):
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
137 oldkeep = kwargs.pop('keep', False)
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
138 if oldkeep:
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
139 ui.warn('WARNING --keep option ignored by experimental obsolete extension')
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
140 kwargs['keep'] = True
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
141 return orig(repo, ui, *args, **kwargs)
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
142
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
143
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
144 ### Filter obsolet changeset
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
145 ############################
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
146
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
147 def filterobsoleteout(orig, repo, remote, *args,**kwargs):
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
148 """wrapper for findcommonoutgoing that remove obsolete changeset
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
149
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
150 This behaviour is temporary"""
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
151 common, heads = orig(repo, remote, *args, **kwargs)
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
152
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
153 # filter obsolete
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
154 heads = set(map(repo.changelog.rev, heads))
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
155 obsoletes = set()
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
156 for obj in repo._obsobjrels:
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
157 try:
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
158 obsoletes.add(repo.changelog.rev(obj))
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
159 except error.LookupError:
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
160 pass # we don't have this node locally
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
161
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
162 outgoing = set(repo.changelog.ancestors(*heads))
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
163 outgoing.update(heads)
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
164
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
165 selected = outgoing - obsoletes
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
166 heads = sorted(map(repo.changelog.node, selected))
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
167
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
168 return common, heads
71
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
169
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
170 def extsetup(ui):
75
d7b11772f0b5 [obsolete] published changeset can't be obsoleted
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 74
diff changeset
171
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
172 revset.symbols["obsolete"] = revsetobsolete
112
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
173 revset.symbols["public"] = revsetpublic
46
3b0364fc822f Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 44
diff changeset
174
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
175 extensions.wrapfunction(discovery, 'findcommonoutgoing', filterobsoleteout)
46
3b0364fc822f Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 44
diff changeset
176
42
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
177 try:
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
178 rebase = extensions.find('rebase')
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
179 if rebase:
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
180 extensions.wrapfunction(rebase, 'concludenode', concludenode)
84
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
181 extensions.wrapcommand(rebase.cmdtable, "rebase", cmdrebase)
42
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
182 except KeyError:
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
183 pass # rebase not found
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
184
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
185 # Pushkey mechanism for mutable
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
186 #########################################
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
187
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
188 def pushobsolete(repo, key, old, raw):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
189 """push obsolete relation through pushkey"""
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
190 assert key == "relations"
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
191 w = repo.wlock()
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
192 try:
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
193 tmp = StringIO()
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
194 tmp.write(raw)
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
195 tmp.seek(0)
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
196 relations = _obsdeserialise(tmp)
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
197 for sub, objs in relations.iteritems():
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
198 for obj in objs:
58
2ba7355f6e11 [obsolete] Fix pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 56
diff changeset
199 try:
2ba7355f6e11 [obsolete] Fix pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 56
diff changeset
200 repo.addobsolete(sub, obj)
2ba7355f6e11 [obsolete] Fix pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 56
diff changeset
201 except error.RepoLookupError:
2ba7355f6e11 [obsolete] Fix pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 56
diff changeset
202 pass
2ba7355f6e11 [obsolete] Fix pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 56
diff changeset
203 return 0
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
204 finally:
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
205 w.release()
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
206
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
207 def listobsolete(repo):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
208 """dump all obsolete relation in
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
209
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
210 XXX this have be improved"""
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
211 tmp = StringIO()
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
212 _obsserialise(repo._obssubrels, tmp)
89
757153438e58 [obsolet] base64 encore obsolete rel for pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
213 return {'relations': base64.b64encode(tmp.getvalue())}
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
214
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
215 pushkey.register('obsolete', pushobsolete, listobsolete)
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
216
71
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
217 ### New commands
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
218 #############################
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
219
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
220
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
221 def cmddebugobsolete(ui, repo, subject, object):
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
222 """Add an obsolete relation between a too node
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
223
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
224 The subject is expected to be a newer version of the object"""
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
225 sub = repo[subject]
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
226 obj = repo[object]
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
227 repo.addobsolete(sub.node(), obj.node())
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
228 return 0
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
229
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
230 cmdtable = {'debugobsolete': (cmddebugobsolete, [], '<subject> <object>')}
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
231
79
9906560f585e [obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 75
diff changeset
232 ### Altering existing command
9906560f585e [obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 75
diff changeset
233 #############################
9906560f585e [obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 75
diff changeset
234
9906560f585e [obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 75
diff changeset
235 def wrapmayobsoletewc(origfn, ui, repo, *args, **opts):
9906560f585e [obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 75
diff changeset
236 res = origfn(ui, repo, *args, **opts)
9906560f585e [obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 75
diff changeset
237 if repo['.'].obsolete():
9906560f585e [obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 75
diff changeset
238 ui.warn(_('Working directory parent is obsolete\n'))
9906560f585e [obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 75
diff changeset
239 return res
9906560f585e [obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 75
diff changeset
240
9906560f585e [obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 75
diff changeset
241 def uisetup(ui):
9906560f585e [obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 75
diff changeset
242 extensions.wrapcommand(commands.table, "update", wrapmayobsoletewc)
9906560f585e [obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 75
diff changeset
243 extensions.wrapcommand(commands.table, "pull", wrapmayobsoletewc)
9906560f585e [obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 75
diff changeset
244
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
245 ### serialisation
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
246 #############################
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
247
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
248 def _obsserialise(obssubrels, flike):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
249 """serialise an obsolete relation mapping in a plain text one
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
250
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
251 this is for subject -> [objects] mapping
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
252
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
253 format is::
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
254
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
255 <subject-full-hex> <object-full-hex>\n"""
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
256 for sub, objs in obssubrels.iteritems():
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
257 for obj in objs:
80
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
258 if sub is None:
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
259 sub = nullid
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
260 flike.write('%s %s\n' % (hex(sub), hex(obj)))
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
261
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
262 def _obsdeserialise(flike):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
263 """read a file like object serialised with _obsserialise
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
264
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
265 this desierialize into a {subject -> objects} mapping"""
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
266 rels = {}
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
267 for line in flike:
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
268 subhex, objhex = line.split()
80
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
269 subnode = bin(subhex)
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
270 if subnode == nullid:
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
271 subnode = None
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
272 rels.setdefault( subnode, set()).add(bin(objhex))
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
273 return rels
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
274
87
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
275 ### diagnostique tools
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
276 #############################
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
277
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
278 def unstables(repo):
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
279 """Return all unstable changeset"""
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
280 return scmutil.revrange(repo, ['obsolete():: and (not obsolete())'])
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
281
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
282 def newerversion(repo, obs):
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
283 """Return the newer version of an obsolete changeset"""
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
284 toproceed = set([obs])
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
285 # XXX know optimization available
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
286 newer = set()
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
287 while toproceed:
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
288 current = toproceed.pop()
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
289 if current in repo._obsobjrels:
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
290 toproceed.update(repo._obsobjrels[current])
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
291 elif current is not None: # None is kill
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
292 newer.add(current)
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
293 return sorted(newer)
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
294
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
295
86
7f763bada042 [obsolete] code section comment for repo subclassing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 85
diff changeset
296 ### repo subclassing
7f763bada042 [obsolete] code section comment for repo subclassing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 85
diff changeset
297 #############################
7f763bada042 [obsolete] code section comment for repo subclassing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 85
diff changeset
298
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
299 def reposetup(ui, repo):
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
300
47
b73b3e3c9560 Don't overwrite non local repo.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 46
diff changeset
301 if not repo.local():
b73b3e3c9560 Don't overwrite non local repo.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 46
diff changeset
302 return
b73b3e3c9560 Don't overwrite non local repo.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 46
diff changeset
303
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
304 opull = repo.pull
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
305 opush = repo.push
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
306 orollback = repo.rollback
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
307 o_writejournal = repo._writejournal
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
308 ocancopy = repo.cancopy
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
309
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
310 class obsoletingrepo(repo.__class__):
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
311
53
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
312 ### Public method
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
313 def obsoletedby(self, node):
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
314 """return the set of node that make <node> obsolete (obj)"""
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
315 return self._obsobjrels.get(node, set())
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
316
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
317 def obsolete(self, node):
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
318 """return the set of node that <node> make obsolete (sub)"""
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
319 return self._obssubrels.get(node, set())
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
320
109
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
321 @util.propertycache
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
322 def _obsoleteset(self):
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
323 obs = set()
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
324 for obj in self._obsobjrels:
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
325 try:
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
326 obs.add(self.changelog.rev(obj))
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
327 except error.LookupError:
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
328 pass
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
329 return obs
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
330
53
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
331 def addobsolete(self, sub, obj):
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
332 """Add a relation marking that node <sub> is a new version of <obj>"""
80
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
333 if sub == nullid:
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
334 sub = None
53
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
335 self._obssubrels.setdefault(sub, set()).add(obj)
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
336 self._obsobjrels.setdefault(obj, set()).add(sub)
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
337 try:
112
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
338 if self[obj].phase() == 0:
95
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
339 if sub is None:
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
340 self.ui.warn(
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
341 _("trying to kill immutable changeset %(obj)s\n")
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
342 % {'obj': short(obj)})
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
343 if sub is not None:
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
344 self.ui.warn(
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
345 _("%(sub)s try to obsolete immutable changeset %(obj)s\n")
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
346 % {'sub': short(sub), 'obj': short(obj)})
53
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
347 self.changelog.hiddenrevs.add(repo[obj].rev())
75
d7b11772f0b5 [obsolete] published changeset can't be obsoleted
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 74
diff changeset
348 except (error.RepoLookupError, error.LookupError):
53
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
349 pass #unknow revision (but keep propagating the data
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
350 self._writeobsrels()
109
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
351 if '_obsobjrels' in vars(self):
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
352 del self._obsobjrels
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
353 if '_obssubrels' in vars(self):
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
354 del self._obssubrels
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
355 if '_obsoleteset' in vars(self):
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
356 del self._obsoleteset
43
20fca307d9f0 more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 42
diff changeset
357
20fca307d9f0 more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 42
diff changeset
358 ### obsolete storage
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
359 @util.propertycache
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
360 def _obsobjrels(self):
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
361 """{<old-node> -> set(<new-node>)}
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
362
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
363 also compute hidden revision"""
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
364 #reverse sub -> objs mapping
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
365 objrels = {}
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
366 for sub, objs in self._obssubrels.iteritems():
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
367 for obj in objs:
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
368 objrels.setdefault(obj, set()).add(sub)
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
369 return objrels
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
370
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
371 @util.propertycache
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
372 def _obssubrels(self):
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
373 """{<new-node> -> set(<old-node>)}"""
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
374 return self._readobsrels()
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
375
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
376
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
377
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
378
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
379 ### Disk IO
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
380 def _readobsrels(self):
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
381 """Write obsolete relation on disk"""
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
382 # XXX handle lock
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
383 try:
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
384 f = self.opener('obsolete-relations')
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
385 try:
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
386 return _obsdeserialise(f)
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
387 finally:
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
388 f.close()
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
389 except IOError:
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
390 return {}
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
391
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
392 def _writeobsrels(self):
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
393 """Write obsolete relation on disk"""
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
394 # XXX handle lock
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
395 f = self.opener('obsolete-relations', 'w', atomictemp=True)
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
396 try:
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
397 _obsserialise(self._obssubrels, f)
83
97a5c943db19 Compat with mercurial 1.9.2
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 80
diff changeset
398 try:
97a5c943db19 Compat with mercurial 1.9.2
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 80
diff changeset
399 f.rename()
97a5c943db19 Compat with mercurial 1.9.2
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 80
diff changeset
400 except AttributeError: # old version
97a5c943db19 Compat with mercurial 1.9.2
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 80
diff changeset
401 f.close()
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
402 finally:
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
403 f.close()
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
404
50
19b22ad56b32 clone support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 47
diff changeset
405 ### local clone support
19b22ad56b32 clone support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 47
diff changeset
406
19b22ad56b32 clone support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 47
diff changeset
407 def cancopy(self):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
408 """wrapper on cancopy that deny copy if there is obsolete relation"""
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
409 return ocancopy() and not bool(self._obsobjrels) # you can't copy if there is obsolete
50
19b22ad56b32 clone support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 47
diff changeset
410
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
411 ### pull // push support
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
412
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
413 def pull(self, remote, *args, **kwargs):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
414 """wrapper around push that push obsolete relation"""
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
415 result = opull(remote, *args, **kwargs)
56
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
416 if 'obsolete' in remote.listkeys('namespaces'):
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
417 tmp = StringIO()
89
757153438e58 [obsolet] base64 encore obsolete rel for pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
418 rels = remote.listkeys('obsolete')['relations']
757153438e58 [obsolet] base64 encore obsolete rel for pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
419 tmp.write(base64.b64decode(rels))
56
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
420 tmp.seek(0)
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
421 obsrels = _obsdeserialise(tmp)
56
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
422 for sub, objs in obsrels.iteritems():
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
423 for obj in objs:
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
424 self.addobsolete(sub, obj)
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
425 return result
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
426
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
427 def push(self, remote, *args, **opts):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
428 """wrapper around pull that pull obsolete relation"""
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
429 result = opush(remote, *args, **opts)
56
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
430 if 'obsolete' in remote.listkeys('namespaces'):
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
431 tmp = StringIO()
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
432 _obsserialise(self._obssubrels, tmp)
58
2ba7355f6e11 [obsolete] Fix pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 56
diff changeset
433 remote.pushkey('obsolete', 'relations', '', tmp.getvalue())
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
434
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
435 return result
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
436
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
437
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
438
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
439 ### rollback support
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
440
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
441 def _writejournal(self, desc):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
442 """wrapped version of _writejournal that save obsolete data"""
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
443 entries = list(o_writejournal(desc))
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
444 filename = 'obsolete-relations'
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
445 filepath = self.join(filename)
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
446 if os.path.exists(filepath):
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
447 journalname = 'journal.' + filename
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
448 journalpath = self.join(journalname)
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
449 util.copyfile(filepath, journalpath)
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
450 entries.append(journalpath)
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
451 return tuple(entries)
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
452
112
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
453 def rollback(self, dryrun=False, **kwargs):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
454 """wrapped version of rollback that restore obsolete data"""
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
455 wlock = lock = None
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
456 try:
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
457 wlock = self.wlock()
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
458 lock = self.lock()
112
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
459 ret = orollback(dryrun, **kwargs)
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
460 if not (ret or dryrun): #rollback did not failed
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
461 src = self.join('undo.obsolete-relations')
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
462 dst = self.join('obsolete-relations')
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
463 if os.path.exists(src):
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
464 util.rename(src, dst)
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
465 elif os.path.exists(dst): #unlink in any case
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
466 os.unlink(dst)
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
467 # invalidate cache
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
468 self.__dict__.pop('_obssubrels', None)
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
469 self.__dict__.pop('_obsobjrels', None)
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
470 return ret
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
471 finally:
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
472 release(lock, wlock)
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
473
114
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
474 @scmutil.filecache('00changelog.i', True)
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
475 def changelog(self):
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
476 changelog = getattr(super(obsoletingrepo, self), 'changelog')
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
477 assert not changelog.__dict__.pop('hiddenrevs', ())
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
478 def _sethidden(changelog, value):
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
479 print 'COIN COIN', value
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
480 assert not value
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
481
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
482
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
483 class hchangelog(changelog.__class__):
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
484 @util.propertycache
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
485 def hiddenrevs(changelog):
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
486 shown = ['not obsolete()', '.', 'bookmark()', 'tagged()',
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
487 'public()']
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
488 basicquery = 'obsolete() - (::(%s))' % (' or '.join(shown))
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
489 # !!! self is repo not changelog
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
490 result = set(scmutil.revrange(self, [basicquery]))
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
491 return result
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
492 changelog.__class__ = hchangelog
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
493 return changelog
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
494
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
495
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
496
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
497
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
498 repo.__class__ = obsoletingrepo
115
d60eddda9546 add an option to ensure unstable are secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 114
diff changeset
499 obsoletes = [c.node() for c in repo.set('obsolete() - public()')]
d60eddda9546 add an option to ensure unstable are secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 114
diff changeset
500 lock = repo.lock()
d60eddda9546 add an option to ensure unstable are secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 114
diff changeset
501 if repo.ui.configbool('obsolete', 'secret-unstable', True):
d60eddda9546 add an option to ensure unstable are secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 114
diff changeset
502 try:
d60eddda9546 add an option to ensure unstable are secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 114
diff changeset
503 phases.retractboundary(repo, 2, obsoletes)
d60eddda9546 add an option to ensure unstable are secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 114
diff changeset
504 finally:
d60eddda9546 add an option to ensure unstable are secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 114
diff changeset
505 lock.release()
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
506
115
d60eddda9546 add an option to ensure unstable are secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 114
diff changeset
507