annotate hgext/obsolete.py @ 88:64fe5a4f877e

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