annotate hgext/obsolete.py @ 448:96c896f0180b

obsolete: some more movement
author Pierre-Yves David <pierre-yves.david@ens-lyon.org>
date Tue, 07 Aug 2012 21:39:55 +0200
parents fa85e7205e0b
children 4f23f224afb4
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
1 # obsolete.py - introduce the obsolete concept in mercurial.
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
2 #
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
3 # Copyright 2011 Pierre-Yves David <pierre-yves.david@ens-lyon.org>
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
4 # Logilab SA <contact@logilab.fr>
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
5 #
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
6 # This software may be used and distributed according to the terms of the
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
7 # GNU General Public License version 2 or any later version.
69
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
8 """Introduce the Obsolete concept to mercurial
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
9
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
10 General concept
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
11 ===============
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
12
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
13 This extension introduces the *obsolete* concept. It adds a new *obsolete*
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
14 relation between two changesets. A relation ``<changeset B> obsolete <changeset
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
15 A>`` is set to denote that ``<changeset B>`` is new version of ``<changeset
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
16 A>``.
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
17
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
18 The *obsolete* relation act as a **perpendicular history** to the standard
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
19 changeset history. Standard changeset history versions files. The *obsolete*
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
20 relation versions changesets.
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
21
228
5a17c0d41a00 proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 226
diff changeset
22 :obsolete: a changeset that has been replaced by another one.
5a17c0d41a00 proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 226
diff changeset
23 :unstable: a changeset that is not obsolete but has an obsolete ancestor.
85
531058dbd703 [obsolete] vocabulary update suggestion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 84
diff changeset
24 :suspended: an obsolete changeset with unstable descendant.
228
5a17c0d41a00 proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 226
diff changeset
25 :extinct: an obsolete changeset without unstable descendant.
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
26 (subject to garbage collection)
85
531058dbd703 [obsolete] vocabulary update suggestion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 84
diff changeset
27
531058dbd703 [obsolete] vocabulary update suggestion
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 84
diff changeset
28 Another name for unstable could be out of sync.
69
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
29
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
30
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
31 Usage and Feature
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
32 =================
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
33
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
34
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
35 New commands
228
5a17c0d41a00 proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 226
diff changeset
36 ------------
69
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
37
415
ea7f2a4ad530 obsolete: fix doc, rebase no longer aborts with --keep
Patrick Mezard <patrick@mezard.eu>
parents: 409
diff changeset
38 Note that rebased changesets are now marked obsolete instead of being stripped.
275
336210dada95 obsolete: make rebase abort with --keep
Patrick Mezard <patrick@mezard.eu>
parents: 274
diff changeset
39
69
aee53d546849 [obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 58
diff changeset
40 """
228
5a17c0d41a00 proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 226
diff changeset
41
54
ad1a4fb0fc49 Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 53
diff changeset
42
89
757153438e58 [obsolet] base64 encore obsolete rel for pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 87
diff changeset
43
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
44 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
45
aa1255c2ac8f obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 432
diff changeset
46 try:
aa1255c2ac8f obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 432
diff changeset
47 from mercurial import obsolete
aa1255c2ac8f obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 432
diff changeset
48 obsolete._enabled = True
aa1255c2ac8f obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 432
diff changeset
49 except ImportError:
aa1255c2ac8f obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 432
diff changeset
50 raise util.Abort('Obsolete extension requires Mercurial 2.3 (or later)')
aa1255c2ac8f obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 432
diff changeset
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
6cff54825233 obsolete: reorder import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 438
diff changeset
64 from mercurial import templatekw
435
97d82fbd2c24 obsolete: clean up import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 434
diff changeset
65 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
66
432
6347bc69b49a obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 431
diff changeset
67 # This extension hold the following code
6347bc69b49a obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 431
diff changeset
68 #
6347bc69b49a obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 431
diff changeset
69 # - Extension Helper code
6347bc69b49a obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 431
diff changeset
70 # - ...
6347bc69b49a obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 431
diff changeset
71 # - Older format compat
160
24346b78cd99 mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 150
diff changeset
72
432
6347bc69b49a obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 431
diff changeset
73
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
74
432
6347bc69b49a obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 431
diff changeset
75 #####################################################################
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
76 ### Extension helper ###
432
6347bc69b49a obsolete: some more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 431
diff changeset
77 #####################################################################
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
78
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
79 class exthelper(object):
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
80 """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
81
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
82 A single helper should be intanciated for each extension. Helper method are
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
83 then used as decorator for various purpose.
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
84
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
85 All decorator returns the original function and may be chained.
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
86 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
87
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
88 def __init__(self):
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
89 self._uicallables = []
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
90 self._extcallables = []
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
91 self._repocallables = []
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
92 self._revsetsymbols = []
431
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
93 self._templatekws = []
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
94 self._commandwrappers = []
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
95 self._extcommandwrappers = []
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
96 self._functionwrappers = []
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
97 self._duckpunchers = []
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
98
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
99 def final_uisetup(self, ui):
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
100 """Method to be used as a the extension uisetup
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
101
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
102 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
103
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
104 - 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
105 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
106 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
107 passed to runcommand
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
108 - Command wraps (extensions.wrapcommand)
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
109 - Changes that need to be visible by other extensions: because
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
110 initialization occurs in phases (all extensions run uisetup, then all
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
111 run extsetup), a change made here will be visible by other extensions
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
112 during extsetup
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
113 - Monkeypatches or function wraps (extensions.wrapfunction) of dispatch
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
114 module members
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
115 - 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
116 - pushkey setup
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
117 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
118 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
119 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
120 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
121 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
122 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
123 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
124 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
125 c(ui)
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
126
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
127 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
128 """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
129
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
130 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
131
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
132 - Changes depending on the status of other extensions. (if extensions.find('mq'))
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
133 - Add a global option to all commands
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
134 - Extend revsets
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
135 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
136 knownexts = {}
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
137 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
138 revset.symbols[name] = symbol
431
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
139 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
140 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
141 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
142 if ext not in knownexts:
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
143 e = extensions.find('rebase')
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
144 if e is None:
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
145 raise util.Abort('extension %s not found' %e)
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
146 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
147 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
148 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
149 c(ui)
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
150
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
151 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
152 """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
153
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
154 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
155
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
156 - 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
157 - Modify configuration variables
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
158 - 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
159 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
160 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
161 c(ui, repo)
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 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
164 """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
165
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
166 example::
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
167
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
168 @eh.uisetup
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
169 def setupbabar(ui):
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
170 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
171 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
172 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
173 return call
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 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
176 """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
177
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
178 example::
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
179
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
180 @eh.extsetup
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
181 def setupcelestine(ui):
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
182 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
183 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
184 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
185 return call
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 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
188 """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
189
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
190 example::
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
191
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
192 @eh.reposetup
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
193 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
194 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
195 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
196 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
197 return call
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 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
200 """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
201
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
202 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
203 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
204
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
205 example::
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
206
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
207 @eh.revset('hidden')
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
208 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
209 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
210 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
211 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
212 def dec(symbol):
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
213 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
214 return symbol
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
215 return dec
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
216
431
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
217
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
218 def templatekw(self, keywordname):
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
219 """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
220
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
221 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
222 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
223
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
224 example::
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
225
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
226 @eh.templatekw('babar')
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
227 def kwbabar(ctx):
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
228 return 'babar'
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
229 """
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
230 def dec(keyword):
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
231 self._templatekws.append((keywordname, keyword))
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
232 return keyword
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
233 return dec
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
234
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
235 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
236 """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
237
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
238 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
239 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
240
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
241 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
242 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
243 string that will be searched using `extension.find` if not found and
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
244 Abort error is raised. If the wrapping apply to an extension, it is
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
245 installed during `extsetup`
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
246
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
247 example::
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
248
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
249 @eh.wrapcommand('summary')
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
250 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
251 ui.note('Barry!')
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
252 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
253
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
254 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
255 def dec(wrapper):
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
256 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
257 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
258 else:
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
259 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
260 return wrapper
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
261 return dec
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
262
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
263 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
264 """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
265
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
266 This function take two argument, the container and the name of the
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
267 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
268 (there is don't support extension)
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
269
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
270 example::
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
271
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
272 @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
273 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
274 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
275 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
276 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
277 def dec(wrapper):
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
278 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
279 return wrapper
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
280 return dec
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
281
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
282 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
283 """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
284
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
285 This function take two argument, the container and the name of the
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
286 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
287
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
288 example::
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
289
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
290 @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
291 def babar(ctx):
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
292 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
293 """
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
294 def dec(func):
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
295 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
296 return func
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
297 return dec
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
298
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
299 eh = exthelper()
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
300 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
301 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
302 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
303
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
304 #####################################################################
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
305 ### Obsolescence Caching Logic ###
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
306 #####################################################################
32
c27491be4431 obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff changeset
307
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
308 ### compute cache functions
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
309
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
310 computecache = {}
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
311 def cachefor(name):
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
312 """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
313 def decorator(func):
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
314 assert name not in computecache
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
315 computecache[name] = func
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
316 return func
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
317 return decorator
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
318
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
319 @cachefor('obsolete')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
320 def _computeobsoleteset(repo):
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
321 """the set of obsolete revision"""
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
322 obs = set()
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
323 nm = repo.changelog.nodemap
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
324 for prec in repo.obsstore.precursors:
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
325 rev = nm.get(prec)
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
326 if rev is not None:
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
327 obs.add(rev)
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
328 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
329
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
330 @cachefor('unstable')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
331 def _computeunstableset(repo):
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
332 """the set of non obsolete revision with obsolete parent"""
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
333 return set(repo.revs('(obsolete()::) - obsolete()'))
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
334
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
335 @cachefor('suspended')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
336 def _computesuspendedset(repo):
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
337 """the set of obsolete parent with non obsolete descendant"""
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
338 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
339
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
340 @cachefor('extinct')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
341 def _computeextinctset(repo):
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
342 """the set of obsolete parent without non obsolete descendant"""
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
343 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
344
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
345 @eh.wrapfunction(obsolete.obsstore, '__init__')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
346 def _initobsstorecache(orig, obsstore, *args, **kwargs):
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
347 """add a caches attributes to obsstore"""
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
348 obsstore.caches = {}
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
349 return orig(obsstore, *args, **kwargs)
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
350
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
351 def getobscache(repo, name):
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
352 if not repo.obsstore:
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
353 return ()
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
354 if name not in repo.obsstore.caches:
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
355 repo.obsstore.caches[name] = computecache[name](repo)
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
356 return repo.obsstore.caches[name]
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
357
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 ### cache clean up
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
360 def clearobscaches(repo):
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
361 #if 'obsstore' in vars(repo):
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
362 # should work great but cache invalidation act strange
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
363 repo.obsstore.caches.clear()
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
364
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
365 @eh.wrapfunction(localrepo.localrepository, 'updatebranchcache')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
366 @eh.wrapfunction(phases, 'advanceboundary')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
367 def wrapclearcache(orig, repo, *args, **kwargs):
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
368 try:
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
369 return orig(repo, *args, **kwargs)
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
370 finally:
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
371 clearobscaches(repo)
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
372
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
373 @eh.wrapfunction(obsolete.obsstore, 'add')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
374 def clearonadd(orig, obsstore, *args, **kwargs):
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
375 try:
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
376 return orig(obsstore, *args, **kwargs)
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
377 finally:
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
378 obsstore.caches.clear()
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
379
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
380 ### cache user
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
381
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
382 @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
383 def unstable(ctx):
8e93e1f67205 obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 144
diff changeset
384 """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
385 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
386 return False
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
387 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
388
8e93e1f67205 obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 144
diff changeset
389
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
390 @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
391 def extinct(ctx):
ea4aa1890b16 obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 212
diff changeset
392 """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
393 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
394 return False
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
395 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
396
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
397 @eh.revset('obsolete')
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
398 def revsetobsolete(repo, subset, x):
397
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
399 """``obsolete()``
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
400 Changeset is obsolete.
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
401 """
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
402 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
403 obsoletes = getobscache(repo, 'obsolete')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
404 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
405
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
406 @eh.revset('unstable')
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
407 def revsetunstable(repo, subset, x):
397
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
408 """``unstable()``
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
409 Unstable changesets are non-obsolete with obsolete ancestors.
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
410 """
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
411 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
412 unstables = getobscache(repo, 'unstable')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
413 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
414
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
415 @eh.revset('extinct')
135
1a08daef8a53 obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 132
diff changeset
416 def revsetextinct(repo, subset, x):
397
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
417 """``extinct()``
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
418 Obsolete changesets with obsolete descendants only.
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
419 """
310
2d0dc5c18489 [obsolete] fix revset error message
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 308
diff changeset
420 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
421 extincts = getobscache(repo, 'extinct')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
422 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
423
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
424 #####################################################################
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
425 ### Complete troubles computation logic ###
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
426 #####################################################################
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
427
448
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
428 @cachefor('latecomer')
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
429 def _computelatecomerset(repo):
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
430 """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
431 query = 'allsuccessors(public()) - obsolete() - public()'
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
432 return set(repo.revs(query))
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
433
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
434 @cachefor('conflicting')
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
435 def _computeconflictingset(repo):
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
436 """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
437 conflicting = set()
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
438 obsstore = repo.obsstore
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
439 newermap = {}
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
440 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
441 prec = obsstore.successors.get(ctx.node(), ())
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
442 toprocess = set(prec)
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
443 while toprocess:
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
444 prec = toprocess.pop()[0]
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
445 if prec not in newermap:
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
446 newermap[prec] = newerversion(repo, prec)
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
447 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
448 if len(newer) > 1:
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
449 conflicting.add(ctx.rev())
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
450 break
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
451 toprocess.update(obsstore.successors.get(prec, ()))
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
452 return conflicting
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
453
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
454 @eh.addattr(context.changectx, 'latecomer')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
455 def latecomer(ctx):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
456 """is the changeset latecomer (Try to succeed to public change)"""
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
457 if ctx.node() is None:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
458 return False
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
459 return ctx.rev() in getobscache(ctx._repo, 'latecomer')
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
460
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
461 @eh.addattr(context.changectx, 'conflicting')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
462 def conflicting(ctx):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
463 """is the changeset conflicting (Try to succeed to public change)"""
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
464 if ctx.node() is None:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
465 return False
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
466 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
467
448
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
468 ### Discovery wrapping
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
469
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
470 @eh.wrapfunction(discovery, 'checkheads')
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
471 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
472 """wrap mercurial.discovery.checkheads
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
473
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
474 * prevent unstability to be pushed
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
475 * patch remote to ignore obsolete heads on remote
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
476 """
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
477 # do not push instability
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
478 for h in outgoing.missingheads:
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
479 # 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
480 # obsolete or unstable.
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
481 ctx = repo[h]
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
482 if ctx.latecomer():
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
483 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
484 % ctx)
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
485 if ctx.conflicting():
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
486 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
487 % ctx)
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
488 return orig(repo, remote, outgoing, *args, **kwargs)
96c896f0180b obsolete: some more movement
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 447
diff changeset
489
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
490
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
491 #####################################################################
445
52b5e14c63d5 obsolete: enforce pdiff and pstatus alias in the extension
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 444
diff changeset
492 ### Additional Utilities ###
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
493 #####################################################################
354
bd26eb9714fb obsolete: Detect conflicting changeset!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 351
diff changeset
494
445
52b5e14c63d5 obsolete: enforce pdiff and pstatus alias in the extension
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 444
diff changeset
495 @eh.uisetup
52b5e14c63d5 obsolete: enforce pdiff and pstatus alias in the extension
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 444
diff changeset
496 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
497 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
498 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
499 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
500 ui.setconfig('alias', 'pdiff', 'diff --rev .^')
52b5e14c63d5 obsolete: enforce pdiff and pstatus alias in the extension
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 444
diff changeset
501
305
0b444d7c5c96 update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 304
diff changeset
502 def _precursors(repo, s):
0b444d7c5c96 update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 304
diff changeset
503 """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
504 cs = set()
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
505 nm = repo.changelog.nodemap
334
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 332
diff changeset
506 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
507 for r in s:
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
508 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
509 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
510 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
511 cs.add(pr)
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
512 return cs
0599fb01dc41 add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 135
diff changeset
513
305
0b444d7c5c96 update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 304
diff changeset
514 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
515 """transitive precursors of a subset"""
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
516 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
517 seen = set()
334
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 332
diff changeset
518 allsubjects = repo.obsstore.successors
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
519 while toproceed:
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
520 nc = toproceed.pop()
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
521 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
522 np = mark[0]
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
523 if np not in seen:
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
524 seen.add(np)
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
525 toproceed.append(np)
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
526 nm = repo.changelog.nodemap
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
527 cs = set()
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
528 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
529 pr = nm.get(p)
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
530 if pr is not None:
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
531 cs.add(pr)
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
532 return cs
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
533
306
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
534 def _successors(repo, s):
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
535 """Successors of a changeset"""
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
536 cs = set()
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
537 nm = repo.changelog.nodemap
334
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 332
diff changeset
538 markerbyobj = repo.obsstore.precursors
306
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
539 for r in s:
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
540 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
541 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
542 sr = nm.get(sub)
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
543 if sr is not None:
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
544 cs.add(sr)
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
545 return cs
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
546
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
547 def _allsuccessors(repo, s): # XXX we need a better naming
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
548 """transitive successors of a subset"""
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
549 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
550 seen = set()
334
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 332
diff changeset
551 allobjects = repo.obsstore.precursors
306
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
552 while toproceed:
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
553 nc = toproceed.pop()
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
554 for mark in allobjects.get(nc, ()):
334
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 332
diff changeset
555 for sub in mark[1]:
306
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
556 if sub not in seen:
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
557 seen.add(sub)
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
558 toproceed.append(sub)
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
559 nm = repo.changelog.nodemap
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
560 cs = set()
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
561 for s in seen:
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
562 sr = nm.get(s)
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
563 if sr is not None:
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
564 cs.add(sr)
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
565 return cs
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
566
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
567
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
568 ### diagnostique tools
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
569
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
570 def unstables(repo):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
571 """Return all unstable changeset"""
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
572 return scmutil.revrange(repo, ['obsolete():: and (not obsolete())'])
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
573
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
574 def newerversion(repo, obs):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
575 """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
576 toproceed = set([(obs,)])
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
577 # XXX known optimization available
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
578 newer = set()
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
579 objectrels = repo.obsstore.precursors
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
580 while toproceed:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
581 current = toproceed.pop()
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
582 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
583 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
584 if current:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
585 n, = current
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
586 if n in objectrels:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
587 markers = objectrels[n]
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
588 for mark in markers:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
589 toproceed.add(tuple(mark[1]))
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
590 else:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
591 newer.add(tuple(current))
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
592 else:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
593 newer.add(())
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
594 return sorted(newer)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
595
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
596 def createmarkers(repo, relations, metadata=None, flag=0):
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
597 """Add obsolete markers between changeset in a repo
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
598
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
599 <relations> must be an iterable of (<old>, (<new>, ...)) tuple.
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
600 `old` and `news` are changectx.
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
601
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
602 Current user and date are used except if specified otherwise in the
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
603 metadata attribute.
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
604
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
605 /!\ assume the repo have been locked byt the user /!\
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
606 """
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
607 # prepare metadata
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
608 if metadata is None:
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
609 metadata = {}
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
610 if 'date' not in metadata:
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
611 metadata['date'] = '%i %i' % util.makedate()
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
612 if 'user' not in metadata:
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
613 metadata['user'] = repo.ui.username()
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
614 # check future marker
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
615 tr = repo.transaction('add-obsolescence-marker')
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
616 try:
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
617 for prec, sucs in relations:
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
618 if not prec.mutable():
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
619 raise util.Abort("Cannot obsolete immutable changeset: %s" % prec)
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
620 nprec = prec.node()
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
621 nsucs = tuple(s.node() for s in sucs)
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
622 if nprec in nsucs:
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
623 raise util.Abort("Changeset %s cannot obsolete himself" % prec)
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
624 repo.obsstore.create(tr, nprec, nsucs, flag, metadata)
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
625 clearobscaches(repo)
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
626 tr.close()
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
627 finally:
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
628 tr.release()
48d18ba05480 obsolete: extract high level marker creation in a dedicated util function
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 441
diff changeset
629
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
630 #####################################################################
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
631 ### Extending revset and template ###
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
632 #####################################################################
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
633
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
634 @eh.revset('hidden')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
635 def revsethidden(repo, subset, x):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
636 """``hidden()``
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
637 Changeset is hidden.
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
638 """
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
639 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
640 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
641
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
642 ## troubles
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
643
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
644 @eh.revset('suspended')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
645 def revsetsuspended(repo, subset, x):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
646 """``suspended()``
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
647 Obsolete changesets with non-obsolete descendants.
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
648 """
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
649 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
650 suspended = getobscache(repo, 'suspended')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
651 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
652
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
653 @eh.revset('latecomer')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
654 def revsetlatecomer(repo, subset, x):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
655 """``latecomer()``
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
656 Changesets marked as successors of public changesets.
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
657 """
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
658 args = revset.getargs(x, 0, 0, 'latecomer takes no arguments')
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
659 lates = getobscache(repo, 'latecomer')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
660 return [r for r in subset if r in lates]
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
661
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
662 @eh.revset('conflicting')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
663 def revsetconflicting(repo, subset, x):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
664 """``conflicting()``
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
665 Changesets marked as successors of a same changeset.
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
666 """
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
667 args = revset.getargs(x, 0, 0, 'conflicting takes no arguments')
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
668 conf = getobscache(repo, 'conflicting')
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
669 return [r for r in subset if r in conf]
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
670
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
671
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
672 @eh.revset('precursors')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
673 def revsetprecursors(repo, subset, x):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
674 """``precursors(set)``
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
675 Immediate precursors of changesets in set.
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
676 """
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
677 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
678 cs = _precursors(repo, s)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
679 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
680
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
681
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
682 @eh.revset('allprecursors')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
683 def revsetallprecursors(repo, subset, x):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
684 """``allprecursors(set)``
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
685 Transitive precursors of changesets in set.
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
686 """
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
687 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
688 cs = _allprecursors(repo, s)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
689 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
690
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
691
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
692 @eh.revset('successors')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
693 def revsetsuccessors(repo, subset, x):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
694 """``successors(set)``
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
695 Immediate successors of changesets in set.
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
696 """
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
697 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
698 cs = _successors(repo, s)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
699 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
700
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
701 @eh.revset('allsuccessors')
306
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
702 def revsetallsuccessors(repo, subset, x):
397
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
703 """``allsuccessors(set)``
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
704 Transitive successors of changesets in set.
0bd63f294a6f obsolete: improve revset online help
Patrick Mezard <patrick@mezard.eu>
parents: 393
diff changeset
705 """
306
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
706 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
707 cs = _allsuccessors(repo, s)
8cfa3163dfaa obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 305
diff changeset
708 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
709
299
eda6491ca269 obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
710 ### template keywords
eda6491ca269 obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
711
431
bd05022c7856 obsolete: add and use templatekw decorator
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 430
diff changeset
712 @eh.templatekw('obsolete')
299
eda6491ca269 obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
713 def obsoletekw(repo, ctx, templ, **args):
eda6491ca269 obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
714 """:obsolete: String. The obsolescence level of the node, could be
eda6491ca269 obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
715 ``stable``, ``unstable``, ``suspended`` or ``extinct``.
eda6491ca269 obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
716 """
eda6491ca269 obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
717 rev = ctx.rev()
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
718 if ctx.obsolete():
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
719 if ctx.extinct():
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
720 return 'extinct'
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
721 else:
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
722 return 'suspended'
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
723 elif ctx.unstable():
299
eda6491ca269 obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
724 return 'unstable'
eda6491ca269 obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents: 298
diff changeset
725 return 'stable'
144
f387658d6d22 Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 143
diff changeset
726
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
727 #####################################################################
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
728 ### Various trouble warning ###
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
729 #####################################################################
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
730
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
731
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
732
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
733 @eh.wrapcommand("update")
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
734 @eh.wrapcommand("pull")
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
735 def wrapmayobsoletewc(origfn, ui, repo, *args, **opts):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
736 res = origfn(ui, repo, *args, **opts)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
737 if repo['.'].obsolete():
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
738 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
739 return res
71
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
740
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
741 @eh.wrapcommand("commit")
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
742 @eh.wrapcommand("push")
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
743 @eh.wrapcommand("pull")
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
744 @eh.wrapcommand("graft")
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
745 @eh.wrapcommand("phase")
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
746 @eh.wrapcommand("unbundle")
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
747 def warnobserrors(orig, ui, repo, *args, **kwargs):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
748 """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
749 priorunstables = len(repo.revs('unstable()'))
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
750 priorlatecomers = len(repo.revs('latecomer()'))
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
751 priorconflictings = len(repo.revs('conflicting()'))
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
752 #print orig, priorunstables
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
753 #print len(repo.revs('secret() - obsolete()'))
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
754 try:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
755 return orig(ui, repo, *args, **kwargs)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
756 finally:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
757 newunstables = len(repo.revs('unstable()')) - priorunstables
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
758 newlatecomers = len(repo.revs('latecomer()')) - priorlatecomers
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
759 newconflictings = len(repo.revs('conflicting()')) - priorconflictings
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
760 #print orig, newunstables
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
761 #print len(repo.revs('secret() - obsolete()'))
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
762 if newunstables > 0:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
763 ui.warn(_('%i new unstables changesets\n') % newunstables)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
764 if newlatecomers > 0:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
765 ui.warn(_('%i new latecomers changesets\n') % newlatecomers)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
766 if newconflictings > 0:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
767 ui.warn(_('%i new conflictings changesets\n') % newconflictings)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
768
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
769 @eh.reposetup
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
770 def _repostabilizesetup(ui, repo):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
771 if not repo.local():
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
772 return
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
773
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
774 opush = repo.push
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
775
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
776 class stabilizerrepo(repo.__class__):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
777 def push(self, remote, *args, **opts):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
778 """wrapper around pull that pull obsolete relation"""
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
779 try:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
780 result = opush(remote, *args, **opts)
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
781 except util.Abort, ex:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
782 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
783 "or --force to ignore warnings")
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
784 if (len(ex.args) >= 1
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
785 and ex.args[0].startswith('push includes ')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
786 and ex.hint is None):
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
787 ex.hint = hint
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
788 raise
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
789 return result
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
790 repo.__class__ = stabilizerrepo
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
791
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
792 #####################################################################
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
793 ### Other extension compat ###
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
794 #####################################################################
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 ### commit --amend
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 @eh.wrapfunction(cmdutil, 'amend')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
799 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
800 oldnode = old.node()
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
801 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
802 if new != oldnode:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
803 lock = repo.lock()
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
804 try:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
805 tr = repo.transaction('post-amend-obst')
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
806 try:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
807 meta = {
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
808 'date': '%i %i' % util.makedate(),
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
809 'user': ui.username(),
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
810 }
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
811 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
812 tr.close()
447
fa85e7205e0b obsolete: move caches on obsstore
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 446
diff changeset
813 clearobscaches(repo)
437
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
814 finally:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
815 tr.release()
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
816 finally:
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
817 lock.release()
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
818 return new
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
819
48ac58354b7b obsolete: sort all code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 436
diff changeset
820 ### rebase
150
f12fd2410a60 obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 148
diff changeset
821
253
8ee6c5b98d73 [obsolete] fix new api: be more flexible on rebase's buildstate signature
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 252
diff changeset
822 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
823 """wrapper for rebase 's buildstate that exclude obsolete changeset"""
f12fd2410a60 obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 148
diff changeset
824 rebaseset = repo.revs('%ld - extinct()', rebaseset)
253
8ee6c5b98d73 [obsolete] fix new api: be more flexible on rebase's buildstate signature
Alain Leufroy <alain.leufroy@logilab.fr>
parents: 252
diff changeset
825 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
826
282
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
827 def defineparents(orig, repo, rev, target, state, *args, **kwargs):
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
828 rebasestate = getattr(repo, '_rebasestate', None)
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
829 if rebasestate is not None:
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
830 repo._rebasestate = dict(state)
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
831 repo._rebasetarget = target
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
832 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
833
282
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
834 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
835 """wrapper for rebase 's concludenode that set obsolete relation"""
282
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
836 newrev = orig(repo, rev, p1, *args, **kwargs)
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
837 rebasestate = getattr(repo, '_rebasestate', None)
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
838 if rebasestate is not None:
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
839 if newrev is not None:
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
840 nrev = repo[newrev].rev()
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
841 else:
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
842 nrev = p1
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
843 repo._rebasestate[rev] = nrev
71
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
844 return newrev
19e1930587a0 [obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 70
diff changeset
845
274
6622a24f3b0f obsolete: fix rebase wrapping
Patrick Mezard <patrick@mezard.eu>
parents: 273
diff changeset
846 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
847
5eecfda0a5c7 obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 310
diff changeset
848 reallykeep = kwargs.get('keep', False)
275
336210dada95 obsolete: make rebase abort with --keep
Patrick Mezard <patrick@mezard.eu>
parents: 274
diff changeset
849 kwargs = dict(kwargs)
84
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
850 kwargs['keep'] = True
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
851
282
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
852 # 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
853 # replacements if any. Doing it in concludenode() prevents
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
854 # aborting the rebase, and is not called with all relevant
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
855 # revisions in --collapse case. Instead, we try to track the
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
856 # rebase state structure by sampling/updating it in
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
857 # defineparents() and concludenode(). The obsolete markers are
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
858 # added from this state after a successful call.
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
859 repo._rebasestate = {}
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
860 repo._rebasetarget = None
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
861 try:
443
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
862 l = repo.lock()
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
863 try:
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
864 res = orig(ui, repo, *args, **kwargs)
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
865 if not reallykeep:
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
866 # Filter nullmerge or unrebased entries
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
867 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
868 if p[1] >= 0)
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
869 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
870 # 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
871 # 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
872 # 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
873 # removed.
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
874 targetrev = repo[repo._rebasetarget].rev()
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
875 newrevs = set([targetrev])
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
876 replacements = {}
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
877 for rev, newrev in sorted(repo._rebasestate.items()):
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
878 oldnode = repo[rev].node()
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
879 if newrev not in newrevs:
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
880 newnode = repo[newrev].node()
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
881 newrevs.add(newrev)
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
882 else:
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
883 newnode = nullid
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
884 replacements[oldnode] = newnode
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
885
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
886 if kwargs.get('collapse'):
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
887 newnodes = set(n for n in replacements.values() if n != nullid)
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
888 if newnodes:
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
889 # Collapsing into more than one revision?
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
890 assert len(newnodes) == 1, newnodes
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
891 newnode = newnodes.pop()
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
892 markers = [(repo[r], (repo[newnode],))
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
893 for r in replacements]
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
894 else:
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
895 newnode = nullid
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
896 markers = [(repo[r], ())
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
897 for r in replacements]
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
898 createmarkers(repo, markers)
444
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
899 elif replacements:
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
900 markers = [(repo[o], (() if n == nullid else (repo[n],)))
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
901 for o, n in replacements.iteritems()]
aedb6b8ace86 drop repo.addobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 443
diff changeset
902 createmarkers(repo, markers)
443
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
903 return res
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
904 finally:
3f8c11865ed2 obsolete: remove usage of addcollapsedobsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 442
diff changeset
905 l.release()
282
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
906 finally:
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
907 delattr(repo, '_rebasestate')
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
908 delattr(repo, '_rebasetarget')
84
c4cc5f3bcf12 [obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 83
diff changeset
909
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
910 @eh.extsetup
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
911 def _rebasewrapping(ui):
356
56d4c6207ef9 Move obserror warning into the obsolete extension.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 354
diff changeset
912 # warning about more obsolete
42
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
913 try:
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
914 rebase = extensions.find('rebase')
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
915 if rebase:
356
56d4c6207ef9 Move obserror warning into the obsolete extension.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 354
diff changeset
916 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
917 extensions.wrapfunction(rebase, 'buildstate', buildstate)
282
05ab164c6593 obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents: 279
diff changeset
918 extensions.wrapfunction(rebase, 'defineparents', defineparents)
42
eb6a06d7eae3 Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 41
diff changeset
919 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
920 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
921 except KeyError:
305
0b444d7c5c96 update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 304
diff changeset
922 pass # rebase not found
39
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 38
diff changeset
923
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
924
430
07db1d511faf obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 429
diff changeset
925 #####################################################################
07db1d511faf obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 429
diff changeset
926 ### Older format management ###
07db1d511faf obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 429
diff changeset
927 #####################################################################
07db1d511faf obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 429
diff changeset
928
07db1d511faf obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 429
diff changeset
929 # 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
930 # handled by core
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
931
439
6cff54825233 obsolete: reorder import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 438
diff changeset
932 import json
6cff54825233 obsolete: reorder import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 438
diff changeset
933
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
934 @eh.reposetup
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
935 def _checkoldobsolete(ui, repo):
430
07db1d511faf obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 429
diff changeset
936 """Detect that a repo still carry some old obsolete format
07db1d511faf obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 429
diff changeset
937 """
429
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
938 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
939 return
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
940 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
941 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
942 break
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
943 else:
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
944 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
945 if not data:
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
946 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
947 if data:
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
948 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
949 'run `hg debugconvertobsolete` once.')
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
950
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
951 def _obsdeserialise(flike):
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
952 """read a file like object serialised with _obsserialise
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
953
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
954 this desierialize into a {subject -> objects} mapping"""
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
955 rels = {}
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
956 for line in flike:
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
957 subhex, objhex = line.split()
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
958 subnode = bin(subhex)
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
959 if subnode == nullid:
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
960 subnode = None
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
961 rels.setdefault( subnode, set()).add(bin(objhex))
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
962 return rels
079b231b8ea4 obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 428
diff changeset
963
441
d702f0d26c6a obsolete: remove debugsuccessors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 440
diff changeset
964 cmdtable = {}
d702f0d26c6a obsolete: remove debugsuccessors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 440
diff changeset
965 command = cmdutil.command(cmdtable)
276
f26e9bc5f7fc obsolete: use new-style command registration
Patrick Mezard <patrick@mezard.eu>
parents: 275
diff changeset
966 @command('debugconvertobsolete', [], '')
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
967 def cmddebugconvertobsolete(ui, repo):
278
fa0b9b8a83c0 obsolete: add or fix debug commands help
Patrick Mezard <patrick@mezard.eu>
parents: 277
diff changeset
968 """import markers from an .hg/obsolete-relations file"""
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
969 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
970 err = 0
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
971 l = repo.lock()
334
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 332
diff changeset
972 some = False
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
973 try:
361
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
974 unlink = []
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
975 tr = repo.transaction('convert-obsolete')
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
976 try:
361
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
977 repo._importoldobsolete = True
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
978 store = repo.obsstore
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
979 ### very first format
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
980 try:
361
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
981 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
982 try:
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
983 some = True
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
984 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
985 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
986 suc = bin(subhex)
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
987 prec = bin(objhex)
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
988 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
989 meta = {
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
990 '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
991 'user': ui.username(),
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
992 }
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
993 try:
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
994 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
995 cnt += 1
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
996 except ValueError:
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
997 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
998 % (line))
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
999 err += 1
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1000 finally:
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1001 f.close()
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1002 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
1003 except IOError:
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1004 pass
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1005 ### second (json) format
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1006 data = repo.sopener.tryread('obsoletemarkers')
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1007 if data:
334
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 332
diff changeset
1008 some = True
361
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1009 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
1010 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
1011 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
1012 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
1013 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
1014 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
1015 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
1016 try:
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1017 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
1018 except LOOKUP_ERRORS:
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1019 pass
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1020 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
1021 try:
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1022 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
1023 except LOOKUP_ERRORS:
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1024 pass
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1025
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1026 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
1027 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
1028 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
1029 try:
361
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1030 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
1031 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
1032 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
1033 0, meta)
341
7653f80fd7a4 obsolete: harden convertion from first format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 340
diff changeset
1034 cnt += 1
7653f80fd7a4 obsolete: harden convertion from first format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 340
diff changeset
1035 except ValueError:
361
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1036 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
1037 % (oldobject, oldsubjects))
341
7653f80fd7a4 obsolete: harden convertion from first format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 340
diff changeset
1038 err += 1
361
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1039 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
1040 tr.close()
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1041 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
1042 util.unlink(path)
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1043 finally:
ac7969043677 obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents: 360
diff changeset
1044 tr.release()
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
1045 finally:
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
1046 del repo._importoldobsolete
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
1047 l.release()
334
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 332
diff changeset
1048 if not some:
fb83210bce32 obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents: 332
diff changeset
1049 ui.warn('nothing to do\n')
224
f60555898df4 new obsolete store
Pierre-Yves.David@ens-lyon.org
parents: 218
diff changeset
1050 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
1051 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
1052 ui.write_err('%i conversion failed. check you graph!\n' % err)