annotate hgext/obsolete.py @ 489:fdf3ae486e01

Fix mercurial version check
author Pierre-Yves David <pierre-yves.david@logilab.fr>
date Thu, 23 Aug 2012 18:19:42 +0200
parents 2111c655b4f5
children 8096833e9226
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
1 # obsolete.py - introduce the obsolete concept in mercurial.
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
2 #
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
3 # Copyright 2011 Pierre-Yves David <pierre-yves.david@ens-lyon.org>
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
4 # Logilab SA <contact@logilab.fr>
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
5 #
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
6 # This software may be used and distributed according to the terms of the
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
7 # GNU General Public License version 2 or any later version.
69
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
8 """Introduce the Obsolete concept to mercurial
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
9
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
10 General concept
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
11 ===============
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
12
456
79aacd34bf1e obsolete: simplify module docstring
Patrick Mezard <patrick@mezard.eu>
parents: 455
diff changeset
13 This extension introduces the *obsolete* concept. The relation
79aacd34bf1e obsolete: simplify module docstring
Patrick Mezard <patrick@mezard.eu>
parents: 455
diff changeset
14 ``<changeset B> obsoletes <changeset A>`` denotes that ``<changeset B>``
79aacd34bf1e obsolete: simplify module docstring
Patrick Mezard <patrick@mezard.eu>
parents: 455
diff changeset
15 is a new version of ``<changeset A>``.
69
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
16
456
79aacd34bf1e obsolete: simplify module docstring
Patrick Mezard <patrick@mezard.eu>
parents: 455
diff changeset
17 The *obsolete* relations act as an history **orthogonal** to the regular
79aacd34bf1e obsolete: simplify module docstring
Patrick Mezard <patrick@mezard.eu>
parents: 455
diff changeset
18 changesets history. Regular changesets history versions files. *Obsolete*
79aacd34bf1e obsolete: simplify module docstring
Patrick Mezard <patrick@mezard.eu>
parents: 455
diff changeset
19 relations version changesets.
69
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
20
228
5a17c0d41a00 proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 226
diff changeset
21 :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
22 :unstable: a changeset that is not obsolete but has an obsolete ancestor.
456
79aacd34bf1e obsolete: simplify module docstring
Patrick Mezard <patrick@mezard.eu>
parents: 455
diff changeset
23 :suspended: an obsolete changeset with unstable descendants.
79aacd34bf1e obsolete: simplify module docstring
Patrick Mezard <patrick@mezard.eu>
parents: 455
diff changeset
24 :extinct: an obsolete changeset without unstable descendants.
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
25 (subject to garbage collection)
85
531058dbd703 [obsolete] vocabulary update suggestion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 84
diff changeset
26
531058dbd703 [obsolete] vocabulary update suggestion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 84
diff changeset
27 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
28
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
29
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
30 Usage and Feature
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
31 =================
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
32
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
33
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
34 New commands
228
5a17c0d41a00 proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 226
diff changeset
35 ------------
69
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
36
415
ea7f2a4ad530 obsolete: fix doc, rebase no longer aborts with --keep
Patrick Mezard <patrick@mezard.eu>
parents: 409
diff changeset
37 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
38
69
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
39 """
228
5a17c0d41a00 proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 226
diff changeset
40
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
41
334
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 332
diff changeset
42
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
43 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
44
aa1255c2ac8f obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 432
diff changeset
45 try:
aa1255c2ac8f obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 432
diff changeset
46 from mercurial import obsolete
489
fdf3ae486e01 Fix mercurial version check
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 486
diff changeset
47 if not obsolete._enabled:
fdf3ae486e01 Fix mercurial version check
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 486
diff changeset
48 obsolete._enabled = True
433
aa1255c2ac8f obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 432
diff changeset
49 except ImportError:
458
5d47d854716e obsolete: fix indentation in obsolete import block
Patrick Mezard <patrick@mezard.eu>
parents: 457
diff changeset
50 raise util.Abort('Obsolete extension requires Mercurial 2.3 (or later)')
433
aa1255c2ac8f obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 432
diff changeset
51
439
6cff54825233 obsolete: reorder import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 438
diff changeset
52 import sys
6cff54825233 obsolete: reorder import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 438
diff changeset
53 from mercurial.i18n import _
6cff54825233 obsolete: reorder import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 438
diff changeset
54 from mercurial import cmdutil
6cff54825233 obsolete: reorder import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 438
diff changeset
55 from mercurial import commands
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
56 from mercurial import context
46
3b0364fc822f Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 44
diff changeset
57 from mercurial import discovery
3b0364fc822f Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 44
diff changeset
58 from mercurial import error
439
6cff54825233 obsolete: reorder import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 438
diff changeset
59 from mercurial import extensions
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
60 from mercurial import localrepo
115
d60eddda9546 add an option to ensure unstable are secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 114
diff changeset
61 from mercurial import phases
439
6cff54825233 obsolete: reorder import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 438
diff changeset
62 from mercurial import revset
6cff54825233 obsolete: reorder import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 438
diff changeset
63 from mercurial import scmutil
299
eda6491ca269 obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
64 from mercurial import templatekw
473
1f8f8dd75d18 obsolete: prevent bare hg update to select hidden changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 472
diff changeset
65 from mercurial import merge
435
97d82fbd2c24 obsolete: clean up import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 434
diff changeset
66 from mercurial.node import bin, short, nullid
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
67
459
3477326461e3 obsolete: more typos and cleanup
Patrick Mezard <patrick@mezard.eu>
parents: 458
diff changeset
68 # This extension contains the following code
432
6347bc69b49a obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 431
diff changeset
69 #
6347bc69b49a obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 431
diff changeset
70 # - Extension Helper code
450
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
71 # - Obsolescence cache
432
6347bc69b49a obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 431
diff changeset
72 # - ...
6347bc69b49a obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 431
diff changeset
73 # - Older format compat
160
24346b78cd99 mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 150
diff changeset
74
432
6347bc69b49a obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 431
diff changeset
75
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
76
432
6347bc69b49a obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 431
diff changeset
77 #####################################################################
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
78 ### Extension helper ###
432
6347bc69b49a obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 431
diff changeset
79 #####################################################################
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
80
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
81 class exthelper(object):
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
82 """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
83
457
0fc4addd881c obsolete: fix docstrings
Patrick Mezard <patrick@mezard.eu>
parents: 456
diff changeset
84 A single helper should be instanciated for each extension. Helper
0fc4addd881c obsolete: fix docstrings
Patrick Mezard <patrick@mezard.eu>
parents: 456
diff changeset
85 methods are then used as decorator for various purpose.
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
86
457
0fc4addd881c obsolete: fix docstrings
Patrick Mezard <patrick@mezard.eu>
parents: 456
diff changeset
87 All decorators return the original function and may be chained.
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
88 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
89
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
90 def __init__(self):
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
91 self._uicallables = []
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
92 self._extcallables = []
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
93 self._repocallables = []
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
94 self._revsetsymbols = []
431
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
95 self._templatekws = []
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
96 self._commandwrappers = []
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
97 self._extcommandwrappers = []
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
98 self._functionwrappers = []
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
99 self._duckpunchers = []
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 def final_uisetup(self, ui):
457
0fc4addd881c obsolete: fix docstrings
Patrick Mezard <patrick@mezard.eu>
parents: 456
diff changeset
102 """Method to be used as the extension uisetup
429
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 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
105
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
106 - 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
107 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
108 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
109 passed to runcommand
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
110 - Command wraps (extensions.wrapcommand)
457
0fc4addd881c obsolete: fix docstrings
Patrick Mezard <patrick@mezard.eu>
parents: 456
diff changeset
111 - Changes that need to be visible to other extensions: because
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
112 initialization occurs in phases (all extensions run uisetup, then all
457
0fc4addd881c obsolete: fix docstrings
Patrick Mezard <patrick@mezard.eu>
parents: 456
diff changeset
113 run extsetup), a change made here will be visible to other extensions
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
114 during extsetup
457
0fc4addd881c obsolete: fix docstrings
Patrick Mezard <patrick@mezard.eu>
parents: 456
diff changeset
115 - Monkeypatch or wrap function (extensions.wrapfunction) of dispatch
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
116 module members
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
117 - 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
118 - pushkey setup
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 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
121 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
122 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
123 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
124 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
125 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
126 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
127 c(ui)
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
128
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
129 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
130 """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
131
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
132 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
133
457
0fc4addd881c obsolete: fix docstrings
Patrick Mezard <patrick@mezard.eu>
parents: 456
diff changeset
134 - Changes depending on the status of other extensions. (if
0fc4addd881c obsolete: fix docstrings
Patrick Mezard <patrick@mezard.eu>
parents: 456
diff changeset
135 extensions.find('mq'))
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
136 - Add a global option to all commands
457
0fc4addd881c obsolete: fix docstrings
Patrick Mezard <patrick@mezard.eu>
parents: 456
diff changeset
137 - Register revset functions
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
138 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
139 knownexts = {}
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
140 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
141 revset.symbols[name] = symbol
431
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
142 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
143 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
144 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
145 if ext not in knownexts:
462
d38e02332c2c obsolet: fix extension help code about extension wrapping
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 461
diff changeset
146 e = extensions.find(ext)
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
147 if e is None:
462
d38e02332c2c obsolet: fix extension help code about extension wrapping
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 461
diff changeset
148 raise util.Abort('extension %s not found' % ext)
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
149 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
150 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
151 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
152 c(ui)
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
153
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
154 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
155 """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
156
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
157 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
158
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
159 - 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
160 - Modify configuration variables
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
161 - 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
162 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
163 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
164 c(ui, repo)
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
165
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
166 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
167 """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
168
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
169 example::
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
170
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
171 @eh.uisetup
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
172 def setupbabar(ui):
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
173 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
174 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
175 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
176 return call
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
177
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
178 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
179 """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
180
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
181 example::
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
182
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
183 @eh.extsetup
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
184 def setupcelestine(ui):
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
185 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
186 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
187 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
188 return call
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
189
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
190 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
191 """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
192
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
193 example::
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
194
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
195 @eh.reposetup
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
196 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
197 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
198 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
199 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
200 return call
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
201
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
202 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
203 """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
204
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
205 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
206 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
207
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
208 example::
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
209
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
210 @eh.revset('hidden')
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
211 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
212 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
213 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
214 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
215 def dec(symbol):
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
216 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
217 return symbol
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
218 return dec
160
24346b78cd99 mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 150
diff changeset
219
24346b78cd99 mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 150
diff changeset
220
431
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
221 def templatekw(self, keywordname):
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
222 """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
223
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
224 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
225 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
226
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
227 example::
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
228
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
229 @eh.templatekw('babar')
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
230 def kwbabar(ctx):
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
231 return 'babar'
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
232 """
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
233 def dec(keyword):
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
234 self._templatekws.append((keywordname, keyword))
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
235 return keyword
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
236 return dec
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
237
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
238 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
239 """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
240
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
241 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
242 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
243
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
244 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
245 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
246 string that will be searched using `extension.find` if not found and
457
0fc4addd881c obsolete: fix docstrings
Patrick Mezard <patrick@mezard.eu>
parents: 456
diff changeset
247 Abort error is raised. If the wrapping applies to an extension, it is
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
248 installed during `extsetup`
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
249
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
250 example::
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
251
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
252 @eh.wrapcommand('summary')
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
253 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
254 ui.note('Barry!')
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
255 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
256
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
257 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
258 def dec(wrapper):
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
259 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
260 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
261 else:
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
262 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
263 return wrapper
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
264 return dec
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
265
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
266 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
267 """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
268
457
0fc4addd881c obsolete: fix docstrings
Patrick Mezard <patrick@mezard.eu>
parents: 456
diff changeset
269 This function takes two arguments, the container and the name of the
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
270 function to wrap. The wrapping is performed during `uisetup`.
457
0fc4addd881c obsolete: fix docstrings
Patrick Mezard <patrick@mezard.eu>
parents: 456
diff changeset
271 (there is no extension support)
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
272
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
273 example::
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
274
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
275 @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
276 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
277 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
278 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
279 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
280 def dec(wrapper):
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
281 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
282 return wrapper
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
283 return dec
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
284
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
285 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
286 """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
287
457
0fc4addd881c obsolete: fix docstrings
Patrick Mezard <patrick@mezard.eu>
parents: 456
diff changeset
288 This function takes two arguments, the container and the name of the
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
289 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
290
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
291 example::
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 @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
294 def babar(ctx):
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
295 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
296 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
297 def dec(func):
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
298 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
299 return func
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
300 return dec
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
301
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
302 eh = exthelper()
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
303 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
304 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
305 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
306
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
307 #####################################################################
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
308 ### Obsolescence Caching Logic ###
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
309 #####################################################################
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
310
450
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
311 # Obsolescence related logic can be very slow if we don't have efficient cache.
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
312 #
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
313 # This section implements a cache mechanism that did not make it into core for
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
314 # time reason. It store meaningful set of revision related to obsolescence
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
315 # (obsolete, unstabletble ...
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
316 #
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
317 # Here is:
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
318 #
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
319 # - Computation of meaningful set,
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
320 # - Cache access logic,
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
321 # - Cache invalidation logic,
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
322 # - revset and ctx using this cache.
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
323 #
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
324
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
325
450
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
326 ### Computation of meaningful set
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
327 #
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
328 # Most set can be computed with "simple" revset.
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
329
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
330 #: { set name -> function to compute this set } mapping
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
331 #: function take a single "repo" argument.
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
332 #:
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
333 #: Use the `cachefor` decorator to register new cache function
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
334 cachefuncs = {}
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
335 def cachefor(name):
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
336 """Decorator to register a function as computing the cache for a set"""
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
337 def decorator(func):
450
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
338 assert name not in cachefuncs
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
339 cachefuncs[name] = func
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
340 return func
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
341 return decorator
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
342
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
343 @cachefor('obsolete')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
344 def _computeobsoleteset(repo):
457
0fc4addd881c obsolete: fix docstrings
Patrick Mezard <patrick@mezard.eu>
parents: 456
diff changeset
345 """the set of obsolete revisions"""
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
346 obs = set()
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
347 nm = repo.changelog.nodemap
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
348 for prec in repo.obsstore.precursors:
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
349 rev = nm.get(prec)
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
350 if rev is not None:
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
351 obs.add(rev)
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
352 return set(repo.revs('%ld - public()', obs))
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
353
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
354 @cachefor('unstable')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
355 def _computeunstableset(repo):
457
0fc4addd881c obsolete: fix docstrings
Patrick Mezard <patrick@mezard.eu>
parents: 456
diff changeset
356 """the set of non obsolete revisions with obsolete parents"""
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
357 return set(repo.revs('(obsolete()::) - obsolete()'))
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
358
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
359 @cachefor('suspended')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
360 def _computesuspendedset(repo):
457
0fc4addd881c obsolete: fix docstrings
Patrick Mezard <patrick@mezard.eu>
parents: 456
diff changeset
361 """the set of obsolete parents with non obsolete descendants"""
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
362 return set(repo.revs('obsolete() and obsolete()::unstable()'))
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
363
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
364 @cachefor('extinct')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
365 def _computeextinctset(repo):
457
0fc4addd881c obsolete: fix docstrings
Patrick Mezard <patrick@mezard.eu>
parents: 456
diff changeset
366 """the set of obsolete parents without non obsolete descendants"""
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
367 return set(repo.revs('obsolete() - obsolete()::unstable()'))
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
368
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
369 @eh.wrapfunction(obsolete.obsstore, '__init__')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
370 def _initobsstorecache(orig, obsstore, *args, **kwargs):
457
0fc4addd881c obsolete: fix docstrings
Patrick Mezard <patrick@mezard.eu>
parents: 456
diff changeset
371 """add a cache attribute to obsstore"""
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
372 obsstore.caches = {}
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
373 return orig(obsstore, *args, **kwargs)
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
374
450
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
375 ### Cache access
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
376
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
377 def getobscache(repo, name):
450
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
378 """Return the set of revision that belong to the <name> set
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
379
450
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
380 Such access may compute the set and cache it for future use"""
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
381 if not repo.obsstore:
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
382 return ()
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
383 if name not in repo.obsstore.caches:
450
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
384 repo.obsstore.caches[name] = cachefuncs[name](repo)
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
385 return repo.obsstore.caches[name]
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
386
450
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
387 ### Cache clean up
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
388 #
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
389 # To be simple we need to invalidate obsolescence cache when:
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
390 #
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
391 # - new changeset is added:
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
392 # - public phase is changed
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
393 # - obsolescence marker are added
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
394 # - strip is used a repo
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
395
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
396
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
397 def clearobscaches(repo):
450
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
398 """Remove all obsolescence related cache from a repo
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
399
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
400 This remove all cache in obsstore is the obsstore already exist on the
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
401 repo.
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
402
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
403 (We could be smarter here)"""
449
4f23f224afb4 obsolete: Improves cache invalidation logic
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 448
diff changeset
404 if 'obsstore' in repo._filecache:
4f23f224afb4 obsolete: Improves cache invalidation logic
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 448
diff changeset
405 repo.obsstore.caches.clear()
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
406
450
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
407 @eh.wrapfunction(localrepo.localrepository, 'addchangegroup') # new changeset
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
408 @eh.wrapfunction(phases, 'retractboundary') # phase movement
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
409 @eh.wrapfunction(phases, 'advanceboundary') # phase movement
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
410 @eh.wrapfunction(localrepo.localrepository, 'destroyed') # strip
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
411 def wrapclearcache(orig, repo, *args, **kwargs):
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
412 try:
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
413 return orig(repo, *args, **kwargs)
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
414 finally:
450
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
415 # we are a bit wide here
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
416 # we could restrict to:
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
417 # advanceboundary + phase==public
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
418 # retractboundary + phase==draft
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
419 clearobscaches(repo)
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
420
450
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
421 @eh.wrapfunction(obsolete.obsstore, 'add') # new marker
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
422 def clearonadd(orig, obsstore, *args, **kwargs):
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
423 try:
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
424 return orig(obsstore, *args, **kwargs)
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
425 finally:
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
426 obsstore.caches.clear()
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
427
450
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
428 ### Use the case
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
429 # Function in core that could benefic from the cache are overwritten by cache using version
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
430
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
431 # changectx method
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
432
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
433 @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
434 def unstable(ctx):
8e93e1f67205 obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 144
diff changeset
435 """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
436 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
437 return False
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
438 return ctx.rev() in getobscache(ctx._repo, 'unstable')
148
8e93e1f67205 obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 144
diff changeset
439
8e93e1f67205 obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 144
diff changeset
440
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
441 @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
442 def extinct(ctx):
ea4aa1890b16 obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 212
diff changeset
443 """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
444 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
445 return False
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
446 return ctx.rev() in getobscache(ctx._repo, 'extinct')
213
ea4aa1890b16 obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 212
diff changeset
447
450
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
448 # revset
4d18739b506b obsolete: document the cache stuff
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 449
diff changeset
449
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
450 @eh.revset('obsolete')
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
451 def revsetobsolete(repo, subset, x):
397
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
452 """``obsolete()``
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
453 Changeset is obsolete.
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
454 """
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
455 args = revset.getargs(x, 0, 0, 'obsolete takes no argument')
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
456 obsoletes = getobscache(repo, 'obsolete')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
457 return [r for r in subset if r in obsoletes]
252
470232cea503 [obsolete] fix new api: use the new phase cache api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 228
diff changeset
458
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
459 @eh.revset('unstable')
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
460 def revsetunstable(repo, subset, x):
397
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
461 """``unstable()``
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
462 Unstable changesets are non-obsolete with obsolete ancestors.
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
463 """
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
464 args = revset.getargs(x, 0, 0, 'unstable takes no arguments')
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
465 unstables = getobscache(repo, 'unstable')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
466 return [r for r in subset if r in unstables]
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
467
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
468 @eh.revset('extinct')
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
469 def revsetextinct(repo, subset, x):
397
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
470 """``extinct()``
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
471 Obsolete changesets with obsolete descendants only.
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
472 """
310
2d0dc5c18489 [obsolete] fix revset error message
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 308
diff changeset
473 args = revset.getargs(x, 0, 0, 'extinct takes no arguments')
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
474 extincts = getobscache(repo, 'extinct')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
475 return [r for r in subset if r in extincts]
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
476
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
477 #####################################################################
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
478 ### Complete troubles computation logic ###
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
479 #####################################################################
213
ea4aa1890b16 obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 212
diff changeset
480
451
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
481 # there is two kind of trouble not handled by core right now:
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
482 # - latecomer: (successors for public changeset)
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
483 # - conflicting: (two changeset try to succeed to the same precursors)
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
484 #
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
485 # This section add support for those two addition trouble
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
486 #
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
487 # - Cache computation
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
488 # - revset and ctx method
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
489 # - push warning
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
490
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
491 ### Cache computation
470
a2dfe82f27a0 obsolete: use flag to detect that a obsolescence marker fix a latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 467
diff changeset
492 latediff = 1 # flag to prevent taking late comer fix into account
451
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
493
448
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
494 @cachefor('latecomer')
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
495 def _computelatecomerset(repo):
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
496 """the set of rev trying to obsolete public revision"""
470
a2dfe82f27a0 obsolete: use flag to detect that a obsolescence marker fix a latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 467
diff changeset
497 candidates = _allsuccessors(repo, repo.revs('public()'),
a2dfe82f27a0 obsolete: use flag to detect that a obsolescence marker fix a latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 467
diff changeset
498 haltonflags=latediff)
a2dfe82f27a0 obsolete: use flag to detect that a obsolescence marker fix a latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 467
diff changeset
499 query = '%ld - obsolete() - public()'
a2dfe82f27a0 obsolete: use flag to detect that a obsolescence marker fix a latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 467
diff changeset
500 return set(repo.revs(query, candidates))
213
ea4aa1890b16 obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 212
diff changeset
501
448
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
502 @cachefor('conflicting')
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
503 def _computeconflictingset(repo):
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
504 """the set of rev trying to obsolete public revision"""
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
505 conflicting = set()
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
506 obsstore = repo.obsstore
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
507 newermap = {}
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
508 for ctx in repo.set('(not public()) - obsolete()'):
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
509 prec = obsstore.successors.get(ctx.node(), ())
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
510 toprocess = set(prec)
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
511 while toprocess:
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
512 prec = toprocess.pop()[0]
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
513 if prec not in newermap:
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
514 newermap[prec] = newerversion(repo, prec)
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
515 newer = [n for n in newermap[prec] if n] # filter kill
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
516 if len(newer) > 1:
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
517 conflicting.add(ctx.rev())
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
518 break
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
519 toprocess.update(obsstore.successors.get(prec, ()))
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
520 return conflicting
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
521
451
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
522 ### changectx method
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
523
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
524 @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
525 def latecomer(ctx):
9ac56d36d6ff obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 306
diff changeset
526 """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
527 if ctx.node() is None:
9ac56d36d6ff obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 306
diff changeset
528 return False
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
529 return ctx.rev() in getobscache(ctx._repo, 'latecomer')
307
9ac56d36d6ff obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 306
diff changeset
530
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
531 @eh.addattr(context.changectx, 'conflicting')
354
bd26eb9714fb obsolete: Detect conflicting changeset!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 351
diff changeset
532 def conflicting(ctx):
bd26eb9714fb obsolete: Detect conflicting changeset!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 351
diff changeset
533 """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
534 if ctx.node() is None:
bd26eb9714fb obsolete: Detect conflicting changeset!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 351
diff changeset
535 return False
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
536 return ctx.rev() in getobscache(ctx._repo, 'conflicting')
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
537
451
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
538 ### revset symbol
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
539
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
540 @eh.revset('latecomer')
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
541 def revsetlatecomer(repo, subset, x):
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
542 """``latecomer()``
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
543 Changesets marked as successors of public changesets.
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
544 """
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
545 args = revset.getargs(x, 0, 0, 'latecomer takes no arguments')
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
546 lates = getobscache(repo, 'latecomer')
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
547 return [r for r in subset if r in lates]
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
548
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
549 @eh.revset('conflicting')
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
550 def revsetconflicting(repo, subset, x):
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
551 """``conflicting()``
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
552 Changesets marked as successors of a same changeset.
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
553 """
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
554 args = revset.getargs(x, 0, 0, 'conflicting takes no arguments')
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
555 conf = getobscache(repo, 'conflicting')
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
556 return [r for r in subset if r in conf]
354
bd26eb9714fb obsolete: Detect conflicting changeset!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 351
diff changeset
557
451
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
558
448
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
559 ### Discovery wrapping
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
560
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
561 @eh.wrapfunction(discovery, 'checkheads')
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
562 def wrapcheckheads(orig, repo, remote, outgoing, *args, **kwargs):
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
563 """wrap mercurial.discovery.checkheads
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
564
451
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
565 * prevent latecomer and unstable to be pushed
448
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
566 """
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
567 # do not push instability
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
568 for h in outgoing.missingheads:
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
569 # Checking heads is enough, obsolete descendants are either
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
570 # obsolete or unstable.
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
571 ctx = repo[h]
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
572 if ctx.latecomer():
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
573 raise util.Abort(_("push includes a latecomer changeset: %s!")
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
574 % ctx)
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
575 if ctx.conflicting():
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
576 raise util.Abort(_("push includes a conflicting changeset: %s!")
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
577 % ctx)
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
578 return orig(repo, remote, outgoing, *args, **kwargs)
354
bd26eb9714fb obsolete: Detect conflicting changeset!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 351
diff changeset
579
473
1f8f8dd75d18 obsolete: prevent bare hg update to select hidden changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 472
diff changeset
580 #####################################################################
1f8f8dd75d18 obsolete: prevent bare hg update to select hidden changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 472
diff changeset
581 ### Filter extinct changeset from common operation ###
1f8f8dd75d18 obsolete: prevent bare hg update to select hidden changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 472
diff changeset
582 #####################################################################
1f8f8dd75d18 obsolete: prevent bare hg update to select hidden changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 472
diff changeset
583
1f8f8dd75d18 obsolete: prevent bare hg update to select hidden changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 472
diff changeset
584 @eh.wrapfunction(merge, 'update')
1f8f8dd75d18 obsolete: prevent bare hg update to select hidden changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 472
diff changeset
585 def wrapmergeupdate(orig, repo, node, *args, **kwargs):
1f8f8dd75d18 obsolete: prevent bare hg update to select hidden changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 472
diff changeset
586 """ensure we don't automatically update on hidden changeset"""
1f8f8dd75d18 obsolete: prevent bare hg update to select hidden changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 472
diff changeset
587 if node is None:
1f8f8dd75d18 obsolete: prevent bare hg update to select hidden changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 472
diff changeset
588 # tip of current branch
1f8f8dd75d18 obsolete: prevent bare hg update to select hidden changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 472
diff changeset
589 branch = repo[None].branch()
1f8f8dd75d18 obsolete: prevent bare hg update to select hidden changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 472
diff changeset
590 node = repo.revs('last((.:: and branch(%s)) - hidden())', branch)[0]
1f8f8dd75d18 obsolete: prevent bare hg update to select hidden changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 472
diff changeset
591 return orig(repo, node, *args, **kwargs)
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
592
480
cd1d5b7308be obsolete: ignore hidden changeset when resolving `branchname` revision
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 479
diff changeset
593 @eh.wrapfunction(localrepo.localrepository, 'branchtip')
cd1d5b7308be obsolete: ignore hidden changeset when resolving `branchname` revision
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 479
diff changeset
594 def obsbranchtip(orig, repo, branch):
cd1d5b7308be obsolete: ignore hidden changeset when resolving `branchname` revision
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 479
diff changeset
595 """ensure "stable" reference does not end on a hidden changeset"""
cd1d5b7308be obsolete: ignore hidden changeset when resolving `branchname` revision
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 479
diff changeset
596 result = ()
cd1d5b7308be obsolete: ignore hidden changeset when resolving `branchname` revision
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 479
diff changeset
597 heads = repo.branchmap().get(branch, ())
cd1d5b7308be obsolete: ignore hidden changeset when resolving `branchname` revision
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 479
diff changeset
598 if heads:
cd1d5b7308be obsolete: ignore hidden changeset when resolving `branchname` revision
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 479
diff changeset
599 result = list(repo.set('last(heads(branch(%n) - hidden()))', heads[0]))
cd1d5b7308be obsolete: ignore hidden changeset when resolving `branchname` revision
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 479
diff changeset
600 if not result:
cd1d5b7308be obsolete: ignore hidden changeset when resolving `branchname` revision
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 479
diff changeset
601 raise error.RepoLookupError(_("unknown branch '%s'") % branch)
cd1d5b7308be obsolete: ignore hidden changeset when resolving `branchname` revision
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 479
diff changeset
602 return result[0].node()
cd1d5b7308be obsolete: ignore hidden changeset when resolving `branchname` revision
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 479
diff changeset
603
cd1d5b7308be obsolete: ignore hidden changeset when resolving `branchname` revision
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 479
diff changeset
604
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
605 #####################################################################
445
52b5e14c63d5 obsolete: enforce pdiff and pstatus alias in the extension
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 444
diff changeset
606 ### Additional Utilities ###
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
607 #####################################################################
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
608
451
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
609 # This section contains a lot of small utility function and method
112
eae9be0ee00e adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 109
diff changeset
610
451
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
611 # - Function to create markers
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
612 # - useful alias pstatus and pdiff (should probably go in evolve)
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
613 # - "troubles" method on changectx
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
614 # - function to travel throught the obsolescence graph
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
615 # - function to find useful changeset to stabilize
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
616
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
617 ### Marker Create
252
470232cea503 [obsolete] fix new api: use the new phase cache api
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 228
diff changeset
618
451
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
619 def createmarkers(repo, relations, metadata=None, flag=0):
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
620 """Add obsolete markers between changeset in a repo
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
621
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
622 <relations> must be an iterable of (<old>, (<new>, ...)) tuple.
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
623 `old` and `news` are changectx.
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
624
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
625 Current user and date are used except if specified otherwise in the
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
626 metadata attribute.
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
627
459
3477326461e3 obsolete: more typos and cleanup
Patrick Mezard <patrick@mezard.eu>
parents: 458
diff changeset
628 /!\ assume the repo have been locked by the user /!\
451
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
629 """
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
630 # prepare metadata
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
631 if metadata is None:
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
632 metadata = {}
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
633 if 'date' not in metadata:
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
634 metadata['date'] = '%i %i' % util.makedate()
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
635 if 'user' not in metadata:
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
636 metadata['user'] = repo.ui.username()
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
637 # check future marker
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
638 tr = repo.transaction('add-obsolescence-marker')
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
639 try:
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
640 for prec, sucs in relations:
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
641 if not prec.mutable():
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
642 raise util.Abort("Cannot obsolete immutable changeset: %s" % prec)
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
643 nprec = prec.node()
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
644 nsucs = tuple(s.node() for s in sucs)
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
645 if nprec in nsucs:
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
646 raise util.Abort("Changeset %s cannot obsolete himself" % prec)
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
647 repo.obsstore.create(tr, nprec, nsucs, flag, metadata)
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
648 clearobscaches(repo)
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
649 tr.close()
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
650 finally:
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
651 tr.release()
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
652
451
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
653
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
654 ### Useful alias
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
655
445
52b5e14c63d5 obsolete: enforce pdiff and pstatus alias in the extension
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 444
diff changeset
656 @eh.uisetup
52b5e14c63d5 obsolete: enforce pdiff and pstatus alias in the extension
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 444
diff changeset
657 def _installalias(ui):
52b5e14c63d5 obsolete: enforce pdiff and pstatus alias in the extension
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 444
diff changeset
658 if ui.config('alias', 'pstatus', None) is None:
52b5e14c63d5 obsolete: enforce pdiff and pstatus alias in the extension
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 444
diff changeset
659 ui.setconfig('alias', 'pstatus', 'status --rev .^')
52b5e14c63d5 obsolete: enforce pdiff and pstatus alias in the extension
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 444
diff changeset
660 if ui.config('alias', 'pdiff', None) is None:
52b5e14c63d5 obsolete: enforce pdiff and pstatus alias in the extension
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 444
diff changeset
661 ui.setconfig('alias', 'pdiff', 'diff --rev .^')
483
b12ff7ef35b1 Introduction of olog as an alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 480
diff changeset
662 if ui.config('alias', 'olog', None) is None:
b12ff7ef35b1 Introduction of olog as an alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 480
diff changeset
663 ui.setconfig('alias', 'olog', "log -r 'precursors(.)' --hidden")
445
52b5e14c63d5 obsolete: enforce pdiff and pstatus alias in the extension
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 444
diff changeset
664
451
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
665 # - "troubles" method on changectx
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
666
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
667 @eh.addattr(context.changectx, 'troubles')
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
668 def troubles(ctx):
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
669 """Return a tuple listing all the troubles that affect a changeset
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
670
451
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
671 Troubles may be "unstable", "latecomer" or "conflicting".
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
672 """
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
673 troubles = []
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
674 if ctx.unstable():
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
675 troubles.append('unstable')
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
676 if ctx.latecomer():
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
677 troubles.append('latecomer')
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
678 if ctx.conflicting():
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
679 troubles.append('conflicting')
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
680 return tuple(troubles)
143
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
681
467
869ddfb98c7e obsolete: add a "troubled" revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 462
diff changeset
682 ### Troubled revset symbol
869ddfb98c7e obsolete: add a "troubled" revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 462
diff changeset
683
869ddfb98c7e obsolete: add a "troubled" revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 462
diff changeset
684 @eh.revset('troubled')
869ddfb98c7e obsolete: add a "troubled" revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 462
diff changeset
685 def revsetlatecomer(repo, subset, x):
869ddfb98c7e obsolete: add a "troubled" revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 462
diff changeset
686 """``troubled()``
869ddfb98c7e obsolete: add a "troubled" revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 462
diff changeset
687 Changesets with troubles.
869ddfb98c7e obsolete: add a "troubled" revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 462
diff changeset
688 """
869ddfb98c7e obsolete: add a "troubled" revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 462
diff changeset
689 _ = revset.getargs(x, 0, 0, 'troubled takes no arguments')
869ddfb98c7e obsolete: add a "troubled" revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 462
diff changeset
690 return list(repo.revs('%ld and (unstable() + latecomer() + conflicting())',
869ddfb98c7e obsolete: add a "troubled" revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 462
diff changeset
691 subset))
869ddfb98c7e obsolete: add a "troubled" revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 462
diff changeset
692
451
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
693
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
694 ### Obsolescence graph
dc1bd3595075 more doc and cleanup
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 450
diff changeset
695
452
3cf7ce72dbda add cleanup todo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 451
diff changeset
696 # XXX SOME MAJOR CLEAN UP TO DO HERE XXX
354
bd26eb9714fb obsolete: Detect conflicting changeset!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 351
diff changeset
697
305
0b444d7c5c96 update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 304
diff changeset
698 def _precursors(repo, s):
0b444d7c5c96 update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 304
diff changeset
699 """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
700 cs = set()
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
701 nm = repo.changelog.nodemap
334
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 332
diff changeset
702 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
703 for r in s:
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
704 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
705 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
706 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
707 cs.add(pr)
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
708 return cs
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
709
305
0b444d7c5c96 update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 304
diff changeset
710 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
711 """transitive precursors of a subset"""
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
712 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
713 seen = set()
334
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 332
diff changeset
714 allsubjects = repo.obsstore.successors
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
715 while toproceed:
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
716 nc = toproceed.pop()
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
717 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
718 np = mark[0]
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
719 if np not in seen:
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
720 seen.add(np)
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
721 toproceed.append(np)
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
722 nm = repo.changelog.nodemap
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
723 cs = set()
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
724 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
725 pr = nm.get(p)
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
726 if pr is not None:
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
727 cs.add(pr)
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
728 return cs
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
729
306
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
730 def _successors(repo, s):
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
731 """Successors of a changeset"""
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
732 cs = set()
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
733 nm = repo.changelog.nodemap
334
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 332
diff changeset
734 markerbyobj = repo.obsstore.precursors
306
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
735 for r in s:
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
736 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
737 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
738 sr = nm.get(sub)
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
739 if sr is not None:
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
740 cs.add(sr)
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
741 return cs
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
742
470
a2dfe82f27a0 obsolete: use flag to detect that a obsolescence marker fix a latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 467
diff changeset
743 def _allsuccessors(repo, s, haltonflags=0): # XXX we need a better naming
a2dfe82f27a0 obsolete: use flag to detect that a obsolescence marker fix a latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 467
diff changeset
744 """transitive successors of a subset
a2dfe82f27a0 obsolete: use flag to detect that a obsolescence marker fix a latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 467
diff changeset
745
a2dfe82f27a0 obsolete: use flag to detect that a obsolescence marker fix a latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 467
diff changeset
746 haltonflags allows to provide flags which prevent the evaluation of a
a2dfe82f27a0 obsolete: use flag to detect that a obsolescence marker fix a latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 467
diff changeset
747 marker. """
306
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
748 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
749 seen = set()
334
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 332
diff changeset
750 allobjects = repo.obsstore.precursors
306
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
751 while toproceed:
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
752 nc = toproceed.pop()
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
753 for mark in allobjects.get(nc, ()):
470
a2dfe82f27a0 obsolete: use flag to detect that a obsolescence marker fix a latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 467
diff changeset
754 if mark[2] & haltonflags:
a2dfe82f27a0 obsolete: use flag to detect that a obsolescence marker fix a latecomer
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 467
diff changeset
755 continue
334
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 332
diff changeset
756 for sub in mark[1]:
460
19bba3c91246 obsolete: filter out nullid from possible successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 416
diff changeset
757 if sub == nullid:
19bba3c91246 obsolete: filter out nullid from possible successors
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 416
diff changeset
758 continue # should not be here!
306
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
759 if sub not in seen:
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
760 seen.add(sub)
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
761 toproceed.append(sub)
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
762 nm = repo.changelog.nodemap
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
763 cs = set()
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
764 for s in seen:
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
765 sr = nm.get(s)
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
766 if sr is not None:
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
767 cs.add(sr)
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
768 return cs
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
769
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
770
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
771
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
772 def newerversion(repo, obs):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
773 """Return the newer version of an obsolete changeset"""
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
774 toproceed = set([(obs,)])
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
775 # XXX known optimization available
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
776 newer = set()
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
777 objectrels = repo.obsstore.precursors
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
778 while toproceed:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
779 current = toproceed.pop()
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
780 assert len(current) <= 1, 'splitting not handled yet. %r' % current
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
781 current = [n for n in current if n != nullid]
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
782 if current:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
783 n, = current
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
784 if n in objectrels:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
785 markers = objectrels[n]
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
786 for mark in markers:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
787 toproceed.add(tuple(mark[1]))
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
788 else:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
789 newer.add(tuple(current))
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
790 else:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
791 newer.add(())
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
792 return sorted(newer)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
793
442
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
794
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
795 #####################################################################
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
796 ### Extending revset and template ###
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
797 #####################################################################
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
798
454
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
799 # this section add several useful revset symbol not yet in core.
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
800 # they are subject to changes
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
801
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
802 ### hidden revset is not in core yet
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
803
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
804 @eh.revset('hidden')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
805 def revsethidden(repo, subset, x):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
806 """``hidden()``
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
807 Changeset is hidden.
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
808 """
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
809 args = revset.getargs(x, 0, 0, 'hidden takes no argument')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
810 return [r for r in subset if r in repo.hiddenrevs]
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
811
454
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
812 ### XXX I'm not sure this revset is useful
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
813 @eh.revset('suspended')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
814 def revsetsuspended(repo, subset, x):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
815 """``suspended()``
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
816 Obsolete changesets with non-obsolete descendants.
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
817 """
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
818 args = revset.getargs(x, 0, 0, 'suspended takes no arguments')
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
819 suspended = getobscache(repo, 'suspended')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
820 return [r for r in subset if r in suspended]
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
821
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
822
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
823 @eh.revset('precursors')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
824 def revsetprecursors(repo, subset, x):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
825 """``precursors(set)``
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
826 Immediate precursors of changesets in set.
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
827 """
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
828 s = revset.getset(repo, range(len(repo)), x)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
829 cs = _precursors(repo, s)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
830 return [r for r in subset if r in cs]
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
831
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
832
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
833 @eh.revset('allprecursors')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
834 def revsetallprecursors(repo, subset, x):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
835 """``allprecursors(set)``
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
836 Transitive precursors of changesets in set.
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
837 """
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
838 s = revset.getset(repo, range(len(repo)), x)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
839 cs = _allprecursors(repo, s)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
840 return [r for r in subset if r in cs]
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
841
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
842
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
843 @eh.revset('successors')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
844 def revsetsuccessors(repo, subset, x):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
845 """``successors(set)``
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
846 Immediate successors of changesets in set.
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
847 """
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
848 s = revset.getset(repo, range(len(repo)), x)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
849 cs = _successors(repo, s)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
850 return [r for r in subset if r in cs]
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
851
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
852 @eh.revset('allsuccessors')
306
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
853 def revsetallsuccessors(repo, subset, x):
397
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
854 """``allsuccessors(set)``
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
855 Transitive successors of changesets in set.
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
856 """
306
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
857 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
858 cs = _allsuccessors(repo, s)
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
859 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
860
299
eda6491ca269 obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
861 ### template keywords
454
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
862 # XXX it does not handle troubles well :-/
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
863
431
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
864 @eh.templatekw('obsolete')
299
eda6491ca269 obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
865 def obsoletekw(repo, ctx, templ, **args):
eda6491ca269 obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
866 """:obsolete: String. The obsolescence level of the node, could be
eda6491ca269 obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
867 ``stable``, ``unstable``, ``suspended`` or ``extinct``.
eda6491ca269 obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
868 """
eda6491ca269 obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
869 rev = ctx.rev()
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
870 if ctx.obsolete():
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
871 if ctx.extinct():
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
872 return 'extinct'
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
873 else:
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
874 return 'suspended'
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
875 elif ctx.unstable():
299
eda6491ca269 obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
876 return 'unstable'
eda6491ca269 obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
877 return 'stable'
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
878
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
879 #####################################################################
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
880 ### Various trouble warning ###
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
881 #####################################################################
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
882
454
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
883 # This section take care of issue warning to the user when troubles appear
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
884
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
885 @eh.wrapcommand("update")
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
886 @eh.wrapcommand("pull")
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
887 def wrapmayobsoletewc(origfn, ui, repo, *args, **opts):
454
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
888 """Warn that the working directory parent is an obsolete changeset"""
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
889 res = origfn(ui, repo, *args, **opts)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
890 if repo['.'].obsolete():
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
891 ui.warn(_('Working directory parent is obsolete\n'))
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
892 return res
71
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
893
454
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
894 # XXX this could wrap transaction code
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
895 # XXX (but this is a bit a layer violation)
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
896 @eh.wrapcommand("commit")
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
897 @eh.wrapcommand("push")
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
898 @eh.wrapcommand("pull")
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
899 @eh.wrapcommand("graft")
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
900 @eh.wrapcommand("phase")
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
901 @eh.wrapcommand("unbundle")
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
902 def warnobserrors(orig, ui, repo, *args, **kwargs):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
903 """display warning is the command resulted in more instable changeset"""
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
904 priorunstables = len(repo.revs('unstable()'))
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
905 priorlatecomers = len(repo.revs('latecomer()'))
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
906 priorconflictings = len(repo.revs('conflicting()'))
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
907 try:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
908 return orig(ui, repo, *args, **kwargs)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
909 finally:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
910 newunstables = len(repo.revs('unstable()')) - priorunstables
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
911 newlatecomers = len(repo.revs('latecomer()')) - priorlatecomers
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
912 newconflictings = len(repo.revs('conflicting()')) - priorconflictings
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
913 if newunstables > 0:
486
2111c655b4f5 fix typo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 483
diff changeset
914 ui.warn(_('%i new unstable changesets\n') % newunstables)
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
915 if newlatecomers > 0:
486
2111c655b4f5 fix typo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 483
diff changeset
916 ui.warn(_('%i new latecomer changesets\n') % newlatecomers)
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
917 if newconflictings > 0:
486
2111c655b4f5 fix typo
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 483
diff changeset
918 ui.warn(_('%i new conflicting changesets\n') % newconflictings)
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
919
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
920 @eh.reposetup
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
921 def _repostabilizesetup(ui, repo):
454
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
922 """Add a hint for "hg stabilize" when troubles make push fails
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
923 """
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
924 if not repo.local():
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
925 return
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
926
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
927 opush = repo.push
71
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
928
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
929 class stabilizerrepo(repo.__class__):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
930 def push(self, remote, *args, **opts):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
931 """wrapper around pull that pull obsolete relation"""
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
932 try:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
933 result = opush(remote, *args, **opts)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
934 except util.Abort, ex:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
935 hint = _("use 'hg stabilize' to get a stable history "
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
936 "or --force to ignore warnings")
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
937 if (len(ex.args) >= 1
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
938 and ex.args[0].startswith('push includes ')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
939 and ex.hint is None):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
940 ex.hint = hint
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
941 raise
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
942 return result
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
943 repo.__class__ = stabilizerrepo
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
944
479
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
945 @eh.wrapcommand("summary")
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
946 def obssummary(orig, ui, repo, *args, **kwargs):
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
947 ret = orig(ui, repo, *args, **kwargs)
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
948 nbunstable = len(getobscache(repo, 'unstable'))
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
949 nblatecomer = len(getobscache(repo, 'latecomer'))
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
950 nbconflicting = len(getobscache(repo, 'unstable'))
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
951 if nbunstable:
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
952 ui.write('unstable: %i changesets\n' % nbunstable)
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
953 else:
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
954 ui.note('unstable: 0 changesets\n')
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
955 if nblatecomer:
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
956 ui.write('latecomer: %i changesets\n' % nblatecomer)
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
957 else:
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
958 ui.note('latecomer: 0 changesets\n')
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
959 if nbconflicting:
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
960 ui.write('conflicting: %i changesets\n' % nbconflicting)
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
961 else:
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
962 ui.note('conflicting: 0 changesets\n')
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
963 return ret
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
964
b63da0fb8ee5 obsolete: add obsolete data to summary.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 473
diff changeset
965
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
966 #####################################################################
454
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
967 ### Core Other extension compat ###
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
968 #####################################################################
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
969
454
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
970 # This section make official history rewritter create obsolete marker
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
971
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
972
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
973 ### commit --amend
454
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
974 # make commit --amend create obsolete marker
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
975 #
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
976 # The precursor is still strip from the repository.
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
977
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
978 @eh.wrapfunction(cmdutil, 'amend')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
979 def wrapcmdutilamend(orig, ui, repo, commitfunc, old, *args, **kwargs):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
980 oldnode = old.node()
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
981 new = orig(ui, repo, commitfunc, old, *args, **kwargs)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
982 if new != oldnode:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
983 lock = repo.lock()
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
984 try:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
985 tr = repo.transaction('post-amend-obst')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
986 try:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
987 meta = {
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
988 'date': '%i %i' % util.makedate(),
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
989 'user': ui.username(),
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
990 }
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
991 repo.obsstore.create(tr, oldnode, [new], 0, meta)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
992 tr.close()
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
993 clearobscaches(repo)
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
994 finally:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
995 tr.release()
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
996 finally:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
997 lock.release()
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
998 return new
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
999
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
1000 ### rebase
454
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
1001 #
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
1002 # - ignore obsolete changeset
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
1003 # - create obsolete marker *instead of* striping
150
f12fd2410a60 obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 148
diff changeset
1004
253
8ee6c5b98d73 [obsolete] fix new api: be more flexible on rebase's buildstate signature
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 252
diff changeset
1005 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
1006 """wrapper for rebase 's buildstate that exclude obsolete changeset"""
472
641e0cd43d6d obsolete: prevent rebasing of public changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 471
diff changeset
1007
150
f12fd2410a60 obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 148
diff changeset
1008 rebaseset = repo.revs('%ld - extinct()', rebaseset)
471
8be3973adf34 obsolete: warn when the whole rebase set was remove because extinct
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 470
diff changeset
1009 if not rebaseset:
8be3973adf34 obsolete: warn when the whole rebase set was remove because extinct
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 470
diff changeset
1010 repo.ui.warn(_('whole rebase set is extinct and ignored.\n'))
8be3973adf34 obsolete: warn when the whole rebase set was remove because extinct
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 470
diff changeset
1011 return {}
472
641e0cd43d6d obsolete: prevent rebasing of public changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 471
diff changeset
1012 root = min(rebaseset)
641e0cd43d6d obsolete: prevent rebasing of public changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 471
diff changeset
1013 if not repo._rebasekeep and not repo[root].mutable():
641e0cd43d6d obsolete: prevent rebasing of public changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 471
diff changeset
1014 raise util.Abort(_("can't rebase immutable changeset %s") % repo[root],
641e0cd43d6d obsolete: prevent rebasing of public changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 471
diff changeset
1015 hint=_('see hg help phases for details'))
253
8ee6c5b98d73 [obsolete] fix new api: be more flexible on rebase's buildstate signature
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 252
diff changeset
1016 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
1017
282
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1018 def defineparents(orig, repo, rev, target, state, *args, **kwargs):
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1019 rebasestate = getattr(repo, '_rebasestate', None)
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1020 if rebasestate is not None:
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1021 repo._rebasestate = dict(state)
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1022 repo._rebasetarget = target
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1023 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
1024
282
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1025 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
1026 """wrapper for rebase 's concludenode that set obsolete relation"""
282
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1027 newrev = orig(repo, rev, p1, *args, **kwargs)
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1028 rebasestate = getattr(repo, '_rebasestate', None)
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1029 if rebasestate is not None:
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1030 if newrev is not None:
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1031 nrev = repo[newrev].rev()
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1032 else:
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1033 nrev = p1
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1034 repo._rebasestate[rev] = nrev
71
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
1035 return newrev
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
1036
274
6622a24f3b0f obsolete: fix rebase wrapping
Patrick Mezard <patrick@mezard.eu>
parents: 273
diff changeset
1037 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
1038
5eecfda0a5c7 obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 310
diff changeset
1039 reallykeep = kwargs.get('keep', False)
275
336210dada95 obsolete: make rebase abort with --keep
Patrick Mezard <patrick@mezard.eu>
parents: 274
diff changeset
1040 kwargs = dict(kwargs)
84
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
1041 kwargs['keep'] = True
472
641e0cd43d6d obsolete: prevent rebasing of public changeset
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 471
diff changeset
1042 repo._rebasekeep = reallykeep
84
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
1043
282
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1044 # 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
1045 # replacements if any. Doing it in concludenode() prevents
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1046 # aborting the rebase, and is not called with all relevant
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1047 # revisions in --collapse case. Instead, we try to track the
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1048 # rebase state structure by sampling/updating it in
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1049 # defineparents() and concludenode(). The obsolete markers are
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1050 # added from this state after a successful call.
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1051 repo._rebasestate = {}
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1052 repo._rebasetarget = None
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1053 try:
443
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
1054 l = repo.lock()
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
1055 try:
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
1056 res = orig(ui, repo, *args, **kwargs)
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
1057 if not reallykeep:
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
1058 # Filter nullmerge or unrebased entries
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
1059 repo._rebasestate = dict(p for p in repo._rebasestate.iteritems()
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
1060 if p[1] >= 0)
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
1061 if not res and not kwargs.get('abort') and repo._rebasestate:
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
1062 # Rebased revisions are assumed to be descendants of
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
1063 # targetrev. If a source revision is mapped to targetrev
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
1064 # or to another rebased revision, it must have been
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
1065 # removed.
455
f46a41006136 obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 454
diff changeset
1066 markers = []
443
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
1067 if kwargs.get('collapse'):
455
f46a41006136 obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 454
diff changeset
1068 # collapse assume revision disapear because they are all
f46a41006136 obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 454
diff changeset
1069 # in the created revision
f46a41006136 obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 454
diff changeset
1070 newrevs = set(repo._rebasestate.values())
f46a41006136 obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 454
diff changeset
1071 newrevs.remove(repo._rebasetarget)
f46a41006136 obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 454
diff changeset
1072 if newrevs:
f46a41006136 obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 454
diff changeset
1073 # we create new revision.
f46a41006136 obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 454
diff changeset
1074 # A single one by --collapse design
f46a41006136 obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 454
diff changeset
1075 assert len(newrevs) == 1
f46a41006136 obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 454
diff changeset
1076 new = tuple(repo[n] for n in newrevs)
443
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
1077 else:
455
f46a41006136 obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 454
diff changeset
1078 # every body died. no new changeset created
f46a41006136 obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 454
diff changeset
1079 new = (repo[repo._rebasetarget],)
f46a41006136 obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 454
diff changeset
1080 for rev, newrev in sorted(repo._rebasestate.items()):
f46a41006136 obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 454
diff changeset
1081 markers.append((repo[rev], new))
311
5eecfda0a5c7 obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 310
diff changeset
1082 else:
455
f46a41006136 obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 454
diff changeset
1083 # no collapse assume revision disapear because they are
f46a41006136 obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 454
diff changeset
1084 # contained in parent
f46a41006136 obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 454
diff changeset
1085 for rev, newrev in sorted(repo._rebasestate.items()):
f46a41006136 obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 454
diff changeset
1086 markers.append((repo[rev], (repo[newrev],)))
f46a41006136 obsolete: simplify rebase wrapping code and change relation creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 454
diff changeset
1087 createmarkers(repo, markers)
443
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
1088 return res
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
1089 finally:
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
1090 l.release()
282
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1091 finally:
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1092 delattr(repo, '_rebasestate')
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1093 delattr(repo, '_rebasetarget')
84
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
1094
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
1095 @eh.extsetup
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
1096 def _rebasewrapping(ui):
356
56d4c6207ef9 Move obserror warning into the obsolete extension.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 354
diff changeset
1097 # warning about more obsolete
42
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
1098 try:
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
1099 rebase = extensions.find('rebase')
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
1100 if rebase:
356
56d4c6207ef9 Move obserror warning into the obsolete extension.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 354
diff changeset
1101 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
1102 extensions.wrapfunction(rebase, 'buildstate', buildstate)
282
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
1103 extensions.wrapfunction(rebase, 'defineparents', defineparents)
42
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
1104 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
1105 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
1106 except KeyError:
305
0b444d7c5c96 update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 304
diff changeset
1107 pass # rebase not found
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
1108
44
b243c10a5fbe Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 43
diff changeset
1109
430
07db1d511faf obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 429
diff changeset
1110 #####################################################################
07db1d511faf obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 429
diff changeset
1111 ### Older format management ###
07db1d511faf obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 429
diff changeset
1112 #####################################################################
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
1113
430
07db1d511faf obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 429
diff changeset
1114 # 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
1115 # handled by core
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
1116
439
6cff54825233 obsolete: reorder import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 438
diff changeset
1117 import json
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
1118
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
1119 @eh.reposetup
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
1120 def _checkoldobsolete(ui, repo):
459
3477326461e3 obsolete: more typos and cleanup
Patrick Mezard <patrick@mezard.eu>
parents: 458
diff changeset
1121 """Detect that a repo still contains some old obsolete format
273
87e4d1eec5e8 obsolete: add debugsuccessors command
Patrick Mezard <patrick@mezard.eu>
parents: 254
diff changeset
1122 """
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
1123 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
1124 return
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
1125 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
1126 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
1127 break
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
1128 else:
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
1129 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
1130 if not data:
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
1131 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
1132 if data:
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
1133 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
1134 'run `hg debugconvertobsolete` once.')
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
1135
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
1136 def _obsdeserialise(flike):
74
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
1137 """read a file like object serialised with _obsserialise
c7dd26dec7fc [obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 73
diff changeset
1138
454
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
1139 this desierialize into a {subject -> objects} mapping
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
1140
4e34a723115b obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 453
diff changeset
1141 this was the very first format ever."""
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
1142 rels = {}
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
1143 for line in flike:
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
1144 subhex, objhex = line.split()
80
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
1145 subnode = bin(subhex)
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
1146 if subnode == nullid:
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
1147 subnode = None
5d029a358252 [obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 79
diff changeset
1148 rels.setdefault( subnode, set()).add(bin(objhex))
70
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
1149 return rels
af4f7ef0a3c1 [obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 69
diff changeset
1150
441
d702f0d26c6a obsolete: remove debugsuccessors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 440
diff changeset
1151 cmdtable = {}
d702f0d26c6a obsolete: remove debugsuccessors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 440
diff changeset
1152 command = cmdutil.command(cmdtable)
276
f26e9bc5f7fc obsolete: use new-style command registration
Patrick Mezard <patrick@mezard.eu>
parents: 275
diff changeset
1153 @command('debugconvertobsolete', [], '')
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
1154 def cmddebugconvertobsolete(ui, repo):
278
fa0b9b8a83c0 obsolete: add or fix debug commands help
Patrick Mezard <patrick@mezard.eu>
parents: 277
diff changeset
1155 """import markers from an .hg/obsolete-relations file"""
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
1156 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
1157 err = 0
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
1158 l = repo.lock()
334
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 332
diff changeset
1159 some = False
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
1160 try:
361
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1161 unlink = []
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1162 tr = repo.transaction('convert-obsolete')
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
1163 try:
361
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1164 repo._importoldobsolete = True
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1165 store = repo.obsstore
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1166 ### very first format
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
1167 try:
361
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1168 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
1169 try:
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1170 some = True
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1171 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
1172 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
1173 suc = bin(subhex)
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1174 prec = bin(objhex)
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1175 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
1176 meta = {
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1177 '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
1178 'user': ui.username(),
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1179 }
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1180 try:
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1181 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
1182 cnt += 1
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1183 except ValueError:
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1184 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
1185 % (line))
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1186 err += 1
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1187 finally:
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1188 f.close()
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1189 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
1190 except IOError:
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1191 pass
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1192 ### second (json) format
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1193 data = repo.sopener.tryread('obsoletemarkers')
334
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 332
diff changeset
1194 if data:
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 332
diff changeset
1195 some = True
361
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1196 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
1197 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
1198 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
1199 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
1200 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
1201 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
1202 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
1203 try:
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1204 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
1205 except LOOKUP_ERRORS:
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1206 pass
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1207 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
1208 try:
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1209 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
1210 except LOOKUP_ERRORS:
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1211 pass
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
1212
361
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1213 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
1214 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
1215 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
1216 try:
361
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1217 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
1218 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
1219 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
1220 0, meta)
341
7653f80fd7a4 obsolete: harden convertion from first format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 340
diff changeset
1221 cnt += 1
7653f80fd7a4 obsolete: harden convertion from first format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 340
diff changeset
1222 except ValueError:
361
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1223 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
1224 % (oldobject, oldsubjects))
341
7653f80fd7a4 obsolete: harden convertion from first format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 340
diff changeset
1225 err += 1
361
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1226 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
1227 tr.close()
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1228 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
1229 util.unlink(path)
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1230 finally:
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1231 tr.release()
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
1232 finally:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
1233 del repo._importoldobsolete
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
1234 l.release()
334
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 332
diff changeset
1235 if not some:
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 332
diff changeset
1236 ui.warn('nothing to do\n')
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
1237 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
1238 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
1239 ui.write_err('%i conversion failed. check you graph!\n' % err)