annotate hgext/obsolete.py @ 203:9799d0aa53c8

[obsolete] add supprt for futur Hg 2.2
author Alain Leufroy <alain.leufroy@logilab.fr>
date Mon, 16 Apr 2012 10:51:40 +0200
parents 83b7e2c62ac3
children 50039b9b535e
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
757153438e58 [obsolet] base64 encore obsolete rel for pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
86
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
87 from mercurial import util
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
88 from mercurial import context
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
89 from mercurial import revset
40
b9a5a596d9ef proper computation of hidden changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 39
diff changeset
90 from mercurial import scmutil
42
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
91 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
92 from mercurial import pushkey
46
3b0364fc822f Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 44
diff changeset
93 from mercurial import discovery
3b0364fc822f Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 44
diff changeset
94 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
95 from mercurial import commands
114
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
96 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
97 from mercurial import phases
80
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
98 from mercurial.node import hex, bin, short, nullid
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
99 from mercurial.lock import release
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
100
160
24346b78cd99 mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 150
diff changeset
101 try:
24346b78cd99 mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 150
diff changeset
102 from mercurial.localrepo import storecache
24346b78cd99 mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 150
diff changeset
103 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
104 except (TypeError, ImportError):
160
24346b78cd99 mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 150
diff changeset
105 def storecache(*args):
24346b78cd99 mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 150
diff changeset
106 return scmutil.filecache(*args, instore=True)
24346b78cd99 mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 150
diff changeset
107
24346b78cd99 mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 150
diff changeset
108
72
774932a6cc0d [obsolete] rationalize doc header.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 71
diff changeset
109 ### Patch changectx
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
110 #############################
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 def obsolete(ctx):
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
113 """is the changeset obsolete by other"""
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
114 if ctx.node()is None:
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
115 return False
112
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
116 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
117
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
118 context.changectx.obsolete = obsolete
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
119
148
8e93e1f67205 obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 144
diff changeset
120 def unstable(ctx):
8e93e1f67205 obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 144
diff changeset
121 """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
122 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
123 return False
8e93e1f67205 obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 144
diff changeset
124 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
125
8e93e1f67205 obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 144
diff changeset
126 context.changectx.unstable = unstable
8e93e1f67205 obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 144
diff changeset
127
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
128
72
774932a6cc0d [obsolete] rationalize doc header.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 71
diff changeset
129 ### revset
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
130 #############################
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
131
112
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
132
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
133 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
134 """obsolete changesets"""
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
135 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
136 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
137
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
138 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
139 """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
140 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
141 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
142
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
143 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
144 """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
145 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
146 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
147
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
148 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
149 """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
150 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
151 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
152
143
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
153
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
154 def _obsparents(repo, s):
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
155 """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
156 cs = set()
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
157 nm = repo.changelog.nodemap
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
158 for r in s:
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
159 for p in repo._obssubrels.get(repo[r].node(), ()):
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
160 pr = nm.get(p, None)
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
161 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
162 cs.add(pr)
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
163 return cs
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
164
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
165 def revsetobsparents(repo, subset, x):
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
166 """obsolete parents"""
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
167 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
168 cs = _obsparents(repo, s)
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
169 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
170
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
171 def _obsancestors(repo, s):
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
172 """obsolete ancestors of a subset"""
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
173 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
174 seen = set()
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
175 while toproceed:
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
176 nc = toproceed.pop()
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
177 for np in repo._obssubrels.get(nc, ()):
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
178 if np not in seen:
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
179 seen.add(np)
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
180 toproceed.append(np)
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
181 nm = repo.changelog.nodemap
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
182 cs = set()
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
183 for p in seen:
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
184 pr = nm.get(p, None)
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
185 if pr is not None:
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
186 cs.add(pr)
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
187 return cs
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
188
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
189 def revsetobsancestors(repo, subset, x):
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
190 """obsolete parents"""
143
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
191 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
192 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
193 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
194
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
195
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
196
71
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
197 ### Other Extension compat
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
198 ############################
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
199
150
f12fd2410a60 obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 148
diff changeset
200
f12fd2410a60 obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 148
diff changeset
201 def buildstate(orig, repo, dest, rebaseset, detach):
f12fd2410a60 obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 148
diff changeset
202 """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
203 rebaseset = repo.revs('%ld - extinct()', rebaseset)
f12fd2410a60 obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 148
diff changeset
204 return orig(repo, dest, rebaseset, detach)
f12fd2410a60 obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 148
diff changeset
205
f12fd2410a60 obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 148
diff changeset
206
71
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
207 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
208 """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
209 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
210 oldnode = repo[rev].node()
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
211 newnode = repo[newrev].node()
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
212 repo.addobsolete(newnode, oldnode)
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
213 return newrev
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
214
84
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
215 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
216 oldkeep = kwargs.pop('keep', False)
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
217 if oldkeep:
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
218 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
219 kwargs['keep'] = True
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
220 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
221
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
222
71
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
223
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
224 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
225
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
226 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
227 revset.symbols["unstable"] = revsetunstable
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
228 revset.symbols["suspended"] = revsetsuspended
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
229 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
230 revset.symbols["obsparents"] = revsetobsparents
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
231 revset.symbols["obsancestors"] = revsetobsancestors
46
3b0364fc822f Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 44
diff changeset
232
3b0364fc822f Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 44
diff changeset
233
42
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
234 try:
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
235 rebase = extensions.find('rebase')
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
236 if rebase:
150
f12fd2410a60 obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 148
diff changeset
237 extensions.wrapfunction(rebase, 'buildstate', buildstate)
42
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
238 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
239 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
240 except KeyError:
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
241 pass # rebase not found
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
242
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
243 # Pushkey mechanism for mutable
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
244 #########################################
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
245
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
246 def pushobsolete(repo, key, old, raw):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
247 """push obsolete relation through pushkey"""
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
248 assert key == "relations"
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
249 w = repo.wlock()
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
250 try:
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
251 tmp = StringIO()
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
252 tmp.write(raw)
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
253 tmp.seek(0)
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
254 relations = _obsdeserialise(tmp)
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
255 for sub, objs in relations.iteritems():
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
256 for obj in objs:
58
2ba7355f6e11 [obsolete] Fix pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 56
diff changeset
257 try:
2ba7355f6e11 [obsolete] Fix pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 56
diff changeset
258 repo.addobsolete(sub, obj)
2ba7355f6e11 [obsolete] Fix pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 56
diff changeset
259 except error.RepoLookupError:
2ba7355f6e11 [obsolete] Fix pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 56
diff changeset
260 pass
2ba7355f6e11 [obsolete] Fix pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 56
diff changeset
261 return 0
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
262 finally:
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
263 w.release()
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
264
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
265 def listobsolete(repo):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
266 """dump all obsolete relation in
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
267
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
268 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
269 tmp = StringIO()
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
270 _obsserialise(repo._obssubrels, tmp)
89
757153438e58 [obsolet] base64 encore obsolete rel for pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
271 return {'relations': base64.b64encode(tmp.getvalue())}
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
272
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
273 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
274
71
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
275 ### New commands
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
276 #############################
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
277
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
278
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
279 def cmddebugobsolete(ui, repo, subject, object):
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
280 """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
281
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
282 The subject is expected to be a newer version of the object"""
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
283 sub = repo[subject]
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
284 obj = repo[object]
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
285 repo.addobsolete(sub.node(), obj.node())
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
286 return 0
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
287
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
288 cmdtable = {'debugobsolete': (cmddebugobsolete, [], '<subject> <object>')}
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
289
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
290 ### 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
291 #############################
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
292
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
293 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
294 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
295 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
296 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
297 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
298
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
299 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
300 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
301 extensions.wrapcommand(commands.table, "pull", wrapmayobsoletewc)
9906560f585e [obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 75
diff changeset
302
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
303 ### serialisation
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
304 #############################
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
305
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
306 def _obsserialise(obssubrels, flike):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
307 """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
308
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
309 this is for subject -> [objects] mapping
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
310
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
311 format is::
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
312
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
313 <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
314 for sub, objs in obssubrels.iteritems():
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
315 for obj in objs:
80
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
316 if sub is None:
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
317 sub = nullid
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
318 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
319
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
320 def _obsdeserialise(flike):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
321 """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
322
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
323 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
324 rels = {}
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
325 for line in flike:
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
326 subhex, objhex = line.split()
80
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
327 subnode = bin(subhex)
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
328 if subnode == nullid:
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
329 subnode = None
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
330 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
331 return rels
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
332
87
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
333 ### diagnostique tools
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
334 #############################
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
335
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
336 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
337 """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
338 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
339
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
340 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
341 """Return the newer version of an obsolete changeset"""
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
342 toproceed = set([obs])
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
343 # XXX know optimization available
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
344 newer = set()
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
345 while toproceed:
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
346 current = toproceed.pop()
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
347 if current in repo._obsobjrels:
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
348 toproceed.update(repo._obsobjrels[current])
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
349 elif current is not None: # None is kill
132
64d16f07d67f obsolete: alter newerversion return
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 131
diff changeset
350 newer.add((current,))
64d16f07d67f obsolete: alter newerversion return
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 131
diff changeset
351 else:
64d16f07d67f obsolete: alter newerversion return
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 131
diff changeset
352 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
353 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
354
246b8fefd0a5 [evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 86
diff changeset
355
86
7f763bada042 [obsolete] code section comment for repo subclassing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 85
diff changeset
356 ### repo subclassing
7f763bada042 [obsolete] code section comment for repo subclassing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 85
diff changeset
357 #############################
7f763bada042 [obsolete] code section comment for repo subclassing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 85
diff changeset
358
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
359 def reposetup(ui, repo):
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
360
47
b73b3e3c9560 Don't overwrite non local repo.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 46
diff changeset
361 if not repo.local():
b73b3e3c9560 Don't overwrite non local repo.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 46
diff changeset
362 return
b73b3e3c9560 Don't overwrite non local repo.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 46
diff changeset
363
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
364 opull = repo.pull
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
365 opush = repo.push
202
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
366 o_rollback = repo._rollback
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
367 ocancopy = repo.cancopy
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
368
203
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
369 # /!\ 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
370 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
371 o_journalfiles = repo._journalfiles
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
372 else: # XXX remove this bloc while breaking support to Hg 2.1
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
373 o_writejournal = repo._writejournal
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
374
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
375
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
376 class obsoletingrepo(repo.__class__):
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
377
53
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
378 ### Public method
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
379 def obsoletedby(self, node):
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
380 """return the set of node that make <node> obsolete (obj)"""
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
381 return self._obsobjrels.get(node, set())
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
382
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
383 def obsolete(self, node):
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
384 """return the set of node that <node> make obsolete (sub)"""
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
385 return self._obssubrels.get(node, set())
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
386
109
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
387 @util.propertycache
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
388 def _obsoleteset(self):
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
389 """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
390 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
391 nm = self.changelog.nodemap
109
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
392 for obj in self._obsobjrels:
203
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
393 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
394 rev = nm.get(obj)
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
395 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
396 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
397 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
398 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
399 return obs
a2e8057117d3 obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 95
diff changeset
400
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
401 @util.propertycache
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
402 def _unstableset(self):
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
403 """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
404 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
405
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
406 @util.propertycache
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
407 def _suspendedset(self):
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
408 """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
409 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
410
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
411 @util.propertycache
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
412 def _extinctset(self):
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
413 """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
414 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
415
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
416 def _clearobsoletecache(self):
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
417 if '_obsobjrels' in vars(self):
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
418 del self._obsobjrels
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
419 if '_obssubrels' in vars(self):
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
420 del self._obssubrels
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
421 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
422 del self._obsoleteset
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
423 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
424 del self._unstableset
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
425 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
426 del self._suspendedset
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
427 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
428 del self._extinctset
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
429
53
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
430 def addobsolete(self, sub, obj):
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
431 """Add a relation marking that node <sub> is a new version of <obj>"""
80
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
432 if sub == nullid:
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
433 sub = None
129
3ad25876ee68 obsolete: lazy relation adding
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 128
diff changeset
434 if obj in self._obssubrels.get(sub, set()):
3ad25876ee68 obsolete: lazy relation adding
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 128
diff changeset
435 return 0
131
3124889cad55 keep branch on amend
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 129
diff changeset
436 if sub == obj:
3124889cad55 keep branch on amend
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 129
diff changeset
437 return 0
53
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
438 self._obssubrels.setdefault(sub, set()).add(obj)
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
439 self._obsobjrels.setdefault(obj, set()).add(sub)
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
440 try:
112
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
441 if self[obj].phase() == 0:
95
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
442 if sub is None:
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
443 self.ui.warn(
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
444 _("trying to kill immutable changeset %(obj)s\n")
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
445 % {'obj': short(obj)})
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
446 if sub is not None:
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
447 self.ui.warn(
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
448 _("%(sub)s try to obsolete immutable changeset %(obj)s\n")
5dcece86aeb0 improve tuto
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 89
diff changeset
449 % {'sub': short(sub), 'obj': short(obj)})
53
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
450 self.changelog.hiddenrevs.add(repo[obj].rev())
75
d7b11772f0b5 [obsolete] published changeset can't be obsoleted
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 74
diff changeset
451 except (error.RepoLookupError, error.LookupError):
53
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
452 pass #unknow revision (but keep propagating the data
0bcbf690dfca reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 52
diff changeset
453 self._writeobsrels()
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
454 self._clearobsoletecache()
129
3ad25876ee68 obsolete: lazy relation adding
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 128
diff changeset
455 return 1
43
20fca307d9f0 more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 42
diff changeset
456
20fca307d9f0 more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 42
diff changeset
457 ### obsolete storage
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
458 @util.propertycache
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
459 def _obsobjrels(self):
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
460 """{<old-node> -> set(<new-node>)}
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
461
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
462 also compute hidden revision"""
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
463 #reverse sub -> objs mapping
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
464 objrels = {}
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
465 for sub, objs in self._obssubrels.iteritems():
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
466 for obj in objs:
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
467 objrels.setdefault(obj, set()).add(sub)
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
468 return objrels
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
469
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
470 @util.propertycache
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
471 def _obssubrels(self):
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
472 """{<new-node> -> set(<old-node>)}"""
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
473 return self._readobsrels()
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
474
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
475
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
476
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
477
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
478 ### Disk IO
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
479 def _readobsrels(self):
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
480 """Write obsolete relation on disk"""
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
481 # XXX handle lock
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
482 try:
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
483 f = self.opener('obsolete-relations')
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
484 try:
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
485 return _obsdeserialise(f)
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
486 finally:
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
487 f.close()
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
488 except IOError:
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
489 return {}
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
490
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
491 def _writeobsrels(self):
37
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
492 """Write obsolete relation on disk"""
9493ffa68633 Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 32
diff changeset
493 # XXX handle lock
121
7280eede21ea obsolete: improve locking when writing obsolete data
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 120
diff changeset
494 lock = self.wlock()
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
495 try:
121
7280eede21ea obsolete: improve locking when writing obsolete data
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 120
diff changeset
496 f = self.opener('obsolete-relations', 'w', atomictemp=True)
83
97a5c943db19 Compat with mercurial 1.9.2
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 80
diff changeset
497 try:
121
7280eede21ea obsolete: improve locking when writing obsolete data
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 120
diff changeset
498 _obsserialise(self._obssubrels, f)
7280eede21ea obsolete: improve locking when writing obsolete data
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 120
diff changeset
499 try:
7280eede21ea obsolete: improve locking when writing obsolete data
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 120
diff changeset
500 f.rename()
7280eede21ea obsolete: improve locking when writing obsolete data
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 120
diff changeset
501 except AttributeError: # old version
7280eede21ea obsolete: improve locking when writing obsolete data
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 120
diff changeset
502 f.close()
7280eede21ea obsolete: improve locking when writing obsolete data
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 120
diff changeset
503 finally:
83
97a5c943db19 Compat with mercurial 1.9.2
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 80
diff changeset
504 f.close()
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
505 finally:
121
7280eede21ea obsolete: improve locking when writing obsolete data
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 120
diff changeset
506 lock.release()
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
507
50
19b22ad56b32 clone support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 47
diff changeset
508 ### local clone support
19b22ad56b32 clone support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 47
diff changeset
509
19b22ad56b32 clone support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 47
diff changeset
510 def cancopy(self):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
511 """wrapper on cancopy that deny copy if there is obsolete relation"""
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
512 return ocancopy() and not bool(self._obsobjrels) # you can't copy if there is obsolete
50
19b22ad56b32 clone support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 47
diff changeset
513
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
514 ### pull // push support
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
515
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
516 def pull(self, remote, *args, **kwargs):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
517 """wrapper around push that push obsolete relation"""
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
518 result = opull(remote, *args, **kwargs)
56
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
519 if 'obsolete' in remote.listkeys('namespaces'):
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
520 tmp = StringIO()
89
757153438e58 [obsolet] base64 encore obsolete rel for pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
521 rels = remote.listkeys('obsolete')['relations']
757153438e58 [obsolet] base64 encore obsolete rel for pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
522 tmp.write(base64.b64decode(rels))
56
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
523 tmp.seek(0)
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
524 obsrels = _obsdeserialise(tmp)
56
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
525 for sub, objs in obsrels.iteritems():
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
526 for obj in objs:
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
527 self.addobsolete(sub, obj)
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
528 return result
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
529
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
530 def push(self, remote, *args, **opts):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
531 """wrapper around pull that pull obsolete relation"""
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
532 result = opush(remote, *args, **opts)
56
27f9c0d0a996 [obsolete] Update pushkey code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 54
diff changeset
533 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
534 tmp = StringIO()
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
535 _obsserialise(self._obssubrels, tmp)
58
2ba7355f6e11 [obsolete] Fix pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 56
diff changeset
536 remote.pushkey('obsolete', 'relations', '', tmp.getvalue())
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
537
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
538 return result
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
539
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
540
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
541 ### rollback support
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
542
203
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
543 # /!\ 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
544 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
545 def _journalfiles(self):
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
546 return o_journalfiles() + ('journal.obsolete-relations',)
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
547 else: # XXX remove this bloc while breaking support to Hg 2.1
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
548 def _writejournal(self, desc):
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
549 """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
550 entries = list(o_writejournal(desc))
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
551 filename = 'obsolete-relations'
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
552 filepath = self.join(filename)
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
553 if os.path.exists(filepath):
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
554 journalname = 'journal.' + filename
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
555 journalpath = self.join(journalname)
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
556 util.copyfile(filepath, journalpath)
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
557 entries.append(journalpath)
9799d0aa53c8 [obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 202
diff changeset
558 return tuple(entries)
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
559
202
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
560 def _rollback(self, dryrun=False, **kwargs):
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
561 """wrapped version of _rollback that restore obsolete data"""
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
562 ret = o_rollback(dryrun, **kwargs)
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
563 if not (ret or dryrun): #rollback did not failed
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
564 src = self.join('undo.obsolete-relations')
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
565 dst = self.join('obsolete-relations')
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
566 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
567 util.rename(src, dst)
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
568 elif os.path.exists(dst): #unlink in any case
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
569 os.unlink(dst)
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
570 # invalidate cache
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
571 self.__dict__.pop('_obssubrels', None)
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
572 self.__dict__.pop('_obsobjrels', None)
83b7e2c62ac3 [obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 197
diff changeset
573 return ret
52
62bdc2567099 Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 51
diff changeset
574
160
24346b78cd99 mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 150
diff changeset
575 @storecache('00changelog.i')
114
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
576 def changelog(self):
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
577 changelog = getattr(super(obsoletingrepo, self), 'changelog')
122
c75a73209f1e Locking while writing obsolete data.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 121
diff changeset
578 old = changelog.__dict__.pop('hiddenrevs', ())
c75a73209f1e Locking while writing obsolete data.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 121
diff changeset
579 if old:
c75a73209f1e Locking while writing obsolete data.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 121
diff changeset
580 ui.warn("old wasn't empty ? %r" % old)
114
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
581 def _sethidden(changelog, value):
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
582 assert not value
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
583
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
584
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
585 class hchangelog(changelog.__class__):
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
586 @util.propertycache
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
587 def hiddenrevs(changelog):
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
588 shown = ['not obsolete()', '.', 'bookmark()', 'tagged()',
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
589 'public()']
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
590 basicquery = 'obsolete() - (::(%s))' % (' or '.join(shown))
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
591 # !!! self is repo not changelog
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
592 result = set(scmutil.revrange(self, [basicquery]))
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
593 return result
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
594 changelog.__class__ = hchangelog
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
595 return changelog
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
596
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
597
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
598
1a64195e2b09 nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 112
diff changeset
599
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
600 repo.__class__ = obsoletingrepo
115
d60eddda9546 add an option to ensure unstable are secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 114
diff changeset
601 if repo.ui.configbool('obsolete', 'secret-unstable', True):
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
602 symbol = 'obsolete()'
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
603 else:
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
604 symbol = 'extinct()'
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
605
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
606 expobs = [c.node() for c in repo.set('%s - secret()' % symbol)]
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
607 if expobs: # do not lock in nothing move. locking for peanut make hgview reload on any command
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
608 lock = repo.lock()
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
609 try:
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
610 phases.retractboundary(repo, 2, expobs)
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
611 finally:
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
612 lock.release()
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
613
115
d60eddda9546 add an option to ensure unstable are secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 114
diff changeset
614