annotate hgext/obsolete.py @ 226:0892b91947ef

obsolete: export pretty printed json Will help unavoidable hand fixing.
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Wed, 09 May 2012 12:43:45 +0200
parents f60555898df4
children 5a17c0d41a00
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.
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
25 :extinct: an obsolete changeset without unstable descendant
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
26 (subject to garbage collection)
85
531058dbd703 [obsolete] vocabulary update suggestion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 84
diff changeset
27
531058dbd703 [obsolete] vocabulary update suggestion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 84
diff changeset
28 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
29
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
30
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 Usage and Feature
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
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 Display and Exchange
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
37 ....................
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 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
40
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
41 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
42 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
43
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
44 New commands
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
45 ............
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 a ``debugobsolete`` command has been added.
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 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
50
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
51 Context object
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
52 ..............
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
53
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
54 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
55 False otherwise.
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 revset
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
58 ......
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
59
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
60 Add an ``obsolete()`` entry.
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
61
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
62 repo extension
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
63 ..............
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
64
69
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
65 To Do
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
66 -----
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 * refuse to obsolete published changesets
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 split
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
71
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
72 * handle conflict
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
73
85
531058dbd703 [obsolete] vocabulary update suggestion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 84
diff changeset
74 * handle unstable // out of sync
69
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
75
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
76 """
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
77 import os
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
78 try:
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
79 from cStringIO import StringIO
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
80 except ImportError:
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
81 from StringIO import StringIO
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
82
75
d7b11772f0b5 [obsolete] published changeset can't be obsoleted
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 74
diff changeset
83 from mercurial.i18n import _
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
84
89
757153438e58 [obsolet] base64 encore obsolete rel for pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
85 import base64
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
86 import json
89
757153438e58 [obsolet] base64 encore obsolete rel for pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
87
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
88 from mercurial import util
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
89 from mercurial import context
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
90 from mercurial import revset
40
b9a5a596d9ef proper computation of hidden changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 39
diff changeset
91 from mercurial import scmutil
42
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
92 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
93 from mercurial import pushkey
46
3b0364fc822f Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 44
diff changeset
94 from mercurial import discovery
3b0364fc822f Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 44
diff changeset
95 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
96 from mercurial import commands
114
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
97 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
98 from mercurial import phases
80
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
99 from mercurial.node import hex, bin, short, nullid
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
100 from mercurial.lock import release
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
101
160
24346b78cd99 mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 150
diff changeset
102 try:
24346b78cd99 mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 150
diff changeset
103 from mercurial.localrepo import storecache
24346b78cd99 mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 150
diff changeset
104 storecache('babar') # to trigger import
197
c2d692c8f599 stronger try except for store cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 160
diff changeset
105 except (TypeError, ImportError):
160
24346b78cd99 mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 150
diff changeset
106 def storecache(*args):
24346b78cd99 mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 150
diff changeset
107 return scmutil.filecache(*args, instore=True)
24346b78cd99 mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 150
diff changeset
108
24346b78cd99 mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 150
diff changeset
109
72
774932a6cc0d [obsolete] rationalize doc header.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 71
diff changeset
110 ### Patch changectx
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
111 #############################
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
112
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
113 def obsolete(ctx):
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
114 """is the changeset obsolete by other"""
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
115 if ctx.node()is None:
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
116 return False
112
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
117 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
118
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
119 context.changectx.obsolete = obsolete
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
120
148
8e93e1f67205 obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 144
diff changeset
121 def unstable(ctx):
8e93e1f67205 obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 144
diff changeset
122 """is the changeset unstable (have obsolete ancestor)"""
8e93e1f67205 obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 144
diff changeset
123 if ctx.node() is None:
8e93e1f67205 obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 144
diff changeset
124 return False
8e93e1f67205 obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 144
diff changeset
125 return ctx.rev() in ctx._repo._unstableset
8e93e1f67205 obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 144
diff changeset
126
8e93e1f67205 obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 144
diff changeset
127 context.changectx.unstable = unstable
8e93e1f67205 obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 144
diff changeset
128
213
ea4aa1890b16 obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 212
diff changeset
129 def extinct(ctx):
ea4aa1890b16 obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 212
diff changeset
130 """is the changeset extinct by other"""
ea4aa1890b16 obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 212
diff changeset
131 if ctx.node() is None:
ea4aa1890b16 obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 212
diff changeset
132 return False
ea4aa1890b16 obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 212
diff changeset
133 return ctx.rev() in ctx._repo._extinctset
ea4aa1890b16 obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 212
diff changeset
134
ea4aa1890b16 obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 212
diff changeset
135 context.changectx.extinct = extinct
ea4aa1890b16 obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 212
diff changeset
136
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
137
72
774932a6cc0d [obsolete] rationalize doc header.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 71
diff changeset
138 ### revset
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
139 #############################
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
140
112
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
141
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
142 def revsetobsolete(repo, subset, x):
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
143 """obsolete changesets"""
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
144 args = revset.getargs(x, 0, 0, 'obsolete takes no argument')
112
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
145 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
146
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
147 def revsetunstable(repo, subset, x):
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
148 """non obsolete changesets descendant of obsolete one"""
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
149 args = revset.getargs(x, 0, 0, 'unstable takes no arguments')
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
150 return [r for r in subset if r in repo._unstableset]
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
151
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
152 def revsetsuspended(repo, subset, x):
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
153 """obsolete changesets with non obsolete descendants"""
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
154 args = revset.getargs(x, 0, 0, 'unstable takes no arguments')
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
155 return [r for r in subset if r in repo._suspendedset]
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
156
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
157 def revsetextinct(repo, subset, x):
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
158 """obsolete changesets without obsolete descendants"""
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
159 args = revset.getargs(x, 0, 0, 'unstable takes no arguments')
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
160 return [r for r in subset if r in repo._extinctset]
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
161
143
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
162
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
163 def _obsparents(repo, s):
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
164 """obsolete parents of a subset"""
143
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
165 cs = set()
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
166 nm = repo.changelog.nodemap
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
167 markerbysubj = repo.obsoletestore.subjects
143
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
168 for r in s:
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
169 for p in markerbysubj.get(repo[r].node(), ()):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
170 pr = nm.get(p['object'])
143
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
171 if pr is not None:
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
172 cs.add(pr)
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
173 return cs
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
174
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
175 def revsetobsparents(repo, subset, x):
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
176 """obsolete parents"""
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
177 s = revset.getset(repo, range(len(repo)), x)
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
178 cs = _obsparents(repo, s)
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
179 return [r for r in subset if r in cs]
143
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
180
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
181 def _obsancestors(repo, s):
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
182 """obsolete ancestors of a subset"""
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
183 toproceed = [repo[r].node() for r in s]
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
184 seen = set()
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
185 allsubjects = repo.obsoletestore.subjects
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
186 while toproceed:
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
187 nc = toproceed.pop()
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
188 for mark in allsubjects.get(nc, ()):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
189 np = mark['object']
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
190 if np not in seen:
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
191 seen.add(np)
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
192 toproceed.append(np)
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
193 nm = repo.changelog.nodemap
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
194 cs = set()
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
195 for p in seen:
204
50039b9b535e 2.2 compat: nodemap.get take a single argument now.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 203
diff changeset
196 pr = nm.get(p)
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
197 if pr is not None:
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
198 cs.add(pr)
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
199 return cs
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
200
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
201 def revsetobsancestors(repo, subset, x):
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
202 """obsolete parents"""
143
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
203 s = revset.getset(repo, range(len(repo)), x)
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
204 cs = _obsancestors(repo, s)
143
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
205 return [r for r in subset if r in cs]
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
206
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
207
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
208
71
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
209 ### Other Extension compat
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
210 ############################
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
211
150
f12fd2410a60 obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 148
diff changeset
212
f12fd2410a60 obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 148
diff changeset
213 def buildstate(orig, repo, dest, rebaseset, detach):
f12fd2410a60 obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 148
diff changeset
214 """wrapper for rebase 's buildstate that exclude obsolete changeset"""
f12fd2410a60 obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 148
diff changeset
215 rebaseset = repo.revs('%ld - extinct()', rebaseset)
f12fd2410a60 obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 148
diff changeset
216 return orig(repo, dest, rebaseset, detach)
f12fd2410a60 obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 148
diff changeset
217
f12fd2410a60 obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 148
diff changeset
218
71
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
219 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
220 """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
221 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
222 oldnode = repo[rev].node()
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
223 newnode = repo[newrev].node()
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
224 repo.addobsolete(newnode, oldnode)
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
225 return newrev
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
226
84
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
227 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
228 oldkeep = kwargs.pop('keep', False)
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
229 if oldkeep:
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
230 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
231 kwargs['keep'] = True
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
232 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
233
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
234
71
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
235
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
236 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
237
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
238 revset.symbols["obsolete"] = revsetobsolete
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
239 revset.symbols["unstable"] = revsetunstable
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
240 revset.symbols["suspended"] = revsetsuspended
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
241 revset.symbols["extinct"] = revsetextinct
143
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
242 revset.symbols["obsparents"] = revsetobsparents
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
243 revset.symbols["obsancestors"] = revsetobsancestors
46
3b0364fc822f Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 44
diff changeset
244
3b0364fc822f Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 44
diff changeset
245
42
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
246 try:
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
247 rebase = extensions.find('rebase')
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
248 if rebase:
150
f12fd2410a60 obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 148
diff changeset
249 extensions.wrapfunction(rebase, 'buildstate', buildstate)
42
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
250 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
251 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
252 except KeyError:
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
253 pass # rebase not found
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
254
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
255 # Pushkey mechanism for mutable
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
256 #########################################
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
257
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
258 def pushobsolete(repo, key, old, raw):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
259 """push obsolete relation through pushkey"""
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
260 assert key == "markers"
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
261 l = repo.lock()
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
262 try:
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
263 tmp = StringIO()
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
264 tmp.write(raw)
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
265 tmp.seek(0)
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
266 repo.obsoletestore.load(tmp)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
267 repo.obsoletestore._dirty = True # XXX meh
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
268 return 1
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
269 finally:
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
270 l.release()
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
271
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
272 def listobsolete(repo):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
273 """dump all obsolete relation in
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
274
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
275 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
276 tmp = StringIO()
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
277 repo.obsoletestore.save(tmp)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
278 return {'markers': 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
279
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
280 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
281
214
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
282 ### Discovery wrapping
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
283 #############################
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
284
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
285 class blist(list, object):
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
286 """silly class to have non False but empty list"""
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
287
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
288 def __nonzero__(self):
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
289 return bool(len(self.orig))
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
290
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
291 def wrapfindcommonoutgoing(orig, repo, *args, **kwargs):
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
292 """wrap mercurial.discovery.findcommonoutgoing to remove extinct changeset
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
293
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
294 Such excluded changeset are removed from excluded and will *not* appear
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
295 are excluded secret changeset.
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
296 """
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
297 outgoing = orig(repo, *args, **kwargs)
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
298 orig = outgoing.excluded
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
299 outgoing.excluded = blist(n for n in orig if not repo[n].extinct())
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
300 # when no revision is specified (push everything) a shortcut is taken when
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
301 # nothign was exclude. taking this code path when extinct changeset have
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
302 # been excluded leads to repository corruption.
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
303 outgoing.excluded.orig = orig
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
304 return outgoing
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
305
217
786eb34d93ea obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 215
diff changeset
306 def wrapcheckheads(orig, repo, remote, outgoing, *args, **kwargs):
218
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
307 """wrap mercurial.discovery.checkheads
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
308
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
309 * prevent unstability to be pushed
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
310 * patch remote to ignore obsolete heads on remote
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
311 """
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
312 # do not push instability
217
786eb34d93ea obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 215
diff changeset
313 for h in outgoing.missingheads:
786eb34d93ea obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 215
diff changeset
314 # checking heads only is enought because any thing base on obsolete
786eb34d93ea obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 215
diff changeset
315 # changeset is either obsolete or unstable.
786eb34d93ea obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 215
diff changeset
316 ctx = repo[h]
786eb34d93ea obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 215
diff changeset
317 hint = _("use 'hg stabilize' to get a stable history (or --force to proceed)")
786eb34d93ea obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 215
diff changeset
318 if ctx.unstable():
786eb34d93ea obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 215
diff changeset
319 raise util.Abort(_("Trying to push unstable changeset: %s!") % ctx,
786eb34d93ea obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 215
diff changeset
320 hint=hint)
786eb34d93ea obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 215
diff changeset
321 if ctx.obsolete():
786eb34d93ea obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 215
diff changeset
322 raise util.Abort(_("Trying to push obsolete changeset: %s!") % ctx,
786eb34d93ea obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 215
diff changeset
323 hint=hint)
218
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
324 ### patch remote branch map
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
325 # do not read it this burn eyes
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
326 try:
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
327 if 'oldbranchmap' not in vars(remote):
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
328 remote.oldbranchmap = remote.branchmap
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
329 def branchmap():
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
330 newbm = {}
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
331 oldbm = None
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
332 if (util.safehasattr(phases, 'visiblebranchmap')
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
333 and not util.safehasattr(remote, 'ignorevisiblebranchmap')
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
334 ):
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
335 remote.ignorevisiblebranchmap = False
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
336 remote.branchmap = remote.oldbranchmap
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
337 oldbm = phases.visiblebranchmap(remote)
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
338 remote.branchmap = remote.newbranchmap
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
339 remote.ignorevisiblebranchmap = True
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
340 if oldbm is None:
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
341 oldbm = remote.oldbranchmap()
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
342 for branch, nodes in oldbm.iteritems():
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
343 nodes = list(nodes)
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
344 new = set()
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
345 while nodes:
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
346 n = nodes.pop()
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
347 if n in repo.obsoletestore.objects:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
348 markers = repo.obsoletestore.objects[n]
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
349 for mark in markers:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
350 for newernode in mark['subjects']:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
351 if newernode is not None:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
352 nodes.append(newernode)
218
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
353 else:
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
354 new.add(n)
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
355 if new:
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
356 newbm[branch] = list(new)
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
357 return newbm
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
358 remote.ignorevisiblebranchmap = True
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
359 remote.branchmap = branchmap
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
360 remote.newbranchmap = branchmap
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
361 return orig(repo, remote, outgoing, *args, **kwargs)
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
362 finally:
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
363 remote.__dict__.pop('branchmap', None) # restore class one
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
364 remote.__dict__.pop('oldbranchmap', None)
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
365 remote.__dict__.pop('newbranchmap', None)
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
366 remote.__dict__.pop('ignorevisiblebranchmap', None)
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
367
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
368 # eye are still burning
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
369 def wrapvisiblebranchmap(orig, repo):
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
370 ignore = getattr(repo, 'ignorevisiblebranchmap', None)
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
371 if ignore is None:
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
372 return orig(repo)
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
373 elif ignore:
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
374 return repo.branchmap()
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
375 else:
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
376 return None # break recursion
217
786eb34d93ea obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 215
diff changeset
377
786eb34d93ea obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 215
diff changeset
378
71
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
379 ### New commands
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
380 #############################
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
381
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
382
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
383 def cmddebugobsolete(ui, repo, subject, object):
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
384 """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
385
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
386 The subject is expected to be a newer version of the object"""
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
387 lock = repo.lock()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
388 try:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
389 sub = repo[subject]
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
390 obj = repo[object]
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
391 repo.addobsolete(sub.node(), obj.node())
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
392 finally:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
393 lock.release()
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
394 return 0
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
395
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
396 def cmddebugconvertobsolete(ui, repo):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
397 cnt = 0
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
398 l = repo.lock()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
399 try:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
400 repo._importoldobsolete = True
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
401 store = repo.obsoletestore
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
402 try:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
403 f = repo.opener('obsolete-relations')
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
404 try:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
405 for line in f:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
406 subhex, objhex = line.split()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
407 sub = bin(subhex)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
408 obj = bin(objhex)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
409 newmarker = {
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
410 'subjects': (sub==nullid) and [] or [sub],
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
411 'object': obj,
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
412 'date': util.makedate(),
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
413 'user': ui.username(),
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
414 'reason': 'import from older format.',
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
415 }
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
416 store.new(newmarker)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
417 store._dirty = True
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
418 cnt += 1
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
419 finally:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
420 f.close()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
421 util.unlink(repo.join('obsolete-relations'))
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
422 except IOError:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
423 ui.warn('nothing to do\n')
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
424 pass
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
425 finally:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
426 del repo._importoldobsolete
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
427 l.release()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
428 ui.status('%i obsolete marker converted\n' % cnt)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
429
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
430
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
431 cmdtable = {'debugobsolete': (cmddebugobsolete, [], '<subject> <object>'),
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
432 'debugconvertobsolete': (cmddebugconvertobsolete, [], ''),
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
433 }
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
434
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
435 ### 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
436 #############################
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
437
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
438 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
439 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
440 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
441 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
442 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
443
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
444 def noextinctsvisibleheads(orig, repo):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
445 repo._turn_extinct_secret()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
446 return orig(repo)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
447
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
448 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
449 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
450 extensions.wrapcommand(commands.table, "pull", wrapmayobsoletewc)
214
a140d1857931 obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 213
diff changeset
451 extensions.wrapfunction(discovery, 'findcommonoutgoing', wrapfindcommonoutgoing)
217
786eb34d93ea obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 215
diff changeset
452 extensions.wrapfunction(discovery, 'checkheads', wrapcheckheads)
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
453 extensions.wrapfunction(phases, 'visibleheads', noextinctsvisibleheads)
218
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
454 if util.safehasattr(phases, 'visiblebranchmap'):
ace5608350b6 obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 217
diff changeset
455 extensions.wrapfunction(phases, 'visiblebranchmap', wrapvisiblebranchmap)
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
456
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
457 ### serialisation
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
458 #############################
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
459
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
460 def _obsserialise(obssubrels, flike):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
461 """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
462
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
463 this is for subject -> [objects] mapping
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
464
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
465 format is::
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
466
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
467 <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
468 for sub, objs in obssubrels.iteritems():
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
469 for obj in objs:
80
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
470 if sub is None:
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
471 sub = nullid
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
472 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
473
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
474 def _obsdeserialise(flike):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
475 """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
476
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
477 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
478 rels = {}
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
479 for line in flike:
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
480 subhex, objhex = line.split()
80
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
481 subnode = bin(subhex)
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
482 if subnode == nullid:
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
483 subnode = None
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
484 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
485 return rels
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
486
87
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
487 ### diagnostique tools
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
488 #############################
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
489
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
490 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
491 """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
492 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
493
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
494 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
495 """Return the newer version of an obsolete changeset"""
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
496 toproceed = set([(obs,)])
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
497 # XXX known optimization available
87
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
498 newer = set()
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
499 objectrels = repo.obsoletestore.objects
87
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
500 while toproceed:
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
501 current = toproceed.pop()
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
502 assert len(current) <= 1, 'splitting not handled yet. %r' % current
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
503 if current:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
504 n, = current
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
505 if n in objectrels:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
506 markers = objectrels[n]
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
507 for mark in markers:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
508 toproceed.add(tuple(mark['subjects']))
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
509 else:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
510 newer.add(tuple(current))
132
64d16f07d67f obsolete: alter newerversion return
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 131
diff changeset
511 else:
64d16f07d67f obsolete: alter newerversion return
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 131
diff changeset
512 newer.add(())
87
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
513 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
514
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
515 ### obsolete relation storage
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
516 #############################
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
517 def add2set(d, key, mark):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
518 """add <mark> to a `set` in <d>[<key>]"""
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
519 d.setdefault(key, []).append(mark)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
520
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
521 def markerid(marker):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
522 KEYS = ['subjects', "object", "date", "user", "reason"]
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
523 for key in KEYS:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
524 assert key in marker
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
525 keys = sorted(marker.keys())
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
526 a = util.sha1()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
527 for key in keys:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
528 if key == 'subjects':
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
529 for sub in sorted(marker[key]):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
530 a.update(sub)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
531 elif key == 'id':
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
532 pass
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
533 else:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
534 a.update(str(marker[key]))
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
535 a.update('\0')
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
536 return a.digest()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
537
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
538 class obsoletestore(object):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
539 """Store obsolete relations
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
540
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
541 Relation are stored in three mapping. All mapping have "obsolete markers"
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
542 as values::
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
543
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
544 {'id': "unique id of the obsolete marker"
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
545 'subjects': "0-N newer version of changeset in "object" (as ordered list)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
546 'object': "old and obsolete version"
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
547 'date': "When was this marker created ?"
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
548 'user': "Who did that ?"
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
549 'reason': "Why was it done"
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
550 }
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
551
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
552 Three keys exists
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
553
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
554 :self._markers: "id" -> marker
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
555
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
556 :self.subjects: "subject" -> set(marker)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
557
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
558 :self.objects: "object" -> set(marker)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
559 """
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
560
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
561 def __init__(self):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
562 self._markers = {}
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
563 self.subjects = {}
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
564 self.objects = {}
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
565 self._dirty = False # should be on repo
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
566
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
567 def new(self, marker):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
568 """Add a *new* marker to the store. computing it's ID"""
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
569 mid = marker['id'] = markerid(marker)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
570 self._insert(marker)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
571 self._dirty = True
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
572 return mid
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
573
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
574 def _insert(self, marker):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
575 if marker['id'] not in self._markers:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
576 self._markers[marker['id']] = marker
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
577 add2set(self.objects, marker['object'], marker)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
578 for subj in marker['subjects']:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
579 add2set(self.subjects, subj, marker)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
580
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
581 def save(self, stream):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
582 markers = []
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
583 for mark in self._markers.itervalues():
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
584 jmark = mark.copy()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
585 jmark['id'] = hex(jmark['id'])
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
586 jmark['subjects'] = [hex(n) for n in jmark['subjects']]
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
587 jmark['object'] = hex(jmark['object'])
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
588 markers.append(jmark)
226
0892b91947ef obsolete: export pretty printed json
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 224
diff changeset
589 json.dump(markers, stream, indent=4)
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
590
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
591 def load(self, stream):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
592 for mark in json.load(stream):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
593 mark['id'] = bin(mark['id'])
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
594 mark['subjects'] = [bin(n) for n in mark['subjects']]
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
595 mark['object'] = bin(mark['object'])
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
596 self._insert(mark)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
597
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
598 def writeobsolete(repo):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
599 """wire obsolete data on disk"""
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
600 f = repo.sopener('obsoletemarkers', 'w', atomictemp=True)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
601 try:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
602 repo.obsoletestore.save(f)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
603 repo._dirty = False
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
604 finally:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
605 f.close()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
606
87
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
607
86
7f763bada042 [obsolete] code section comment for repo subclassing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 85
diff changeset
608 ### repo subclassing
7f763bada042 [obsolete] code section comment for repo subclassing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 85
diff changeset
609 #############################
7f763bada042 [obsolete] code section comment for repo subclassing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 85
diff changeset
610
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
611 def reposetup(ui, repo):
47
b73b3e3c9560 Don't overwrite non local repo.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 46
diff changeset
612 if not repo.local():
b73b3e3c9560 Don't overwrite non local repo.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 46
diff changeset
613 return
b73b3e3c9560 Don't overwrite non local repo.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 46
diff changeset
614
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
615 opull = repo.pull
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
616 opush = repo.push
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
617 olock = repo.lock
202
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
618 o_rollback = repo._rollback
210
168ea7d200a0 obsolete: blindly obsolete unstability cache when changeset are added
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 205
diff changeset
619 o_updatebranchcache = repo.updatebranchcache
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
620
203
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
621 # /!\ api change in Hg 2.2 (97efd26eb9576f39590812ea9) /!\
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
622 if util.safehasattr(repo, '_journalfiles'): # Hg 2.2
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
623 o_journalfiles = repo._journalfiles
205
7ba30bd95a88 obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 204
diff changeset
624 o_writejournal = repo._writejournal
203
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
625
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
626
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
627 class obsoletingrepo(repo.__class__):
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
628
53
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
629 ### Public method
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
630 def obsoletedby(self, node):
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
631 """return the set of node that make <node> obsolete (obj)"""
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
632 others = set()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
633 for marker in self.obsoletestore.objects.get(node, []):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
634 others.update(marker['subjects'])
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
635 return others
53
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
636
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
637 def obsolete(self, node):
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
638 """return the set of node that <node> make obsolete (sub)"""
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
639 return set(marker['object'] for marker in self.obsoletestore.subjects.get(node, []))
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
640
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
641 @util.propertycache
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
642 def obsoletestore(self):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
643 if not getattr(self, '_importoldobsolete', False):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
644 try:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
645 f = self.opener('obsolete-relations')
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
646 f.close()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
647 raise util.Abort('old format of obsolete marker detected!\n'
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
648 'run `hg debugconvertobsolete` once.')
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
649 except IOError:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
650 pass
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
651 store = obsoletestore()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
652 try:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
653 f = self.sopener('obsoletemarkers')
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
654 store.load(f)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
655 except IOError:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
656 pass
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
657 return store
53
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
658
109
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
659 @util.propertycache
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
660 def _obsoleteset(self):
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
661 """the set of obsolete revision"""
109
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
662 obs = set()
126
c083fb43daee obsolete: stop using rev as it rebuild the cache every time there is a fault
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 125
diff changeset
663 nm = self.changelog.nodemap
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
664 for obj in self.obsoletestore.objects:
203
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
665 try: # /!\api change in Hg 2.2 (e8d37b78acfb22ae2c1fb126c2)/!\
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
666 rev = nm.get(obj)
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
667 except TypeError: #XXX to remove while breaking Hg 2.1 support
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
668 rev = nm.get(obj, None)
126
c083fb43daee obsolete: stop using rev as it rebuild the cache every time there is a fault
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 125
diff changeset
669 if rev is not None:
c083fb43daee obsolete: stop using rev as it rebuild the cache every time there is a fault
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 125
diff changeset
670 obs.add(rev)
109
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
671 return obs
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
672
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
673 @util.propertycache
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
674 def _unstableset(self):
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
675 """the set of non obsolete revision with obsolete parent"""
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
676 return set(self.revs('(obsolete()::) - obsolete()'))
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
677
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
678 @util.propertycache
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
679 def _suspendedset(self):
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
680 """the set of obsolete parent with non obsolete descendant"""
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
681 return set(self.revs('obsolete() and obsolete()::unstable()'))
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
682
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
683 @util.propertycache
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
684 def _extinctset(self):
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
685 """the set of obsolete parent without non obsolete descendant"""
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
686 return set(self.revs('obsolete() - obsolete()::unstable()'))
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
687
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
688 def _clearobsoletecache(self):
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
689 if '_obsoleteset' in vars(self):
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
690 del self._obsoleteset
210
168ea7d200a0 obsolete: blindly obsolete unstability cache when changeset are added
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 205
diff changeset
691 self._clearunstablecache()
168ea7d200a0 obsolete: blindly obsolete unstability cache when changeset are added
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 205
diff changeset
692
168ea7d200a0 obsolete: blindly obsolete unstability cache when changeset are added
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 205
diff changeset
693 def updatebranchcache(self):
168ea7d200a0 obsolete: blindly obsolete unstability cache when changeset are added
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 205
diff changeset
694 o_updatebranchcache()
168ea7d200a0 obsolete: blindly obsolete unstability cache when changeset are added
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 205
diff changeset
695 self._clearunstablecache()
168ea7d200a0 obsolete: blindly obsolete unstability cache when changeset are added
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 205
diff changeset
696
168ea7d200a0 obsolete: blindly obsolete unstability cache when changeset are added
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 205
diff changeset
697 def _clearunstablecache(self):
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
698 if '_unstableset' in vars(self):
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
699 del self._unstableset
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
700 if '_suspendedset' in vars(self):
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
701 del self._suspendedset
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
702 if '_extinct' in vars(self):
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
703 del self._extinctset
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
704
53
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
705 def addobsolete(self, sub, obj):
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
706 """Add a relation marking that node <sub> is a new version of <obj>"""
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
707 assert sub != obj
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
708 if not repo[obj].phase():
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
709 if sub is None:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
710 self.ui.warn(
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
711 _("trying to kill immutable changeset %(obj)s\n")
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
712 % {'obj': short(obj)})
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
713 if sub is not None:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
714 self.ui.warn(
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
715 _("%(sub)s try to obsolete immutable changeset %(obj)s\n")
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
716 % {'sub': short(sub), 'obj': short(obj)})
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
717 lock = self.lock()
53
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
718 try:
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
719 newmarker = {
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
720 'subjects': (sub==nullid) and [] or [sub],
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
721 'object': obj,
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
722 'date': util.makedate(),
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
723 'user': ui.username(),
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
724 'reason': 'unknown',
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
725 }
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
726 mid = self.obsoletestore.new(newmarker)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
727 self._clearobsoletecache()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
728 self._turn_extinct_secret()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
729 return mid
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
730 finally:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
731 lock.release()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
732
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
733 def _turn_extinct_secret(self):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
734 """ensure all extinct changeset are secret"""
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
735 self._clearobsoletecache()
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
736 # this is mainly for safety purpose
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
737 # both pull and push
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
738 expobs = [c.node() for c in repo.set('extinct() - secret()')]
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
739 phases.retractboundary(repo, 2, expobs)
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
740
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
741 ### Disk IO
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
742
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
743 def lock(self, *args, **kwargs):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
744 l = olock(*args, **kwargs)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
745 if not getattr(l.releasefn, 'obspatched', False):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
746 oreleasefn = l.releasefn
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
747 def releasefn(*args, **kwargs):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
748 if self.obsoletestore._dirty:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
749 writeobsolete(self)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
750 oreleasefn(*args, **kwargs)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
751 releasefn.obspatched = True
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
752 l.releasefn = releasefn
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
753 return l
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
754
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
755 def _readobsrels(self):
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
756 """Read obsolete relation on disk"""
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
757 # XXX handle lock
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
758 try:
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
759 f = self.opener('obsolete-relations')
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
760 try:
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
761 return _obsdeserialise(f)
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
762 finally:
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
763 f.close()
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
764 except IOError:
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
765 return {}
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
766
50
19b22ad56b32 clone support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 47
diff changeset
767
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
768 ### pull // push support
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
769
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
770 def pull(self, remote, *args, **kwargs):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
771 """wrapper around push that push obsolete relation"""
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
772 l = repo.lock()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
773 try:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
774 result = opull(remote, *args, **kwargs)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
775 if 'obsolete' in remote.listkeys('namespaces'):
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
776 tmp = StringIO()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
777 rels = remote.listkeys('obsolete')['markers']
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
778 tmp.write(base64.b64decode(rels))
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
779 tmp.seek(0)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
780 repo.obsoletestore.load(tmp)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
781 repo.obsoletestore._dirty = True # XXX meh
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
782 self._clearobsoletecache()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
783 self._turn_extinct_secret()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
784 return result
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
785 finally:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
786 l.release()
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
787
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
788 def push(self, remote, *args, **opts):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
789 """wrapper around pull that pull obsolete relation"""
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
790 self._turn_extinct_secret()
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
791 result = opush(remote, *args, **opts)
56
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
792 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
793 tmp = StringIO()
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
794 self.obsoletestore.save(tmp)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
795 remote.pushkey('obsolete', 'markers', '', tmp.getvalue())
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
796 self._turn_extinct_secret()
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
797
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
798 return result
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
799
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
800
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
801 ### rollback support
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
802
203
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
803 # /!\ api change in Hg 2.2 (97efd26eb9576f39590812ea9) /!\
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
804 if util.safehasattr(repo, '_journalfiles'): # Hg 2.2
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
805 def _journalfiles(self):
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
806 return o_journalfiles() + (self.sjoin('journal.obsoletemarkers'),)
205
7ba30bd95a88 obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 204
diff changeset
807
7ba30bd95a88 obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 204
diff changeset
808 def _writejournal(self, desc):
7ba30bd95a88 obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 204
diff changeset
809 """wrapped version of _writejournal that save obsolete data"""
7ba30bd95a88 obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 204
diff changeset
810 o_writejournal(desc)
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
811 filename = 'obsoletemarkers'
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
812 filepath = self.sjoin(filename)
205
7ba30bd95a88 obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 204
diff changeset
813 if os.path.exists(filepath):
7ba30bd95a88 obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 204
diff changeset
814 journalname = 'journal.' + filename
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
815 journalpath = self.sjoin(journalname)
205
7ba30bd95a88 obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 204
diff changeset
816 util.copyfile(filepath, journalpath)
7ba30bd95a88 obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 204
diff changeset
817
203
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
818 else: # XXX remove this bloc while breaking support to Hg 2.1
205
7ba30bd95a88 obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 204
diff changeset
819 def _writejournal(self, desc):
203
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
820 """wrapped version of _writejournal that save obsolete data"""
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
821 entries = list(o_writejournal(desc))
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
822 filename = 'obsoletemarkers'
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
823 filepath = self.sjoin(filename)
203
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
824 if os.path.exists(filepath):
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
825 journalname = 'journal.' + filename
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
826 journalpath = self.sjoin(journalname)
203
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
827 util.copyfile(filepath, journalpath)
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
828 entries.append(journalpath)
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
829 return tuple(entries)
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
830
205
7ba30bd95a88 obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 204
diff changeset
831 def _rollback(self, dryrun, force):
202
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
832 """wrapped version of _rollback that restore obsolete data"""
205
7ba30bd95a88 obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 204
diff changeset
833 ret = o_rollback(dryrun, force)
202
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
834 if not (ret or dryrun): #rollback did not failed
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
835 src = self.sjoin('undo.obsoletemarkers')
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
836 dst = self.sjoin('obsoletemarkers')
202
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
837 if os.path.exists(src):
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
838 util.rename(src, dst)
205
7ba30bd95a88 obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 204
diff changeset
839 elif os.path.exists(dst):
7ba30bd95a88 obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 204
diff changeset
840 # If no state was saved because the file did not existed before.
202
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
841 os.unlink(dst)
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
842 # invalidate cache
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
843 self.__dict__.pop('obsoletestore', None)
202
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
844 return ret
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
845
160
24346b78cd99 mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 150
diff changeset
846 @storecache('00changelog.i')
114
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
847 def changelog(self):
215
0eceb5a48485 obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 214
diff changeset
848 # << copy pasted from mercurila source
0eceb5a48485 obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 214
diff changeset
849 c = changelog.changelog(self.sopener)
0eceb5a48485 obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 214
diff changeset
850 if 'HG_PENDING' in os.environ:
0eceb5a48485 obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 214
diff changeset
851 p = os.environ['HG_PENDING']
0eceb5a48485 obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 214
diff changeset
852 if p.startswith(self.root):
0eceb5a48485 obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 214
diff changeset
853 c.readpending('00changelog.i.a')
0eceb5a48485 obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 214
diff changeset
854 # >> end of the copy paste
0eceb5a48485 obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 214
diff changeset
855 old = c.__dict__.pop('hiddenrevs', ())
122
c75a73209f1e Locking while writing obsolete data.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 121
diff changeset
856 if old:
c75a73209f1e Locking while writing obsolete data.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 121
diff changeset
857 ui.warn("old wasn't empty ? %r" % old)
215
0eceb5a48485 obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 214
diff changeset
858 def _sethidden(c, value):
114
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
859 assert not value
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
860
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
861
215
0eceb5a48485 obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 214
diff changeset
862 class hchangelog(c.__class__):
114
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
863 @util.propertycache
215
0eceb5a48485 obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 214
diff changeset
864 def hiddenrevs(c):
114
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
865 shown = ['not obsolete()', '.', 'bookmark()', 'tagged()',
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
866 'public()']
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
867 basicquery = 'obsolete() - (::(%s))' % (' or '.join(shown))
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
868 # !!! self is repo not changelog
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
869 result = set(scmutil.revrange(self, [basicquery]))
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
870 return result
215
0eceb5a48485 obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 214
diff changeset
871 c.__class__ = hchangelog
0eceb5a48485 obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 214
diff changeset
872 return c
114
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
873
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
874 repo.__class__ = obsoletingrepo
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
875
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
876 if False:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
877 expobs = [c.node() for c in repo.set('extinct() - secret()')]
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
878 if expobs: # do not lock in nothing move. locking for peanut make hgview reload on any command
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
879 lock = repo.lock()
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
880 try:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
881 expobs = [c.node() for c in repo.set('extinct() - secret()')]
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
882 phases.retractboundary(repo, 2, expobs)
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
883 finally:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
884 lock.release()
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
885
115
d60eddda9546 add an option to ensure unstable are secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 114
diff changeset
886