annotate hgext/obsolete.py @ 121:7280eede21ea

obsolete: improve locking when writing obsolete data
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Sat, 07 Jan 2012 11:26:48 +0100
parents ba45bb2d35cb
children c75a73209f1e
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
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
115 def revsetobsolete(repo, subset, x):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
116 """filter obsolet entry"""
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
117 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
118 # XXX slow stop using context
112
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
119 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
120
71
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
121 ### Other Extension compat
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
122 ############################
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
123
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
124 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
125 """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
126 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
127 oldnode = repo[rev].node()
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
128 newnode = repo[newrev].node()
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
129 repo.addobsolete(newnode, oldnode)
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
130 return newrev
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
131
84
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
132 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
133 oldkeep = kwargs.pop('keep', False)
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
134 if oldkeep:
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
135 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
136 kwargs['keep'] = True
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
137 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
138
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
139
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
140 ### Filter obsolet changeset
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
141 ############################
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
142
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
143 def filterobsoleteout(orig, repo, remote, *args,**kwargs):
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
144 """wrapper for findcommonoutgoing that remove obsolete 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 This behaviour is temporary"""
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
147 common, heads = orig(repo, remote, *args, **kwargs)
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
148
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
149 # filter obsolete
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
150 heads = set(map(repo.changelog.rev, heads))
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
151 obsoletes = set()
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
152 for obj in repo._obsobjrels:
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
153 try:
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
154 obsoletes.add(repo.changelog.rev(obj))
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
155 except error.LookupError:
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
156 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
157
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
158 outgoing = set(repo.changelog.ancestors(*heads))
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
159 outgoing.update(heads)
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
160
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
161 selected = outgoing - obsoletes
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
162 heads = sorted(map(repo.changelog.node, selected))
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
163
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
164 return common, heads
71
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
165
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
166 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
167
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
168 revset.symbols["obsolete"] = revsetobsolete
46
3b0364fc822f Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 44
diff changeset
169
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
170 extensions.wrapfunction(discovery, 'findcommonoutgoing', filterobsoleteout)
46
3b0364fc822f Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 44
diff changeset
171
42
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
172 try:
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
173 rebase = extensions.find('rebase')
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
174 if rebase:
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
175 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
176 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
177 except KeyError:
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
178 pass # rebase not found
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
179
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
180 # Pushkey mechanism for mutable
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
181 #########################################
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
182
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
183 def pushobsolete(repo, key, old, raw):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
184 """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
185 assert key == "relations"
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
186 w = repo.wlock()
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
187 try:
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
188 tmp = StringIO()
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
189 tmp.write(raw)
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
190 tmp.seek(0)
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
191 relations = _obsdeserialise(tmp)
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
192 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
193 for obj in objs:
58
2ba7355f6e11 [obsolete] Fix pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 56
diff changeset
194 try:
2ba7355f6e11 [obsolete] Fix pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 56
diff changeset
195 repo.addobsolete(sub, obj)
2ba7355f6e11 [obsolete] Fix pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 56
diff changeset
196 except error.RepoLookupError:
2ba7355f6e11 [obsolete] Fix pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 56
diff changeset
197 pass
2ba7355f6e11 [obsolete] Fix pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 56
diff changeset
198 return 0
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
199 finally:
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
200 w.release()
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
201
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
202 def listobsolete(repo):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
203 """dump all obsolete relation in
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
204
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
205 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
206 tmp = StringIO()
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
207 _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
208 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
209
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
210 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
211
71
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
212 ### New commands
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
213 #############################
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
214
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
215
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
216 def cmddebugobsolete(ui, repo, subject, object):
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
217 """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
218
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
219 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
220 sub = repo[subject]
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
221 obj = repo[object]
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
222 repo.addobsolete(sub.node(), obj.node())
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
223 return 0
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
224
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
225 cmdtable = {'debugobsolete': (cmddebugobsolete, [], '<subject> <object>')}
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
226
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
227 ### 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
228 #############################
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
229
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
230 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
231 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
232 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
233 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
234 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
235
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 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
237 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
238 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
239
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
240 ### serialisation
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
241 #############################
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
242
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
243 def _obsserialise(obssubrels, flike):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
244 """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
245
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
246 this is for subject -> [objects] mapping
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
247
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
248 format is::
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
249
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
250 <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
251 for sub, objs in obssubrels.iteritems():
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
252 for obj in objs:
80
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
253 if sub is None:
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
254 sub = nullid
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
255 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
256
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
257 def _obsdeserialise(flike):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
258 """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
259
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
260 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
261 rels = {}
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
262 for line in flike:
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
263 subhex, objhex = line.split()
80
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
264 subnode = bin(subhex)
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
265 if subnode == nullid:
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
266 subnode = None
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
267 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
268 return rels
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
269
87
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
270 ### diagnostique tools
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
271 #############################
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
272
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
273 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
274 """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
275 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
276
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
277 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
278 """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
279 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
280 # 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
281 newer = set()
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
282 while toproceed:
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
283 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
284 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
285 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
286 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
287 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
288 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
289
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
290
86
7f763bada042 [obsolete] code section comment for repo subclassing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 85
diff changeset
291 ### repo subclassing
7f763bada042 [obsolete] code section comment for repo subclassing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 85
diff changeset
292 #############################
7f763bada042 [obsolete] code section comment for repo subclassing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 85
diff changeset
293
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
294 def reposetup(ui, repo):
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
295
47
b73b3e3c9560 Don't overwrite non local repo.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 46
diff changeset
296 if not repo.local():
b73b3e3c9560 Don't overwrite non local repo.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 46
diff changeset
297 return
b73b3e3c9560 Don't overwrite non local repo.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 46
diff changeset
298
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
299 opull = repo.pull
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
300 opush = repo.push
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
301 orollback = repo.rollback
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
302 o_writejournal = repo._writejournal
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
303 ocancopy = repo.cancopy
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
304
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
305 class obsoletingrepo(repo.__class__):
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
306
53
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
307 ### Public method
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
308 def obsoletedby(self, node):
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
309 """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
310 return self._obsobjrels.get(node, set())
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
311
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
312 def obsolete(self, node):
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
313 """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
314 return self._obssubrels.get(node, set())
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
315
109
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
316 @util.propertycache
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
317 def _obsoleteset(self):
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
318 obs = set()
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
319 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
320 try:
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
321 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
322 except error.LookupError:
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
323 pass
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
324 return obs
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
325
53
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
326 def addobsolete(self, sub, obj):
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
327 """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
328 if sub == nullid:
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
329 sub = None
53
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
330 self._obssubrels.setdefault(sub, set()).add(obj)
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
331 self._obsobjrels.setdefault(obj, set()).add(sub)
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
332 try:
112
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
333 if self[obj].phase() == 0:
95
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
334 if sub is None:
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
335 self.ui.warn(
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
336 _("trying to kill immutable changeset %(obj)s\n")
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
337 % {'obj': short(obj)})
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
338 if sub is not None:
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
339 self.ui.warn(
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
340 _("%(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
341 % {'sub': short(sub), 'obj': short(obj)})
53
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
342 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
343 except (error.RepoLookupError, error.LookupError):
53
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
344 pass #unknow revision (but keep propagating the data
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
345 self._writeobsrels()
109
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
346 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
347 del self._obsobjrels
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
348 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
349 del self._obssubrels
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
350 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
351 del self._obsoleteset
43
20fca307d9f0 more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 42
diff changeset
352
20fca307d9f0 more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 42
diff changeset
353 ### obsolete storage
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
354 @util.propertycache
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
355 def _obsobjrels(self):
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
356 """{<old-node> -> set(<new-node>)}
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
357
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
358 also compute hidden revision"""
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
359 #reverse sub -> objs mapping
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
360 objrels = {}
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
361 for sub, objs in self._obssubrels.iteritems():
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
362 for obj in objs:
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
363 objrels.setdefault(obj, set()).add(sub)
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
364 return objrels
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
365
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
366 @util.propertycache
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
367 def _obssubrels(self):
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
368 """{<new-node> -> set(<old-node>)}"""
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
369 return self._readobsrels()
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
370
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
371
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
372
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
373
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
374 ### Disk IO
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
375 def _readobsrels(self):
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
376 """Write obsolete relation on disk"""
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
377 # XXX handle lock
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
378 try:
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
379 f = self.opener('obsolete-relations')
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
380 try:
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
381 return _obsdeserialise(f)
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
382 finally:
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
383 f.close()
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
384 except IOError:
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
385 return {}
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
386
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
387 def _writeobsrels(self):
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
388 """Write obsolete relation on disk"""
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
389 # XXX handle lock
121
7280eede21ea obsolete: improve locking when writing obsolete data
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 120
diff changeset
390 lock = self.wlock()
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
391 try:
121
7280eede21ea obsolete: improve locking when writing obsolete data
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 120
diff changeset
392 f = self.opener('obsolete-relations', 'w', atomictemp=True)
83
97a5c943db19 Compat with mercurial 1.9.2
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 80
diff changeset
393 try:
121
7280eede21ea obsolete: improve locking when writing obsolete data
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 120
diff changeset
394 _obsserialise(self._obssubrels, f)
7280eede21ea obsolete: improve locking when writing obsolete data
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 120
diff changeset
395 try:
7280eede21ea obsolete: improve locking when writing obsolete data
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 120
diff changeset
396 f.rename()
7280eede21ea obsolete: improve locking when writing obsolete data
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 120
diff changeset
397 except AttributeError: # old version
7280eede21ea obsolete: improve locking when writing obsolete data
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 120
diff changeset
398 f.close()
7280eede21ea obsolete: improve locking when writing obsolete data
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 120
diff changeset
399 finally:
83
97a5c943db19 Compat with mercurial 1.9.2
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 80
diff changeset
400 f.close()
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
401 finally:
121
7280eede21ea obsolete: improve locking when writing obsolete data
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 120
diff changeset
402 lock.release()
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
403
50
19b22ad56b32 clone support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 47
diff changeset
404 ### local clone support
19b22ad56b32 clone support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 47
diff changeset
405
19b22ad56b32 clone support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 47
diff changeset
406 def cancopy(self):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
407 """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
408 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
409
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
410 ### pull // push support
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
411
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
412 def pull(self, remote, *args, **kwargs):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
413 """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
414 result = opull(remote, *args, **kwargs)
56
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
415 if 'obsolete' in remote.listkeys('namespaces'):
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
416 tmp = StringIO()
89
757153438e58 [obsolet] base64 encore obsolete rel for pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
417 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
418 tmp.write(base64.b64decode(rels))
56
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
419 tmp.seek(0)
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
420 obsrels = _obsdeserialise(tmp)
56
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
421 for sub, objs in obsrels.iteritems():
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
422 for obj in objs:
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
423 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
424 return result
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
425
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
426 def push(self, remote, *args, **opts):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
427 """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
428 result = opush(remote, *args, **opts)
56
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
429 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
430 tmp = StringIO()
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
431 _obsserialise(self._obssubrels, tmp)
58
2ba7355f6e11 [obsolete] Fix pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 56
diff changeset
432 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
433
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
434 return result
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
435
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
436
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
437
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
438 ### rollback support
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
439
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
440 def _writejournal(self, desc):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
441 """wrapped version of _writejournal that save obsolete data"""
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
442 entries = list(o_writejournal(desc))
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
443 filename = 'obsolete-relations'
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
444 filepath = self.join(filename)
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
445 if os.path.exists(filepath):
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
446 journalname = 'journal.' + filename
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
447 journalpath = self.join(journalname)
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
448 util.copyfile(filepath, journalpath)
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
449 entries.append(journalpath)
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
450 return tuple(entries)
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
451
112
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
452 def rollback(self, dryrun=False, **kwargs):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
453 """wrapped version of rollback that restore obsolete data"""
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
454 wlock = lock = None
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
455 try:
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
456 wlock = self.wlock()
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
457 lock = self.lock()
112
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
458 ret = orollback(dryrun, **kwargs)
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
459 if not (ret or dryrun): #rollback did not failed
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
460 src = self.join('undo.obsolete-relations')
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
461 dst = self.join('obsolete-relations')
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
462 if os.path.exists(src):
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
463 util.rename(src, dst)
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
464 elif os.path.exists(dst): #unlink in any case
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
465 os.unlink(dst)
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
466 # invalidate cache
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
467 self.__dict__.pop('_obssubrels', None)
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
468 self.__dict__.pop('_obsobjrels', None)
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
469 return ret
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
470 finally:
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
471 release(lock, wlock)
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
472
114
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
473 @scmutil.filecache('00changelog.i', True)
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
474 def changelog(self):
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
475 changelog = getattr(super(obsoletingrepo, self), 'changelog')
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
476 assert not changelog.__dict__.pop('hiddenrevs', ())
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
477 def _sethidden(changelog, value):
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
478 print 'COIN COIN', value
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
479 assert not value
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
480
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 class hchangelog(changelog.__class__):
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
483 @util.propertycache
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
484 def hiddenrevs(changelog):
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
485 shown = ['not obsolete()', '.', 'bookmark()', 'tagged()',
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
486 'public()']
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
487 basicquery = 'obsolete() - (::(%s))' % (' or '.join(shown))
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
488 # !!! self is repo not changelog
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
489 result = set(scmutil.revrange(self, [basicquery]))
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
490 return result
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
491 changelog.__class__ = hchangelog
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
492 return changelog
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
493
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
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
497 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
498 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
499 lock = repo.lock()
d60eddda9546 add an option to ensure unstable are secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 114
diff changeset
500 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
501 try:
d60eddda9546 add an option to ensure unstable are secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 114
diff changeset
502 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
503 finally:
d60eddda9546 add an option to ensure unstable are secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 114
diff changeset
504 lock.release()
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
505
115
d60eddda9546 add an option to ensure unstable are secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 114
diff changeset
506