Mercurial > evolve
annotate hgext/obsolete.py @ 433:aa1255c2ac8f
obsolete: move version checks at the start of the file
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Tue, 07 Aug 2012 14:32:54 +0200 |
parents | 6347bc69b49a |
children | 9863e196cc65 |
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 |
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
22 :obsolete: a changeset that has been replaced by another one. |
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
23 :unstable: a changeset that is not obsolete but has an obsolete ancestor. |
85
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. |
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
25 :extinct: an obsolete changeset without unstable descendant. |
135
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 Usage and Feature |
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 |
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
35 New commands |
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
36 ------------ |
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
37 |
415
ea7f2a4ad530
obsolete: fix doc, rebase no longer aborts with --keep
Patrick Mezard <patrick@mezard.eu>
parents:
409
diff
changeset
|
38 Note that rebased changesets are now marked obsolete instead of being stripped. |
275
336210dada95
obsolete: make rebase abort with --keep
Patrick Mezard <patrick@mezard.eu>
parents:
274
diff
changeset
|
39 |
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
40 """ |
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
41 |
379
881c3eca314a
Wider triggering of the debug marker abort
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
378
diff
changeset
|
42 import os, sys |
54
ad1a4fb0fc49
Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
53
diff
changeset
|
43 try: |
ad1a4fb0fc49
Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
53
diff
changeset
|
44 from cStringIO import StringIO |
ad1a4fb0fc49
Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
53
diff
changeset
|
45 except ImportError: |
ad1a4fb0fc49
Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
53
diff
changeset
|
46 from StringIO import StringIO |
ad1a4fb0fc49
Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
53
diff
changeset
|
47 |
75
d7b11772f0b5
[obsolete] published changeset can't be obsoleted
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
74
diff
changeset
|
48 from mercurial.i18n import _ |
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
49 |
224 | 50 import json |
89
757153438e58
[obsolet] base64 encore obsolete rel for pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
51 |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
52 import struct |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
53 from mercurial import util, base85 |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
54 |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
55 _pack = struct.pack |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
56 _unpack = struct.unpack |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
57 |
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
58 from mercurial import util |
433
aa1255c2ac8f
obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
432
diff
changeset
|
59 |
aa1255c2ac8f
obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
432
diff
changeset
|
60 try: |
aa1255c2ac8f
obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
432
diff
changeset
|
61 from mercurial import obsolete |
aa1255c2ac8f
obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
432
diff
changeset
|
62 obsolete._enabled = True |
aa1255c2ac8f
obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
432
diff
changeset
|
63 except ImportError: |
aa1255c2ac8f
obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
432
diff
changeset
|
64 raise util.Abort('Obsolete extension requires Mercurial 2.3 (or later)') |
aa1255c2ac8f
obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
432
diff
changeset
|
65 |
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
66 from mercurial import context |
39 | 67 from mercurial import revset |
40
b9a5a596d9ef
proper computation of hidden changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
39
diff
changeset
|
68 from mercurial import scmutil |
42
eb6a06d7eae3
Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
41
diff
changeset
|
69 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
|
70 from mercurial import pushkey |
46
3b0364fc822f
Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
44
diff
changeset
|
71 from mercurial import discovery |
3b0364fc822f
Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
44
diff
changeset
|
72 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
|
73 from mercurial import commands |
114
1a64195e2b09
nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
112
diff
changeset
|
74 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
|
75 from mercurial import phases |
80
5d029a358252
[obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
79
diff
changeset
|
76 from mercurial.node import hex, bin, short, nullid |
52
62bdc2567099
Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
51
diff
changeset
|
77 from mercurial.lock import release |
252
470232cea503
[obsolete] fix new api: use the new phase cache api
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
228
diff
changeset
|
78 from mercurial import localrepo |
276
f26e9bc5f7fc
obsolete: use new-style command registration
Patrick Mezard <patrick@mezard.eu>
parents:
275
diff
changeset
|
79 from mercurial import cmdutil |
299
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
80 from mercurial import templatekw |
428
1c82147e9395
obsolete: remove 2.2 compat hack
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
423
diff
changeset
|
81 from mercurial.localrepo import storecache |
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
82 |
432
6347bc69b49a
obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
431
diff
changeset
|
83 # This extension hold the following code |
6347bc69b49a
obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
431
diff
changeset
|
84 # |
6347bc69b49a
obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
431
diff
changeset
|
85 # - Extension Helper code |
6347bc69b49a
obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
431
diff
changeset
|
86 # - ... |
6347bc69b49a
obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
431
diff
changeset
|
87 # - Older format compat |
160
24346b78cd99
mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
150
diff
changeset
|
88 |
432
6347bc69b49a
obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
431
diff
changeset
|
89 |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
90 |
432
6347bc69b49a
obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
431
diff
changeset
|
91 ##################################################################### |
6347bc69b49a
obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
431
diff
changeset
|
92 ### Extension helper #### |
6347bc69b49a
obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
431
diff
changeset
|
93 ##################################################################### |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
94 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
95 class exthelper(object): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
96 """Helper for modular extension setup |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
97 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
98 A single helper should be intanciated for each extension. Helper method are |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
99 then used as decorator for various purpose. |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
100 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
101 All decorator returns the original function and may be chained. |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
102 """ |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
103 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
104 def __init__(self): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
105 self._uicallables = [] |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
106 self._extcallables = [] |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
107 self._repocallables = [] |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
108 self._revsetsymbols = [] |
431
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
109 self._templatekws = [] |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
110 self._commandwrappers = [] |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
111 self._extcommandwrappers = [] |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
112 self._functionwrappers = [] |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
113 self._duckpunchers = [] |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
114 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
115 def final_uisetup(self, ui): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
116 """Method to be used as a the extension uisetup |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
117 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
118 The following operations belong here: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
119 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
120 - Changes to ui.__class__ . The ui object that will be used to run the |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
121 command has not yet been created. Changes made here will affect ui |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
122 objects created after this, and in particular the ui that will be |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
123 passed to runcommand |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
124 - Command wraps (extensions.wrapcommand) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
125 - Changes that need to be visible by other extensions: because |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
126 initialization occurs in phases (all extensions run uisetup, then all |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
127 run extsetup), a change made here will be visible by other extensions |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
128 during extsetup |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
129 - Monkeypatches or function wraps (extensions.wrapfunction) of dispatch |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
130 module members |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
131 - Setup of pre-* and post-* hooks |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
132 - pushkey setup |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
133 """ |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
134 for cont, funcname, func in self._duckpunchers: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
135 setattr(cont, funcname, func) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
136 for command, wrapper in self._commandwrappers: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
137 extensions.wrapcommand(commands.table, command, wrapper) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
138 for cont, funcname, wrapper in self._functionwrappers: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
139 extensions.wrapfunction(cont, funcname, wrapper) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
140 for c in self._uicallables: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
141 c(ui) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
142 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
143 def final_extsetup(self, ui): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
144 """Method to be used as a the extension extsetup |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
145 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
146 The following operations belong here: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
147 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
148 - Changes depending on the status of other extensions. (if extensions.find('mq')) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
149 - Add a global option to all commands |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
150 - Extend revsets |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
151 """ |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
152 knownexts = {} |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
153 for name, symbol in self._revsetsymbols: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
154 revset.symbols[name] = symbol |
431
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
155 for name, kw in self._templatekws: |
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
156 templatekw.keywords[name] = kw |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
157 for ext, command, wrapper in self._extcommandwrappers: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
158 if ext not in knownexts: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
159 e = extensions.find('rebase') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
160 if e is None: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
161 raise util.Abort('extension %s not found' %e) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
162 knownexts[ext] = e.cmdtable |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
163 extensions.wrapcommand(knownexts[ext], commands, wrapper) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
164 for c in self._extcallables: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
165 c(ui) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
166 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
167 def final_reposetup(self, ui, repo): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
168 """Method to be used as a the extension reposetup |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
169 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
170 The following operations belong here: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
171 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
172 - All hooks but pre-* and post-* |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
173 - Modify configuration variables |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
174 - Changes to repo.__class__, repo.dirstate.__class__ |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
175 """ |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
176 for c in self._repocallables: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
177 c(ui, repo) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
178 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
179 def uisetup(self, call): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
180 """Decorated function will be executed during uisetup |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
181 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
182 example:: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
183 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
184 @eh.uisetup |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
185 def setupbabar(ui): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
186 print 'this is uisetup!' |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
187 """ |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
188 self._uicallables.append(call) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
189 return call |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
190 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
191 def extsetup(self, call): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
192 """Decorated function will be executed during extsetup |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
193 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
194 example:: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
195 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
196 @eh.extsetup |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
197 def setupcelestine(ui): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
198 print 'this is extsetup!' |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
199 """ |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
200 self._uicallables.append(call) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
201 return call |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
202 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
203 def reposetup(self, call): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
204 """Decorated function will be executed during reposetup |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
205 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
206 example:: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
207 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
208 @eh.reposetup |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
209 def setupzephir(ui, repo): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
210 print 'this is reposetup!' |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
211 """ |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
212 self._repocallables.append(call) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
213 return call |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
214 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
215 def revset(self, symbolname): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
216 """Decorated function is a revset symbol |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
217 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
218 The name of the symbol must be given as the decorator argument. |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
219 The symbol is added during `extsetup`. |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
220 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
221 example:: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
222 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
223 @eh.revset('hidden') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
224 def revsetbabar(repo, subset, x): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
225 args = revset.getargs(x, 0, 0, 'babar accept no argument') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
226 return [r for r in subset if 'babar' in repo[r].description()] |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
227 """ |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
228 def dec(symbol): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
229 self._revsetsymbols.append((symbolname, symbol)) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
230 return symbol |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
231 return dec |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
232 |
431
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
233 |
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
234 def templatekw(self, keywordname): |
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
235 """Decorated function is a revset keyword |
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
236 |
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
237 The name of the keyword must be given as the decorator argument. |
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
238 The symbol is added during `extsetup`. |
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
239 |
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
240 example:: |
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
241 |
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
242 @eh.templatekw('babar') |
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
243 def kwbabar(ctx): |
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
244 return 'babar' |
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
245 """ |
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
246 def dec(keyword): |
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
247 self._templatekws.append((keywordname, keyword)) |
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
248 return keyword |
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
249 return dec |
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
250 |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
251 def wrapcommand(self, command, extension=None): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
252 """Decorated function is a command wrapper |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
253 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
254 The name of the command must be given as the decorator argument. |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
255 The wrapping is installed during `uisetup`. |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
256 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
257 If the second option `extension` argument is provided, the wrapping |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
258 will be applied in the extension commandtable. This argument must be a |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
259 string that will be searched using `extension.find` if not found and |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
260 Abort error is raised. If the wrapping apply to an extension, it is |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
261 installed during `extsetup` |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
262 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
263 example:: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
264 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
265 @eh.wrapcommand('summary') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
266 def wrapsummary(orig, ui, repo, *args, **kwargs): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
267 ui.note('Barry!') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
268 return orig(ui, repo, *args, **kwargs) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
269 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
270 """ |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
271 def dec(wrapper): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
272 if extension is None: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
273 self._commandwrappers.append((command, wrapper)) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
274 else: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
275 self._extcommandwrappers.append((extension, command, wrapper)) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
276 return wrapper |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
277 return dec |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
278 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
279 def wrapfunction(self, container, funcname): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
280 """Decorated function is a function wrapper |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
281 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
282 This function take two argument, the container and the name of the |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
283 function to wrap. The wrapping is performed during `uisetup`. |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
284 (there is don't support extension) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
285 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
286 example:: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
287 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
288 @eh.function(discovery, 'checkheads') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
289 def wrapfunction(orig, *args, **kwargs): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
290 ui.note('His head smashed in and his heart cut out') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
291 return orig(*args, **kwargs) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
292 """ |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
293 def dec(wrapper): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
294 self._functionwrappers.append((container, funcname, wrapper)) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
295 return wrapper |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
296 return dec |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
297 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
298 def addattr(self, container, funcname): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
299 """Decorated function is to be added to the container |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
300 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
301 This function take two argument, the container and the name of the |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
302 function to wrap. The wrapping is performed during `uisetup`. |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
303 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
304 example:: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
305 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
306 @eh.function(context.changectx, 'babar') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
307 def babar(ctx): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
308 return 'babar' in ctx.description |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
309 """ |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
310 def dec(func): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
311 self._duckpunchers.append((container, funcname, func)) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
312 return func |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
313 return dec |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
314 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
315 eh = exthelper() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
316 uisetup = eh.final_uisetup |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
317 extsetup = eh.final_extsetup |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
318 reposetup = eh.final_reposetup |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
319 |
160
24346b78cd99
mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
150
diff
changeset
|
320 |
72
774932a6cc0d
[obsolete] rationalize doc header.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
71
diff
changeset
|
321 ### Patch changectx |
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
322 ############################# |
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
323 |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
324 @eh.addattr(context.changectx, 'unstable') |
148
8e93e1f67205
obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
144
diff
changeset
|
325 def unstable(ctx): |
8e93e1f67205
obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
144
diff
changeset
|
326 """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
|
327 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
|
328 return False |
8e93e1f67205
obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
144
diff
changeset
|
329 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
|
330 |
8e93e1f67205
obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
144
diff
changeset
|
331 |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
332 @eh.addattr(context.changectx, 'extinct') |
213
ea4aa1890b16
obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
212
diff
changeset
|
333 def extinct(ctx): |
ea4aa1890b16
obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
212
diff
changeset
|
334 """is the changeset extinct by other""" |
ea4aa1890b16
obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
212
diff
changeset
|
335 if ctx.node() is None: |
ea4aa1890b16
obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
212
diff
changeset
|
336 return False |
ea4aa1890b16
obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
212
diff
changeset
|
337 return ctx.rev() in ctx._repo._extinctset |
ea4aa1890b16
obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
212
diff
changeset
|
338 |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
339 @eh.addattr(context.changectx, 'latecomer') |
307
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
340 def latecomer(ctx): |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
341 """is the changeset latecomer (Try to succeed to public change)""" |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
342 if ctx.node() is None: |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
343 return False |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
344 return ctx.rev() in ctx._repo._latecomerset |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
345 |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
346 @eh.addattr(context.changectx, 'conflicting') |
354
bd26eb9714fb
obsolete: Detect conflicting changeset!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
351
diff
changeset
|
347 def conflicting(ctx): |
bd26eb9714fb
obsolete: Detect conflicting changeset!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
351
diff
changeset
|
348 """is the changeset conflicting (Try to succeed to public change)""" |
bd26eb9714fb
obsolete: Detect conflicting changeset!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
351
diff
changeset
|
349 if ctx.node() is None: |
bd26eb9714fb
obsolete: Detect conflicting changeset!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
351
diff
changeset
|
350 return False |
bd26eb9714fb
obsolete: Detect conflicting changeset!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
351
diff
changeset
|
351 return ctx.rev() in ctx._repo._conflictingset |
bd26eb9714fb
obsolete: Detect conflicting changeset!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
351
diff
changeset
|
352 |
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
353 |
72
774932a6cc0d
[obsolete] rationalize doc header.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
71
diff
changeset
|
354 ### revset |
39 | 355 ############################# |
356 | |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
357 @eh.revset('hidden') |
321
41ba89f0caa5
obsolete: add an hidden revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
320
diff
changeset
|
358 def revsethidden(repo, subset, x): |
397
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
359 """``hidden()`` |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
360 Changeset is hidden. |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
361 """ |
321
41ba89f0caa5
obsolete: add an hidden revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
320
diff
changeset
|
362 args = revset.getargs(x, 0, 0, 'hidden takes no argument') |
398
42828b0ace98
obsolete: fix hidden() revset
Patrick Mezard <patrick@mezard.eu>
parents:
397
diff
changeset
|
363 return [r for r in subset if r in repo.hiddenrevs] |
112
eae9be0ee00e
adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
109
diff
changeset
|
364 |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
365 @eh.revset('obsolete') |
39 | 366 def revsetobsolete(repo, subset, x): |
397
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
367 """``obsolete()`` |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
368 Changeset is obsolete. |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
369 """ |
135
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
370 args = revset.getargs(x, 0, 0, 'obsolete takes no argument') |
252
470232cea503
[obsolete] fix new api: use the new phase cache api
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
228
diff
changeset
|
371 return [r for r in subset if r in repo._obsoleteset and repo._phasecache.phase(repo, r) > 0] |
470232cea503
[obsolete] fix new api: use the new phase cache api
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
228
diff
changeset
|
372 |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
373 @eh.revset('unstable') |
135
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
374 def revsetunstable(repo, subset, x): |
397
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
375 """``unstable()`` |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
376 Unstable changesets are non-obsolete with obsolete ancestors. |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
377 """ |
135
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
378 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
|
379 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
|
380 |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
381 @eh.revset('suspended') |
135
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
382 def revsetsuspended(repo, subset, x): |
397
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
383 """``suspended()`` |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
384 Obsolete changesets with non-obsolete descendants. |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
385 """ |
310
2d0dc5c18489
[obsolete] fix revset error message
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
308
diff
changeset
|
386 args = revset.getargs(x, 0, 0, 'suspended takes no arguments') |
135
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
387 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
|
388 |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
389 @eh.revset('extinct') |
135
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
390 def revsetextinct(repo, subset, x): |
397
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
391 """``extinct()`` |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
392 Obsolete changesets with obsolete descendants only. |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
393 """ |
310
2d0dc5c18489
[obsolete] fix revset error message
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
308
diff
changeset
|
394 args = revset.getargs(x, 0, 0, 'extinct takes no arguments') |
135
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
395 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
|
396 |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
397 @eh.revset('latecomer') |
307
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
398 def revsetlatecomer(repo, subset, x): |
397
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
399 """``latecomer()`` |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
400 Changesets marked as successors of public changesets. |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
401 """ |
310
2d0dc5c18489
[obsolete] fix revset error message
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
308
diff
changeset
|
402 args = revset.getargs(x, 0, 0, 'latecomer takes no arguments') |
307
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
403 return [r for r in subset if r in repo._latecomerset] |
143
0599fb01dc41
add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
135
diff
changeset
|
404 |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
405 @eh.revset('conflicting') |
354
bd26eb9714fb
obsolete: Detect conflicting changeset!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
351
diff
changeset
|
406 def revsetconflicting(repo, subset, x): |
397
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
407 """``conflicting()`` |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
408 Changesets marked as successors of a same changeset. |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
409 """ |
354
bd26eb9714fb
obsolete: Detect conflicting changeset!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
351
diff
changeset
|
410 args = revset.getargs(x, 0, 0, 'conflicting takes no arguments') |
bd26eb9714fb
obsolete: Detect conflicting changeset!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
351
diff
changeset
|
411 return [r for r in subset if r in repo._conflictingset] |
bd26eb9714fb
obsolete: Detect conflicting changeset!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
351
diff
changeset
|
412 |
305
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
413 def _precursors(repo, s): |
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
414 """Precursor of a changeset""" |
143
0599fb01dc41
add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
135
diff
changeset
|
415 cs = set() |
0599fb01dc41
add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
135
diff
changeset
|
416 nm = repo.changelog.nodemap |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
417 markerbysubj = repo.obsstore.successors |
143
0599fb01dc41
add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
135
diff
changeset
|
418 for r in s: |
224 | 419 for p in markerbysubj.get(repo[r].node(), ()): |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
420 pr = nm.get(p[0]) |
143
0599fb01dc41
add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
135
diff
changeset
|
421 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
|
422 cs.add(pr) |
0599fb01dc41
add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
135
diff
changeset
|
423 return cs |
0599fb01dc41
add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
135
diff
changeset
|
424 |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
425 @eh.revset('obsparents') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
426 @eh.revset('precursors') |
305
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
427 def revsetprecursors(repo, subset, x): |
397
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
428 """``precursors(set)`` |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
429 Immediate precursors of changesets in set. |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
430 """ |
144
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
431 s = revset.getset(repo, range(len(repo)), x) |
305
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
432 cs = _precursors(repo, s) |
144
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
433 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
|
434 |
305
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
435 def _allprecursors(repo, s): # XXX we need a better naming |
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
436 """transitive precursors of a subset""" |
144
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
437 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
|
438 seen = set() |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
439 allsubjects = repo.obsstore.successors |
144
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
440 while toproceed: |
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
441 nc = toproceed.pop() |
224 | 442 for mark in allsubjects.get(nc, ()): |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
443 np = mark[0] |
144
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
444 if np not in seen: |
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
445 seen.add(np) |
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
446 toproceed.append(np) |
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
447 nm = repo.changelog.nodemap |
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
448 cs = set() |
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
449 for p in seen: |
204
50039b9b535e
2.2 compat: nodemap.get take a single argument now.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
203
diff
changeset
|
450 pr = nm.get(p) |
144
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
451 if pr is not None: |
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
452 cs.add(pr) |
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
453 return cs |
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
454 |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
455 @eh.revset('obsancestors') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
456 @eh.revset('allprecursors') |
305
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
457 def revsetallprecursors(repo, subset, x): |
397
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
458 """``allprecursors(set)`` |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
459 Transitive precursors of changesets in set. |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
460 """ |
143
0599fb01dc41
add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
135
diff
changeset
|
461 s = revset.getset(repo, range(len(repo)), x) |
305
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
462 cs = _allprecursors(repo, s) |
143
0599fb01dc41
add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
135
diff
changeset
|
463 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
|
464 |
306
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
465 def _successors(repo, s): |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
466 """Successors of a changeset""" |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
467 cs = set() |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
468 nm = repo.changelog.nodemap |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
469 markerbyobj = repo.obsstore.precursors |
306
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
470 for r in s: |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
471 for p in markerbyobj.get(repo[r].node(), ()): |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
472 for sub in p[1]: |
306
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
473 sr = nm.get(sub) |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
474 if sr is not None: |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
475 cs.add(sr) |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
476 return cs |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
477 |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
478 @eh.revset('obschildrend') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
479 @eh.revset('successors') |
306
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
480 def revsetsuccessors(repo, subset, x): |
397
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
481 """``successors(set)`` |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
482 Immediate successors of changesets in set. |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
483 """ |
306
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
484 s = revset.getset(repo, range(len(repo)), x) |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
485 cs = _successors(repo, s) |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
486 return [r for r in subset if r in cs] |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
487 |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
488 def _allsuccessors(repo, s): # XXX we need a better naming |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
489 """transitive successors of a subset""" |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
490 toproceed = [repo[r].node() for r in s] |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
491 seen = set() |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
492 allobjects = repo.obsstore.precursors |
306
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
493 while toproceed: |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
494 nc = toproceed.pop() |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
495 for mark in allobjects.get(nc, ()): |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
496 for sub in mark[1]: |
306
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
497 if sub not in seen: |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
498 seen.add(sub) |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
499 toproceed.append(sub) |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
500 nm = repo.changelog.nodemap |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
501 cs = set() |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
502 for s in seen: |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
503 sr = nm.get(s) |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
504 if sr is not None: |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
505 cs.add(sr) |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
506 return cs |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
507 |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
508 @eh.revset('obsdescendants') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
509 @eh.revset('allsuccessors') |
306
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
510 def revsetallsuccessors(repo, subset, x): |
397
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
511 """``allsuccessors(set)`` |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
512 Transitive successors of changesets in set. |
0bd63f294a6f
obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents:
393
diff
changeset
|
513 """ |
306
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
514 s = revset.getset(repo, range(len(repo)), x) |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
515 cs = _allsuccessors(repo, s) |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
516 return [r for r in subset if r in cs] |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
517 |
144
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
518 |
299
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
519 ### template keywords |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
520 ##################### |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
521 |
431
bd05022c7856
obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
430
diff
changeset
|
522 @eh.templatekw('obsolete') |
299
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
523 def obsoletekw(repo, ctx, templ, **args): |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
524 """:obsolete: String. The obsolescence level of the node, could be |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
525 ``stable``, ``unstable``, ``suspended`` or ``extinct``. |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
526 """ |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
527 rev = ctx.rev() |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
528 if rev in repo._extinctset: |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
529 return 'extinct' |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
530 if rev in repo._suspendedset: |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
531 return 'suspended' |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
532 if rev in repo._unstableset: |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
533 return 'unstable' |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
534 return 'stable' |
144
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
535 |
71
19e1930587a0
[obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
70
diff
changeset
|
536 ### Other Extension compat |
19e1930587a0
[obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
70
diff
changeset
|
537 ############################ |
19e1930587a0
[obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
70
diff
changeset
|
538 |
150
f12fd2410a60
obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
148
diff
changeset
|
539 |
253
8ee6c5b98d73
[obsolete] fix new api: be more flexible on rebase's buildstate signature
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
252
diff
changeset
|
540 def buildstate(orig, repo, dest, rebaseset, *ags, **kws): |
150
f12fd2410a60
obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
148
diff
changeset
|
541 """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
|
542 rebaseset = repo.revs('%ld - extinct()', rebaseset) |
253
8ee6c5b98d73
[obsolete] fix new api: be more flexible on rebase's buildstate signature
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
252
diff
changeset
|
543 return orig(repo, dest, rebaseset, *ags, **kws) |
150
f12fd2410a60
obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
148
diff
changeset
|
544 |
282
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
545 def defineparents(orig, repo, rev, target, state, *args, **kwargs): |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
546 rebasestate = getattr(repo, '_rebasestate', None) |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
547 if rebasestate is not None: |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
548 repo._rebasestate = dict(state) |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
549 repo._rebasetarget = target |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
550 return orig(repo, rev, target, state, *args, **kwargs) |
150
f12fd2410a60
obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
148
diff
changeset
|
551 |
282
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
552 def concludenode(orig, repo, rev, p1, *args, **kwargs): |
74
c7dd26dec7fc
[obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
73
diff
changeset
|
553 """wrapper for rebase 's concludenode that set obsolete relation""" |
282
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
554 newrev = orig(repo, rev, p1, *args, **kwargs) |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
555 rebasestate = getattr(repo, '_rebasestate', None) |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
556 if rebasestate is not None: |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
557 if newrev is not None: |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
558 nrev = repo[newrev].rev() |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
559 else: |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
560 nrev = p1 |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
561 repo._rebasestate[rev] = nrev |
71
19e1930587a0
[obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
70
diff
changeset
|
562 return newrev |
19e1930587a0
[obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
70
diff
changeset
|
563 |
274
6622a24f3b0f
obsolete: fix rebase wrapping
Patrick Mezard <patrick@mezard.eu>
parents:
273
diff
changeset
|
564 def cmdrebase(orig, ui, repo, *args, **kwargs): |
311
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
565 |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
566 reallykeep = kwargs.get('keep', False) |
275
336210dada95
obsolete: make rebase abort with --keep
Patrick Mezard <patrick@mezard.eu>
parents:
274
diff
changeset
|
567 kwargs = dict(kwargs) |
84
c4cc5f3bcf12
[obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
83
diff
changeset
|
568 kwargs['keep'] = True |
c4cc5f3bcf12
[obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
83
diff
changeset
|
569 |
282
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
570 # We want to mark rebased revision as obsolete and set their |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
571 # replacements if any. Doing it in concludenode() prevents |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
572 # aborting the rebase, and is not called with all relevant |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
573 # revisions in --collapse case. Instead, we try to track the |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
574 # rebase state structure by sampling/updating it in |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
575 # defineparents() and concludenode(). The obsolete markers are |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
576 # added from this state after a successful call. |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
577 repo._rebasestate = {} |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
578 repo._rebasetarget = None |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
579 try: |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
580 res = orig(ui, repo, *args, **kwargs) |
311
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
581 if not reallykeep: |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
582 # Filter nullmerge or unrebased entries |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
583 repo._rebasestate = dict(p for p in repo._rebasestate.iteritems() |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
584 if p[1] >= 0) |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
585 if not res and not kwargs.get('abort') and repo._rebasestate: |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
586 # Rebased revisions are assumed to be descendants of |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
587 # targetrev. If a source revision is mapped to targetrev |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
588 # or to another rebased revision, it must have been |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
589 # removed. |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
590 targetrev = repo[repo._rebasetarget].rev() |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
591 newrevs = set([targetrev]) |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
592 replacements = {} |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
593 for rev, newrev in sorted(repo._rebasestate.items()): |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
594 oldnode = repo[rev].node() |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
595 if newrev not in newrevs: |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
596 newnode = repo[newrev].node() |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
597 newrevs.add(newrev) |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
598 else: |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
599 newnode = nullid |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
600 replacements[oldnode] = newnode |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
601 |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
602 if kwargs.get('collapse'): |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
603 newnodes = set(n for n in replacements.values() if n != nullid) |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
604 if newnodes: |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
605 # Collapsing into more than one revision? |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
606 assert len(newnodes) == 1, newnodes |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
607 newnode = newnodes.pop() |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
608 else: |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
609 newnode = nullid |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
610 repo.addcollapsedobsolete(replacements, newnode) |
282
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
611 else: |
311
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
612 for oldnode, newnode in replacements.iteritems(): |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
613 repo.addobsolete(newnode, oldnode) |
282
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
614 return res |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
615 finally: |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
616 delattr(repo, '_rebasestate') |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
617 delattr(repo, '_rebasetarget') |
84
c4cc5f3bcf12
[obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
83
diff
changeset
|
618 |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
619 @eh.extsetup |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
620 def _rebasewrapping(ui): |
356
56d4c6207ef9
Move obserror warning into the obsolete extension.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
354
diff
changeset
|
621 # warning about more obsolete |
42
eb6a06d7eae3
Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
41
diff
changeset
|
622 try: |
eb6a06d7eae3
Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
41
diff
changeset
|
623 rebase = extensions.find('rebase') |
eb6a06d7eae3
Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
41
diff
changeset
|
624 if rebase: |
356
56d4c6207ef9
Move obserror warning into the obsolete extension.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
354
diff
changeset
|
625 entry = extensions.wrapcommand(rebase.cmdtable, 'rebase', warnobserrors) |
150
f12fd2410a60
obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
148
diff
changeset
|
626 extensions.wrapfunction(rebase, 'buildstate', buildstate) |
282
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
627 extensions.wrapfunction(rebase, 'defineparents', defineparents) |
42
eb6a06d7eae3
Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
41
diff
changeset
|
628 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
|
629 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
|
630 except KeyError: |
305
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
631 pass # rebase not found |
39 | 632 |
214
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
633 ### Discovery wrapping |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
634 ############################# |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
635 |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
636 @eh.wrapfunction(discovery, 'checkheads') |
217
786eb34d93ea
obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
215
diff
changeset
|
637 def wrapcheckheads(orig, repo, remote, outgoing, *args, **kwargs): |
218
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
638 """wrap mercurial.discovery.checkheads |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
639 |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
640 * prevent unstability to be pushed |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
641 * patch remote to ignore obsolete heads on remote |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
642 """ |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
643 # do not push instability |
376
188afb394e10
obsolete: move hint punching to push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
375
diff
changeset
|
644 for h in outgoing.missingheads: |
390
54582eebeb08
obsolete: fix typos, improve messages
Patrick Mezard <patrick@mezard.eu>
parents:
388
diff
changeset
|
645 # Checking heads is enough, obsolete descendants are either |
54582eebeb08
obsolete: fix typos, improve messages
Patrick Mezard <patrick@mezard.eu>
parents:
388
diff
changeset
|
646 # obsolete or unstable. |
388
97b75bbfacc5
obsolete: rely on core for context and reveset which exist there
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
387
diff
changeset
|
647 ctx = repo[h] |
376
188afb394e10
obsolete: move hint punching to push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
375
diff
changeset
|
648 if ctx.latecomer(): |
390
54582eebeb08
obsolete: fix typos, improve messages
Patrick Mezard <patrick@mezard.eu>
parents:
388
diff
changeset
|
649 raise util.Abort(_("push includes a latecomer changeset: %s!") |
376
188afb394e10
obsolete: move hint punching to push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
375
diff
changeset
|
650 % ctx) |
188afb394e10
obsolete: move hint punching to push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
375
diff
changeset
|
651 if ctx.conflicting(): |
390
54582eebeb08
obsolete: fix typos, improve messages
Patrick Mezard <patrick@mezard.eu>
parents:
388
diff
changeset
|
652 raise util.Abort(_("push includes a conflicting changeset: %s!") |
376
188afb394e10
obsolete: move hint punching to push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
375
diff
changeset
|
653 % ctx) |
382
58fdb2180064
Use the core check heads mecanism to prevent zaelous warning
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
381
diff
changeset
|
654 return orig(repo, remote, outgoing, *args, **kwargs) |
217
786eb34d93ea
obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
215
diff
changeset
|
655 |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
656 @eh.wrapfunction(phases, 'advanceboundary') |
307
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
657 def wrapclearcache(orig, repo, *args, **kwargs): |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
658 try: |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
659 return orig(repo, *args, **kwargs) |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
660 finally: |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
661 repo._clearobsoletecache() |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
662 |
217
786eb34d93ea
obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
215
diff
changeset
|
663 |
71
19e1930587a0
[obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
70
diff
changeset
|
664 ### New commands |
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
665 ############################# |
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
666 |
276
f26e9bc5f7fc
obsolete: use new-style command registration
Patrick Mezard <patrick@mezard.eu>
parents:
275
diff
changeset
|
667 cmdtable = {} |
f26e9bc5f7fc
obsolete: use new-style command registration
Patrick Mezard <patrick@mezard.eu>
parents:
275
diff
changeset
|
668 command = cmdutil.command(cmdtable) |
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
669 |
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
670 |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
671 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
672 @command('debugsuccessors', [], '') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
673 def cmddebugsuccessors(ui, repo): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
674 """dump obsolete changesets and their successors |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
675 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
676 Each line matches an existing marker, the first identifier is the |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
677 obsolete changeset identifier, followed by it successors. |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
678 """ |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
679 lock = repo.lock() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
680 try: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
681 allsuccessors = repo.obsstore.precursors |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
682 for old in sorted(allsuccessors): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
683 successors = [sorted(m[1]) for m in allsuccessors[old]] |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
684 for i, group in enumerate(sorted(successors)): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
685 ui.write('%s' % short(old)) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
686 for new in group: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
687 ui.write(' %s' % short(new)) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
688 ui.write('\n') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
689 finally: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
690 lock.release() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
691 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
692 ### Altering existing command |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
693 ############################# |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
694 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
695 @eh.wrapcommand("update") |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
696 @eh.wrapcommand("pull") |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
697 def wrapmayobsoletewc(origfn, ui, repo, *args, **opts): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
698 res = origfn(ui, repo, *args, **opts) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
699 if repo['.'].obsolete(): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
700 ui.warn(_('Working directory parent is obsolete\n')) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
701 return res |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
702 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
703 def warnobserrors(orig, ui, repo, *args, **kwargs): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
704 """display warning is the command resulted in more instable changeset""" |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
705 priorunstables = len(repo.revs('unstable()')) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
706 priorlatecomers = len(repo.revs('latecomer()')) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
707 priorconflictings = len(repo.revs('conflicting()')) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
708 #print orig, priorunstables |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
709 #print len(repo.revs('secret() - obsolete()')) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
710 try: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
711 return orig(ui, repo, *args, **kwargs) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
712 finally: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
713 newunstables = len(repo.revs('unstable()')) - priorunstables |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
714 newlatecomers = len(repo.revs('latecomer()')) - priorlatecomers |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
715 newconflictings = len(repo.revs('conflicting()')) - priorconflictings |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
716 #print orig, newunstables |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
717 #print len(repo.revs('secret() - obsolete()')) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
718 if newunstables > 0: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
719 ui.warn(_('%i new unstables changesets\n') % newunstables) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
720 if newlatecomers > 0: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
721 ui.warn(_('%i new latecomers changesets\n') % newlatecomers) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
722 if newconflictings > 0: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
723 ui.warn(_('%i new conflictings changesets\n') % newconflictings) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
724 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
725 @eh.extsetup |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
726 def _coreobserrorwrapping(ui): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
727 # warning about more obsolete |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
728 for cmd in ['commit', 'push', 'pull', 'graft', 'phase', 'unbundle']: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
729 entry = extensions.wrapcommand(commands.table, cmd, warnobserrors) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
730 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
731 @eh.wrapfunction(cmdutil, 'amend') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
732 def wrapcmdutilamend(orig, ui, repo, commitfunc, old, *args, **kwargs): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
733 oldnode = old.node() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
734 new = orig(ui, repo, commitfunc, old, *args, **kwargs) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
735 if new != oldnode: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
736 lock = repo.lock() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
737 try: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
738 tr = repo.transaction('post-amend-obst') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
739 try: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
740 meta = { |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
741 'date': '%i %i' % util.makedate(), |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
742 'user': ui.username(), |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
743 } |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
744 repo.obsstore.create(tr, oldnode, [new], 0, meta) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
745 tr.close() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
746 repo._clearobsoletecache() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
747 finally: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
748 tr.release() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
749 finally: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
750 lock.release() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
751 return new |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
752 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
753 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
754 ### diagnostique tools |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
755 ############################# |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
756 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
757 def unstables(repo): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
758 """Return all unstable changeset""" |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
759 return scmutil.revrange(repo, ['obsolete():: and (not obsolete())']) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
760 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
761 def newerversion(repo, obs): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
762 """Return the newer version of an obsolete changeset""" |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
763 toproceed = set([(obs,)]) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
764 # XXX known optimization available |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
765 newer = set() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
766 objectrels = repo.obsstore.precursors |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
767 while toproceed: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
768 current = toproceed.pop() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
769 assert len(current) <= 1, 'splitting not handled yet. %r' % current |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
770 current = [n for n in current if n != nullid] |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
771 if current: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
772 n, = current |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
773 if n in objectrels: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
774 markers = objectrels[n] |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
775 for mark in markers: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
776 toproceed.add(tuple(mark[1])) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
777 else: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
778 newer.add(tuple(current)) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
779 else: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
780 newer.add(()) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
781 return sorted(newer) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
782 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
783 ### repo subclassing |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
784 ############################# |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
785 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
786 @eh.reposetup |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
787 def _reposetup(ui, repo): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
788 if not repo.local(): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
789 return |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
790 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
791 opush = repo.push |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
792 o_updatebranchcache = repo.updatebranchcache |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
793 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
794 # /!\ api change in Hg 2.2 (97efd26eb9576f39590812ea9) /!\ |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
795 if util.safehasattr(repo, '_journalfiles'): # Hg 2.2 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
796 o_journalfiles = repo._journalfiles |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
797 o_writejournal = repo._writejournal |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
798 o_hook = repo.hook |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
799 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
800 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
801 class obsoletingrepo(repo.__class__): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
802 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
803 # workaround |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
804 def hook(self, name, throw=False, **args): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
805 if 'pushkey' in name: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
806 args.pop('new') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
807 args.pop('old') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
808 return o_hook(name, throw=False, **args) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
809 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
810 ### Public method |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
811 # XXX Kill me |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
812 def obsoletedby(self, node): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
813 """return the set of node that make <node> obsolete (obj)""" |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
814 others = set() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
815 for marker in self.obsstore.precursors.get(node, []): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
816 others.update(marker[1]) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
817 return others |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
818 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
819 # XXX Kill me |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
820 def obsolete(self, node): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
821 """return the set of node that <node> make obsolete (sub)""" |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
822 return set(marker[0] for marker in self.obsstore.successors.get(node, [])) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
823 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
824 # XXX move me on obssotre |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
825 @util.propertycache |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
826 def _obsoleteset(self): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
827 """the set of obsolete revision""" |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
828 obs = set() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
829 nm = self.changelog.nodemap |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
830 for prec in self.obsstore.precursors: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
831 rev = nm.get(prec) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
832 if rev is not None: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
833 obs.add(rev) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
834 return obs |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
835 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
836 # XXX move me on obssotre |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
837 @util.propertycache |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
838 def _unstableset(self): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
839 """the set of non obsolete revision with obsolete parent""" |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
840 return set(self.revs('(obsolete()::) - obsolete()')) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
841 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
842 # XXX move me on obssotre |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
843 @util.propertycache |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
844 def _suspendedset(self): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
845 """the set of obsolete parent with non obsolete descendant""" |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
846 return set(self.revs('obsolete() and obsolete()::unstable()')) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
847 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
848 # XXX move me on obssotre |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
849 @util.propertycache |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
850 def _extinctset(self): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
851 """the set of obsolete parent without non obsolete descendant""" |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
852 return set(self.revs('obsolete() - obsolete()::unstable()')) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
853 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
854 # XXX move me on obssotre |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
855 @util.propertycache |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
856 def _latecomerset(self): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
857 """the set of rev trying to obsolete public revision""" |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
858 query = 'allsuccessors(public()) - obsolete() - public()' |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
859 return set(self.revs(query)) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
860 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
861 # XXX move me on obssotre |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
862 @util.propertycache |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
863 def _conflictingset(self): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
864 """the set of rev trying to obsolete public revision""" |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
865 conflicting = set() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
866 obsstore = self.obsstore |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
867 newermap = {} |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
868 for ctx in self.set('(not public()) - obsolete()'): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
869 prec = obsstore.successors.get(ctx.node(), ()) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
870 toprocess = set(prec) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
871 while toprocess: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
872 prec = toprocess.pop()[0] |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
873 if prec not in newermap: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
874 newermap[prec] = newerversion(self, prec) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
875 newer = [n for n in newermap[prec] if n] # filter kill |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
876 if len(newer) > 1: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
877 conflicting.add(ctx.rev()) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
878 break |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
879 toprocess.update(obsstore.successors.get(prec, ())) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
880 return conflicting |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
881 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
882 def _clearobsoletecache(self): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
883 if '_obsoleteset' in vars(self): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
884 del self._obsoleteset |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
885 self._clearunstablecache() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
886 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
887 def updatebranchcache(self): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
888 o_updatebranchcache() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
889 self._clearunstablecache() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
890 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
891 def _clearunstablecache(self): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
892 if '_unstableset' in vars(self): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
893 del self._unstableset |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
894 if '_suspendedset' in vars(self): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
895 del self._suspendedset |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
896 if '_extinctset' in vars(self): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
897 del self._extinctset |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
898 if '_latecomerset' in vars(self): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
899 del self._latecomerset |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
900 if '_conflictingset' in vars(self): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
901 del self._conflictingset |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
902 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
903 # XXX kill me |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
904 def addobsolete(self, sub, obj): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
905 """Add a relation marking that node <sub> is a new version of <obj>""" |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
906 assert sub != obj |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
907 if not repo[obj].phase(): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
908 if sub is None: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
909 self.ui.warn( |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
910 _("trying to kill immutable changeset %(obj)s\n") |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
911 % {'obj': short(obj)}) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
912 if sub is not None: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
913 self.ui.warn( |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
914 _("%(sub)s try to obsolete immutable changeset %(obj)s\n") |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
915 % {'sub': short(sub), 'obj': short(obj)}) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
916 lock = self.lock() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
917 try: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
918 tr = self.transaction('add-obsolete') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
919 try: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
920 meta = { |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
921 'date': '%i %i' % util.makedate(), |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
922 'user': ui.username(), |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
923 } |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
924 subs = (sub == nullid) and [] or [sub] |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
925 mid = self.obsstore.create(tr, obj, subs, 0, meta) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
926 tr.close() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
927 self._clearobsoletecache() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
928 return mid |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
929 finally: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
930 tr.release() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
931 finally: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
932 lock.release() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
933 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
934 # XXX kill me |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
935 def addcollapsedobsolete(self, oldnodes, newnode): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
936 """Mark oldnodes as collapsed into newnode.""" |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
937 # Assume oldnodes are all descendants of a single rev |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
938 rootrevs = self.revs('roots(%ln)', oldnodes) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
939 assert len(rootrevs) == 1, rootrevs |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
940 #rootnode = self[rootrevs[0]].node() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
941 for n in oldnodes: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
942 self.addobsolete(newnode, n) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
943 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
944 ### pull // push support |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
945 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
946 def push(self, remote, *args, **opts): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
947 """wrapper around pull that pull obsolete relation""" |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
948 try: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
949 result = opush(remote, *args, **opts) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
950 except util.Abort, ex: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
951 hint = _("use 'hg stabilize' to get a stable history " |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
952 "or --force to ignore warnings") |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
953 if (len(ex.args) >= 1 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
954 and ex.args[0].startswith('push includes ') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
955 and ex.hint is None): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
956 ex.hint = hint |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
957 raise |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
958 return result |
430
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
959 repo.__class__ = obsoletingrepo |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
960 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
961 |
430
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
962 ##################################################################### |
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
963 ### Older format management ### |
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
964 ##################################################################### |
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
965 |
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
966 # Code related to detection and management of older legacy format never |
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
967 # handled by core |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
968 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
969 @eh.reposetup |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
970 def _checkoldobsolete(ui, repo): |
430
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
971 """Detect that a repo still carry some old obsolete format |
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
972 """ |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
973 if not repo.local(): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
974 return |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
975 for arg in sys.argv: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
976 if 'debugc' in arg: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
977 break |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
978 else: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
979 data = repo.opener.tryread('obsolete-relations') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
980 if not data: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
981 data = repo.sopener.tryread('obsoletemarkers') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
982 if data: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
983 raise util.Abort('old format of obsolete marker detected!\n' |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
984 'run `hg debugconvertobsolete` once.') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
985 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
986 def _obsdeserialise(flike): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
987 """read a file like object serialised with _obsserialise |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
988 |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
989 this desierialize into a {subject -> objects} mapping""" |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
990 rels = {} |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
991 for line in flike: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
992 subhex, objhex = line.split() |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
993 subnode = bin(subhex) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
994 if subnode == nullid: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
995 subnode = None |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
996 rels.setdefault( subnode, set()).add(bin(objhex)) |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
997 return rels |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
998 |
276
f26e9bc5f7fc
obsolete: use new-style command registration
Patrick Mezard <patrick@mezard.eu>
parents:
275
diff
changeset
|
999 @command('debugconvertobsolete', [], '') |
224 | 1000 def cmddebugconvertobsolete(ui, repo): |
278
fa0b9b8a83c0
obsolete: add or fix debug commands help
Patrick Mezard <patrick@mezard.eu>
parents:
277
diff
changeset
|
1001 """import markers from an .hg/obsolete-relations file""" |
224 | 1002 cnt = 0 |
337
ebfd1b96a013
obsolete: convert try to guess what invalid node id are
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
336
diff
changeset
|
1003 err = 0 |
224 | 1004 l = repo.lock() |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1005 some = False |
224 | 1006 try: |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1007 unlink = [] |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1008 tr = repo.transaction('convert-obsolete') |
224 | 1009 try: |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1010 repo._importoldobsolete = True |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1011 store = repo.obsstore |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1012 ### very first format |
224 | 1013 try: |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1014 f = repo.opener('obsolete-relations') |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1015 try: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1016 some = True |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1017 for line in f: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1018 subhex, objhex = line.split() |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1019 suc = bin(subhex) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1020 prec = bin(objhex) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1021 sucs = (suc==nullid) and [] or [suc] |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1022 meta = { |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1023 'date': '%i %i' % util.makedate(), |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1024 'user': ui.username(), |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1025 } |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1026 try: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1027 store.create(tr, prec, sucs, 0, meta) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1028 cnt += 1 |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1029 except ValueError: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1030 repo.ui.write_err("invalid old marker line: %s" |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1031 % (line)) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1032 err += 1 |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1033 finally: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1034 f.close() |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1035 unlink.append(repo.join('obsolete-relations')) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1036 except IOError: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1037 pass |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1038 ### second (json) format |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1039 data = repo.sopener.tryread('obsoletemarkers') |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1040 if data: |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1041 some = True |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1042 for oldmark in json.loads(data): |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1043 del oldmark['id'] # dropped for now |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1044 del oldmark['reason'] # unused until then |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1045 oldobject = str(oldmark.pop('object')) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1046 oldsubjects = [str(s) for s in oldmark.pop('subjects', [])] |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1047 LOOKUP_ERRORS = (error.RepoLookupError, error.LookupError) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1048 if len(oldobject) != 40: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1049 try: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1050 oldobject = repo[oldobject].node() |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1051 except LOOKUP_ERRORS: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1052 pass |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1053 if any(len(s) != 40 for s in oldsubjects): |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1054 try: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1055 oldsubjects = [repo[s].node() for s in oldsubjects] |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1056 except LOOKUP_ERRORS: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1057 pass |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1058 |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1059 oldmark['date'] = '%i %i' % tuple(oldmark['date']) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1060 meta = dict((k.encode('utf-8'), v.encode('utf-8')) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1061 for k, v in oldmark.iteritems()) |
341
7653f80fd7a4
obsolete: harden convertion from first format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
340
diff
changeset
|
1062 try: |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1063 succs = [bin(n) for n in oldsubjects] |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1064 succs = [n for n in succs if n != nullid] |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1065 store.create(tr, bin(oldobject), succs, |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1066 0, meta) |
341
7653f80fd7a4
obsolete: harden convertion from first format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
340
diff
changeset
|
1067 cnt += 1 |
7653f80fd7a4
obsolete: harden convertion from first format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
340
diff
changeset
|
1068 except ValueError: |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1069 repo.ui.write_err("invalid marker %s -> %s\n" |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1070 % (oldobject, oldsubjects)) |
341
7653f80fd7a4
obsolete: harden convertion from first format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
340
diff
changeset
|
1071 err += 1 |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1072 unlink.append(repo.sjoin('obsoletemarkers')) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1073 tr.close() |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1074 for path in unlink: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1075 util.unlink(path) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1076 finally: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
1077 tr.release() |
224 | 1078 finally: |
1079 del repo._importoldobsolete | |
1080 l.release() | |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1081 if not some: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1082 ui.warn('nothing to do\n') |
224 | 1083 ui.status('%i obsolete marker converted\n' % cnt) |
337
ebfd1b96a013
obsolete: convert try to guess what invalid node id are
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
336
diff
changeset
|
1084 if err: |
ebfd1b96a013
obsolete: convert try to guess what invalid node id are
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
336
diff
changeset
|
1085 ui.write_err('%i conversion failed. check you graph!\n' % err) |