author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
Tue, 03 Jul 2012 14:18:33 +0200 | |
changeset 342 | aab826129142 |
parent 334 | fb83210bce32 |
child 335 | c27a465daef2 |
child 343 | 6b92f8d5ae58 |
permissions | -rw-r--r-- |
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 |
Display and Exchange |
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
35 |
-------------------- |
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
36 |
|
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
37 |
obsolete changesets are hidden. (except if they have non obsolete changeset) |
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
38 |
|
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
39 |
obsolete changesets are not exchanged. This will probably change later but it |
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
40 |
was the simpler solution for now. |
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
41 |
|
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
42 |
New commands |
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
43 |
------------ |
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
44 |
|
275
336210dada95
obsolete: make rebase abort with --keep
Patrick Mezard <patrick@mezard.eu>
parents:
274
diff
changeset
|
45 |
Note that rebased changesets are not marked obsolete rather than being stripped |
336210dada95
obsolete: make rebase abort with --keep
Patrick Mezard <patrick@mezard.eu>
parents:
274
diff
changeset
|
46 |
In this experimental extensions, this is done forcing the --keep option. Trying |
336210dada95
obsolete: make rebase abort with --keep
Patrick Mezard <patrick@mezard.eu>
parents:
274
diff
changeset
|
47 |
to use the --keep option of rebase with this extensionn this experimental |
336210dada95
obsolete: make rebase abort with --keep
Patrick Mezard <patrick@mezard.eu>
parents:
274
diff
changeset
|
48 |
extension will cause such a call to abort. Until better releasen please use |
336210dada95
obsolete: make rebase abort with --keep
Patrick Mezard <patrick@mezard.eu>
parents:
274
diff
changeset
|
49 |
graft command to rebase and copy changesets. |
336210dada95
obsolete: make rebase abort with --keep
Patrick Mezard <patrick@mezard.eu>
parents:
274
diff
changeset
|
50 |
|
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
51 |
Context object |
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
52 |
-------------- |
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
53 |
|
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
54 |
Context gains a ``obsolete`` method that will return True if a changeset is |
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
55 |
obsolete False otherwise. |
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
56 |
|
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
57 |
revset |
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
58 |
------ |
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
59 |
|
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
60 |
Add an ``obsolete()`` entry. |
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
61 |
|
70
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
62 |
repo extension |
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
63 |
-------------- |
70
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
64 |
|
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
65 |
To Do |
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
66 |
~~~~~ |
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
67 |
|
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
68 |
- refuse to obsolete published changesets |
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
69 |
|
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
70 |
- handle split |
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
71 |
|
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
72 |
- handle conflict |
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
73 |
|
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
74 |
- handle unstable // out of sync |
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
75 |
|
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
76 |
""" |
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
77 |
|
52
62bdc2567099
Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
51
diff
changeset
|
78 |
import os |
54
ad1a4fb0fc49
Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
53
diff
changeset
|
79 |
try: |
ad1a4fb0fc49
Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
53
diff
changeset
|
80 |
from cStringIO import StringIO |
ad1a4fb0fc49
Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
53
diff
changeset
|
81 |
except ImportError: |
ad1a4fb0fc49
Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
53
diff
changeset
|
82 |
from StringIO import StringIO |
ad1a4fb0fc49
Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
53
diff
changeset
|
83 |
|
75
d7b11772f0b5
[obsolete] published changeset can't be obsoleted
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
74
diff
changeset
|
84 |
from mercurial.i18n import _ |
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
85 |
|
89
757153438e58
[obsolet] base64 encore obsolete rel for pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
86 |
import base64 |
224 | 87 |
import json |
89
757153438e58
[obsolet] base64 encore obsolete rel for pushkey
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
87
diff
changeset
|
88 |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
89 |
import struct |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
90 |
from mercurial import util, base85 |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
91 |
|
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
92 |
_pack = struct.pack |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
93 |
_unpack = struct.unpack |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
94 |
|
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
95 |
from mercurial import util |
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
96 |
from mercurial import context |
39 | 97 |
from mercurial import revset |
40
b9a5a596d9ef
proper computation of hidden changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
39
diff
changeset
|
98 |
from mercurial import scmutil |
42
eb6a06d7eae3
Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
41
diff
changeset
|
99 |
from mercurial import extensions |
44
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
100 |
from mercurial import pushkey |
46
3b0364fc822f
Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
44
diff
changeset
|
101 |
from mercurial import discovery |
3b0364fc822f
Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
44
diff
changeset
|
102 |
from mercurial import error |
79
9906560f585e
[obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
75
diff
changeset
|
103 |
from mercurial import commands |
114
1a64195e2b09
nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
112
diff
changeset
|
104 |
from mercurial import changelog |
115
d60eddda9546
add an option to ensure unstable are secret
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
114
diff
changeset
|
105 |
from mercurial import phases |
80
5d029a358252
[obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
79
diff
changeset
|
106 |
from mercurial.node import hex, bin, short, nullid |
52
62bdc2567099
Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
51
diff
changeset
|
107 |
from mercurial.lock import release |
252
470232cea503
[obsolete] fix new api: use the new phase cache api
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
228
diff
changeset
|
108 |
from mercurial import localrepo |
276
f26e9bc5f7fc
obsolete: use new-style command registration
Patrick Mezard <patrick@mezard.eu>
parents:
275
diff
changeset
|
109 |
from mercurial import cmdutil |
299
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
110 |
from mercurial import templatekw |
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
111 |
|
160
24346b78cd99
mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
150
diff
changeset
|
112 |
try: |
24346b78cd99
mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
150
diff
changeset
|
113 |
from mercurial.localrepo import storecache |
24346b78cd99
mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
150
diff
changeset
|
114 |
storecache('babar') # to trigger import |
197
c2d692c8f599
stronger try except for store cache
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
160
diff
changeset
|
115 |
except (TypeError, ImportError): |
160
24346b78cd99
mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
150
diff
changeset
|
116 |
def storecache(*args): |
24346b78cd99
mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
150
diff
changeset
|
117 |
return scmutil.filecache(*args, instore=True) |
24346b78cd99
mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
150
diff
changeset
|
118 |
|
24346b78cd99
mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
150
diff
changeset
|
119 |
|
72
774932a6cc0d
[obsolete] rationalize doc header.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
71
diff
changeset
|
120 |
### Patch changectx |
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
121 |
############################# |
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
122 |
|
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
123 |
def obsolete(ctx): |
37
9493ffa68633
Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
32
diff
changeset
|
124 |
"""is the changeset obsolete by other""" |
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
125 |
if ctx.node()is None: |
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
126 |
return False |
112
eae9be0ee00e
adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
109
diff
changeset
|
127 |
return bool(ctx._repo.obsoletedby(ctx.node())) and ctx.phase() |
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
128 |
|
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
129 |
context.changectx.obsolete = obsolete |
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
130 |
|
148
8e93e1f67205
obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
144
diff
changeset
|
131 |
def unstable(ctx): |
8e93e1f67205
obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
144
diff
changeset
|
132 |
"""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
|
133 |
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
|
134 |
return False |
8e93e1f67205
obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
144
diff
changeset
|
135 |
return ctx.rev() in ctx._repo._unstableset |
8e93e1f67205
obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
144
diff
changeset
|
136 |
|
8e93e1f67205
obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
144
diff
changeset
|
137 |
context.changectx.unstable = unstable |
8e93e1f67205
obsolete: define an unstable property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
144
diff
changeset
|
138 |
|
213
ea4aa1890b16
obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
212
diff
changeset
|
139 |
def extinct(ctx): |
ea4aa1890b16
obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
212
diff
changeset
|
140 |
"""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
|
141 |
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
|
142 |
return False |
ea4aa1890b16
obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
212
diff
changeset
|
143 |
return ctx.rev() in ctx._repo._extinctset |
ea4aa1890b16
obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
212
diff
changeset
|
144 |
|
ea4aa1890b16
obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
212
diff
changeset
|
145 |
context.changectx.extinct = extinct |
ea4aa1890b16
obsolete: add an extinct property on context
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
212
diff
changeset
|
146 |
|
307
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
147 |
def latecomer(ctx): |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
148 |
"""is the changeset latecomer (Try to succeed to public change)""" |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
149 |
if ctx.node() is None: |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
150 |
return False |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
151 |
return ctx.rev() in ctx._repo._latecomerset |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
152 |
|
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
153 |
context.changectx.latecomer = latecomer |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
154 |
|
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
155 |
|
72
774932a6cc0d
[obsolete] rationalize doc header.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
71
diff
changeset
|
156 |
### revset |
39 | 157 |
############################# |
158 |
||
321
41ba89f0caa5
obsolete: add an hidden revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
320
diff
changeset
|
159 |
def revsethidden(repo, subset, x): |
41ba89f0caa5
obsolete: add an hidden revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
320
diff
changeset
|
160 |
"""hidden changesets""" |
41ba89f0caa5
obsolete: add an hidden revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
320
diff
changeset
|
161 |
args = revset.getargs(x, 0, 0, 'hidden takes no argument') |
41ba89f0caa5
obsolete: add an hidden revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
320
diff
changeset
|
162 |
return [r for r in subset if r in repo.changelog.hiddenrevs] |
112
eae9be0ee00e
adapt obsolete to phase.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
109
diff
changeset
|
163 |
|
39 | 164 |
def revsetobsolete(repo, subset, x): |
135
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
165 |
"""obsolete changesets""" |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
166 |
args = revset.getargs(x, 0, 0, 'obsolete takes no argument') |
252
470232cea503
[obsolete] fix new api: use the new phase cache api
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
228
diff
changeset
|
167 |
return [r for r in subset if r in repo._obsoleteset and repo._phasecache.phase(repo, r) > 0] |
470232cea503
[obsolete] fix new api: use the new phase cache api
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
228
diff
changeset
|
168 |
|
470232cea503
[obsolete] fix new api: use the new phase cache api
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
228
diff
changeset
|
169 |
# XXX Backward compatibility, to be removed once stabilized |
470232cea503
[obsolete] fix new api: use the new phase cache api
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
228
diff
changeset
|
170 |
if '_phasecache' not in vars(localrepo.localrepository): # new api |
470232cea503
[obsolete] fix new api: use the new phase cache api
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
228
diff
changeset
|
171 |
def revsetobsolete(repo, subset, x): |
470232cea503
[obsolete] fix new api: use the new phase cache api
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
228
diff
changeset
|
172 |
"""obsolete changesets""" |
470232cea503
[obsolete] fix new api: use the new phase cache api
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
228
diff
changeset
|
173 |
args = revset.getargs(x, 0, 0, 'obsolete takes no argument') |
470232cea503
[obsolete] fix new api: use the new phase cache api
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
228
diff
changeset
|
174 |
return [r for r in subset if r in repo._obsoleteset and repo._phaserev[r] > 0] |
39 | 175 |
|
135
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
176 |
def revsetunstable(repo, subset, x): |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
177 |
"""non obsolete changesets descendant of obsolete one""" |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
178 |
args = revset.getargs(x, 0, 0, 'unstable takes no arguments') |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
179 |
return [r for r in subset if r in repo._unstableset] |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
180 |
|
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
181 |
def revsetsuspended(repo, subset, x): |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
182 |
"""obsolete changesets with non obsolete descendants""" |
310
2d0dc5c18489
[obsolete] fix revset error message
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
308
diff
changeset
|
183 |
args = revset.getargs(x, 0, 0, 'suspended takes no arguments') |
135
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
184 |
return [r for r in subset if r in repo._suspendedset] |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
185 |
|
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
186 |
def revsetextinct(repo, subset, x): |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
187 |
"""obsolete changesets without obsolete descendants""" |
310
2d0dc5c18489
[obsolete] fix revset error message
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
308
diff
changeset
|
188 |
args = revset.getargs(x, 0, 0, 'extinct takes no arguments') |
135
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
189 |
return [r for r in subset if r in repo._extinctset] |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
190 |
|
307
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
191 |
def revsetlatecomer(repo, subset, x): |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
192 |
"""latecomer, Try to succeed to public change""" |
310
2d0dc5c18489
[obsolete] fix revset error message
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
308
diff
changeset
|
193 |
args = revset.getargs(x, 0, 0, 'latecomer takes no arguments') |
307
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
194 |
return [r for r in subset if r in repo._latecomerset] |
143
0599fb01dc41
add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
135
diff
changeset
|
195 |
|
305
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
196 |
def _precursors(repo, s): |
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
197 |
"""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
|
198 |
cs = set() |
0599fb01dc41
add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
135
diff
changeset
|
199 |
nm = repo.changelog.nodemap |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
200 |
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
|
201 |
for r in s: |
224 | 202 |
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
|
203 |
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
|
204 |
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
|
205 |
cs.add(pr) |
0599fb01dc41
add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
135
diff
changeset
|
206 |
return cs |
0599fb01dc41
add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
135
diff
changeset
|
207 |
|
305
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
208 |
def revsetprecursors(repo, subset, x): |
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
209 |
"""precursors of a subset""" |
144
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
210 |
s = revset.getset(repo, range(len(repo)), x) |
305
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
211 |
cs = _precursors(repo, s) |
144
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
212 |
return [r for r in subset if r in cs] |
143
0599fb01dc41
add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
135
diff
changeset
|
213 |
|
305
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
214 |
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
|
215 |
"""transitive precursors of a subset""" |
144
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
216 |
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
|
217 |
seen = set() |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
218 |
allsubjects = repo.obsstore.successors |
144
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
219 |
while toproceed: |
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
220 |
nc = toproceed.pop() |
224 | 221 |
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
|
222 |
np = mark[0] |
144
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
223 |
if np not in seen: |
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
224 |
seen.add(np) |
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
225 |
toproceed.append(np) |
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
226 |
nm = repo.changelog.nodemap |
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
227 |
cs = set() |
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
228 |
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
|
229 |
pr = nm.get(p) |
144
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
230 |
if pr is not None: |
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
231 |
cs.add(pr) |
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
232 |
return cs |
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
233 |
|
305
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
234 |
def revsetallprecursors(repo, subset, x): |
144
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
235 |
"""obsolete parents""" |
143
0599fb01dc41
add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
135
diff
changeset
|
236 |
s = revset.getset(repo, range(len(repo)), x) |
305
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
237 |
cs = _allprecursors(repo, s) |
143
0599fb01dc41
add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
135
diff
changeset
|
238 |
return [r for r in subset if r in cs] |
0599fb01dc41
add an obsolete parent revset and related alias
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
135
diff
changeset
|
239 |
|
306
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
240 |
def _successors(repo, s): |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
241 |
"""Successors of a changeset""" |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
242 |
cs = set() |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
243 |
nm = repo.changelog.nodemap |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
244 |
markerbyobj = repo.obsstore.precursors |
306
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
245 |
for r in s: |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
246 |
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
|
247 |
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
|
248 |
sr = nm.get(sub) |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
249 |
if sr is not None: |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
250 |
cs.add(sr) |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
251 |
return cs |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
252 |
|
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
253 |
def revsetsuccessors(repo, subset, x): |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
254 |
"""successors of a subset""" |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
255 |
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
|
256 |
cs = _successors(repo, s) |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
257 |
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
|
258 |
|
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
259 |
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
|
260 |
"""transitive successors of a subset""" |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
261 |
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
|
262 |
seen = set() |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
263 |
allobjects = repo.obsstore.precursors |
306
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
264 |
while toproceed: |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
265 |
nc = toproceed.pop() |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
266 |
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
|
267 |
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
|
268 |
if sub not in seen: |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
269 |
seen.add(sub) |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
270 |
toproceed.append(sub) |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
271 |
nm = repo.changelog.nodemap |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
272 |
cs = set() |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
273 |
for s in seen: |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
274 |
sr = nm.get(s) |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
275 |
if sr is not None: |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
276 |
cs.add(sr) |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
277 |
return cs |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
278 |
|
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
279 |
def revsetallsuccessors(repo, subset, x): |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
280 |
"""obsolete parents""" |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
281 |
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
|
282 |
cs = _allsuccessors(repo, s) |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
283 |
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
|
284 |
|
144
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
285 |
|
299
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
286 |
### template keywords |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
287 |
##################### |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
288 |
|
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
289 |
def obsoletekw(repo, ctx, templ, **args): |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
290 |
""":obsolete: String. The obsolescence level of the node, could be |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
291 |
``stable``, ``unstable``, ``suspended`` or ``extinct``. |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
292 |
""" |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
293 |
rev = ctx.rev() |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
294 |
if rev in repo._extinctset: |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
295 |
return 'extinct' |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
296 |
if rev in repo._suspendedset: |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
297 |
return 'suspended' |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
298 |
if rev in repo._unstableset: |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
299 |
return 'unstable' |
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
300 |
return 'stable' |
144
f387658d6d22
Add a bosancestors revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
143
diff
changeset
|
301 |
|
71
19e1930587a0
[obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
70
diff
changeset
|
302 |
### Other Extension compat |
19e1930587a0
[obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
70
diff
changeset
|
303 |
############################ |
19e1930587a0
[obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
70
diff
changeset
|
304 |
|
150
f12fd2410a60
obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
148
diff
changeset
|
305 |
|
253
8ee6c5b98d73
[obsolete] fix new api: be more flexible on rebase's buildstate signature
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
252
diff
changeset
|
306 |
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
|
307 |
"""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
|
308 |
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
|
309 |
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
|
310 |
|
282
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
311 |
def defineparents(orig, repo, rev, target, state, *args, **kwargs): |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
312 |
rebasestate = getattr(repo, '_rebasestate', None) |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
313 |
if rebasestate is not None: |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
314 |
repo._rebasestate = dict(state) |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
315 |
repo._rebasetarget = target |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
316 |
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
|
317 |
|
282
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
318 |
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
|
319 |
"""wrapper for rebase 's concludenode that set obsolete relation""" |
282
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
320 |
newrev = orig(repo, rev, p1, *args, **kwargs) |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
321 |
rebasestate = getattr(repo, '_rebasestate', None) |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
322 |
if rebasestate is not None: |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
323 |
if newrev is not None: |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
324 |
nrev = repo[newrev].rev() |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
325 |
else: |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
326 |
nrev = p1 |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
327 |
repo._rebasestate[rev] = nrev |
71
19e1930587a0
[obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
70
diff
changeset
|
328 |
return newrev |
19e1930587a0
[obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
70
diff
changeset
|
329 |
|
274
6622a24f3b0f
obsolete: fix rebase wrapping
Patrick Mezard <patrick@mezard.eu>
parents:
273
diff
changeset
|
330 |
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
|
331 |
|
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
332 |
reallykeep = kwargs.get('keep', False) |
275
336210dada95
obsolete: make rebase abort with --keep
Patrick Mezard <patrick@mezard.eu>
parents:
274
diff
changeset
|
333 |
kwargs = dict(kwargs) |
84
c4cc5f3bcf12
[obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
83
diff
changeset
|
334 |
kwargs['keep'] = True |
c4cc5f3bcf12
[obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
83
diff
changeset
|
335 |
|
282
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
336 |
# 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
|
337 |
# replacements if any. Doing it in concludenode() prevents |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
338 |
# aborting the rebase, and is not called with all relevant |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
339 |
# revisions in --collapse case. Instead, we try to track the |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
340 |
# rebase state structure by sampling/updating it in |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
341 |
# defineparents() and concludenode(). The obsolete markers are |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
342 |
# added from this state after a successful call. |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
343 |
repo._rebasestate = {} |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
344 |
repo._rebasetarget = None |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
345 |
try: |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
346 |
res = orig(ui, repo, *args, **kwargs) |
311
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
347 |
if not reallykeep: |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
348 |
# Filter nullmerge or unrebased entries |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
349 |
repo._rebasestate = dict(p for p in repo._rebasestate.iteritems() |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
350 |
if p[1] >= 0) |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
351 |
if not res and not kwargs.get('abort') and repo._rebasestate: |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
352 |
# Rebased revisions are assumed to be descendants of |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
353 |
# targetrev. If a source revision is mapped to targetrev |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
354 |
# or to another rebased revision, it must have been |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
355 |
# removed. |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
356 |
targetrev = repo[repo._rebasetarget].rev() |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
357 |
newrevs = set([targetrev]) |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
358 |
replacements = {} |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
359 |
for rev, newrev in sorted(repo._rebasestate.items()): |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
360 |
oldnode = repo[rev].node() |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
361 |
if newrev not in newrevs: |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
362 |
newnode = repo[newrev].node() |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
363 |
newrevs.add(newrev) |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
364 |
else: |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
365 |
newnode = nullid |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
366 |
replacements[oldnode] = newnode |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
367 |
|
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
368 |
if kwargs.get('collapse'): |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
369 |
newnodes = set(n for n in replacements.values() if n != nullid) |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
370 |
if newnodes: |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
371 |
# Collapsing into more than one revision? |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
372 |
assert len(newnodes) == 1, newnodes |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
373 |
newnode = newnodes.pop() |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
374 |
else: |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
375 |
newnode = nullid |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
376 |
repo.addcollapsedobsolete(replacements, newnode) |
282
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
377 |
else: |
311
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
378 |
for oldnode, newnode in replacements.iteritems(): |
5eecfda0a5c7
obsolete: enable rebase --keep again
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
310
diff
changeset
|
379 |
repo.addobsolete(newnode, oldnode) |
282
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
380 |
return res |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
381 |
finally: |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
382 |
delattr(repo, '_rebasestate') |
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
383 |
delattr(repo, '_rebasetarget') |
84
c4cc5f3bcf12
[obsolete] rebase always keep changeset.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
83
diff
changeset
|
384 |
|
71
19e1930587a0
[obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
70
diff
changeset
|
385 |
|
39 | 386 |
def extsetup(ui): |
75
d7b11772f0b5
[obsolete] published changeset can't be obsoleted
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
74
diff
changeset
|
387 |
|
321
41ba89f0caa5
obsolete: add an hidden revset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
320
diff
changeset
|
388 |
revset.symbols["hidden"] = revsethidden |
39 | 389 |
revset.symbols["obsolete"] = revsetobsolete |
135
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
390 |
revset.symbols["unstable"] = revsetunstable |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
391 |
revset.symbols["suspended"] = revsetsuspended |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
392 |
revset.symbols["extinct"] = revsetextinct |
307
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
393 |
revset.symbols["latecomer"] = revsetlatecomer |
305
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
394 |
revset.symbols["obsparents"] = revsetprecursors # DEPR |
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
395 |
revset.symbols["precursors"] = revsetprecursors |
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
396 |
revset.symbols["obsancestors"] = revsetallprecursors # DEPR |
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
397 |
revset.symbols["allprecursors"] = revsetallprecursors # bad name |
306
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
398 |
revset.symbols["successors"] = revsetsuccessors |
8cfa3163dfaa
obsolete: add precursors and successors revset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
305
diff
changeset
|
399 |
revset.symbols["allsuccessors"] = revsetallsuccessors # bad name |
46
3b0364fc822f
Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
44
diff
changeset
|
400 |
|
299
eda6491ca269
obsolete: add 'obsolete' keyword
Patrick Mezard <patrick@mezard.eu>
parents:
298
diff
changeset
|
401 |
templatekw.keywords['obsolete'] = obsoletekw |
46
3b0364fc822f
Do not propagate obsolete changeset
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
44
diff
changeset
|
402 |
|
42
eb6a06d7eae3
Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
41
diff
changeset
|
403 |
try: |
eb6a06d7eae3
Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
41
diff
changeset
|
404 |
rebase = extensions.find('rebase') |
eb6a06d7eae3
Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
41
diff
changeset
|
405 |
if rebase: |
150
f12fd2410a60
obsolete: improve rebase compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
148
diff
changeset
|
406 |
extensions.wrapfunction(rebase, 'buildstate', buildstate) |
282
05ab164c6593
obsolete: handle rebase --collapse
Patrick Mezard <patrick@mezard.eu>
parents:
279
diff
changeset
|
407 |
extensions.wrapfunction(rebase, 'defineparents', defineparents) |
42
eb6a06d7eae3
Make rebase set-obsolete relation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
41
diff
changeset
|
408 |
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
|
409 |
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
|
410 |
except KeyError: |
305
0b444d7c5c96
update revset vocabulary to use precursors, successors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
304
diff
changeset
|
411 |
pass # rebase not found |
39 | 412 |
|
44
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
413 |
# Pushkey mechanism for mutable |
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
414 |
######################################### |
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
415 |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
416 |
def listmarkers(repo): |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
417 |
"""List markers over pushkey""" |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
418 |
if not repo.obsstore: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
419 |
return {} |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
420 |
data = repo.obsstore._writemarkers() |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
421 |
return {'dump': base85.b85encode(data)} |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
422 |
|
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
423 |
def pushmarker(repo, key, old, new): |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
424 |
"""Push markers over pushkey""" |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
425 |
if key != 'dump': |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
426 |
repo.ui.warn(_('unknown key: %r') % key) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
427 |
return 0 |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
428 |
if old: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
429 |
repo.ui.warn(_('unexpected old value') % key) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
430 |
return 0 |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
431 |
data = base85.b85decode(new) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
432 |
lock = repo.lock() |
44
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
433 |
try: |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
434 |
repo.obsstore.mergemarkers(data) |
224 | 435 |
return 1 |
44
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
436 |
finally: |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
437 |
lock.release() |
74
c7dd26dec7fc
[obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
73
diff
changeset
|
438 |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
439 |
pushkey.register('obsolete', pushmarker, listmarkers) |
44
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
440 |
|
214
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
441 |
### Discovery wrapping |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
442 |
############################# |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
443 |
|
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
444 |
class blist(list, object): |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
445 |
"""silly class to have non False but empty list""" |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
446 |
|
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
447 |
def __nonzero__(self): |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
448 |
return bool(len(self.orig)) |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
449 |
|
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
450 |
def wrapfindcommonoutgoing(orig, repo, *args, **kwargs): |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
451 |
"""wrap mercurial.discovery.findcommonoutgoing to remove extinct changeset |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
452 |
|
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
453 |
Such excluded changeset are removed from excluded and will *not* appear |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
454 |
are excluded secret changeset. |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
455 |
""" |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
456 |
outgoing = orig(repo, *args, **kwargs) |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
457 |
orig = outgoing.excluded |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
458 |
outgoing.excluded = blist(n for n in orig if not repo[n].extinct()) |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
459 |
# when no revision is specified (push everything) a shortcut is taken when |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
460 |
# nothign was exclude. taking this code path when extinct changeset have |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
461 |
# been excluded leads to repository corruption. |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
462 |
outgoing.excluded.orig = orig |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
463 |
return outgoing |
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
464 |
|
217
786eb34d93ea
obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
215
diff
changeset
|
465 |
def wrapcheckheads(orig, repo, remote, outgoing, *args, **kwargs): |
218
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
466 |
"""wrap mercurial.discovery.checkheads |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
467 |
|
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
468 |
* prevent unstability to be pushed |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
469 |
* patch remote to ignore obsolete heads on remote |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
470 |
""" |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
471 |
# do not push instability |
217
786eb34d93ea
obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
215
diff
changeset
|
472 |
for h in outgoing.missingheads: |
786eb34d93ea
obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
215
diff
changeset
|
473 |
# checking heads only is enought because any thing base on obsolete |
786eb34d93ea
obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
215
diff
changeset
|
474 |
# changeset is either obsolete or unstable. |
786eb34d93ea
obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
215
diff
changeset
|
475 |
ctx = repo[h] |
786eb34d93ea
obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
215
diff
changeset
|
476 |
hint = _("use 'hg stabilize' to get a stable history (or --force to proceed)") |
786eb34d93ea
obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
215
diff
changeset
|
477 |
if ctx.unstable(): |
786eb34d93ea
obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
215
diff
changeset
|
478 |
raise util.Abort(_("Trying to push unstable changeset: %s!") % ctx, |
786eb34d93ea
obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
215
diff
changeset
|
479 |
hint=hint) |
786eb34d93ea
obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
215
diff
changeset
|
480 |
if ctx.obsolete(): |
786eb34d93ea
obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
215
diff
changeset
|
481 |
raise util.Abort(_("Trying to push obsolete changeset: %s!") % ctx, |
786eb34d93ea
obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
215
diff
changeset
|
482 |
hint=hint) |
308
23ef1c71d164
obsolete: detect late comer during push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
307
diff
changeset
|
483 |
if ctx.latecomer(): |
23ef1c71d164
obsolete: detect late comer during push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
307
diff
changeset
|
484 |
raise util.Abort(_("Trying to push latecomer changeset: %s!") % ctx, |
23ef1c71d164
obsolete: detect late comer during push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
307
diff
changeset
|
485 |
hint=hint) |
218
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
486 |
### patch remote branch map |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
487 |
# do not read it this burn eyes |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
488 |
try: |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
489 |
if 'oldbranchmap' not in vars(remote): |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
490 |
remote.oldbranchmap = remote.branchmap |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
491 |
def branchmap(): |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
492 |
newbm = {} |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
493 |
oldbm = None |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
494 |
if (util.safehasattr(phases, 'visiblebranchmap') |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
495 |
and not util.safehasattr(remote, 'ignorevisiblebranchmap') |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
496 |
): |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
497 |
remote.ignorevisiblebranchmap = False |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
498 |
remote.branchmap = remote.oldbranchmap |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
499 |
oldbm = phases.visiblebranchmap(remote) |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
500 |
remote.branchmap = remote.newbranchmap |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
501 |
remote.ignorevisiblebranchmap = True |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
502 |
if oldbm is None: |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
503 |
oldbm = remote.oldbranchmap() |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
504 |
for branch, nodes in oldbm.iteritems(): |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
505 |
nodes = list(nodes) |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
506 |
new = set() |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
507 |
while nodes: |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
508 |
n = nodes.pop() |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
509 |
if n in repo.obsstore.precursors: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
510 |
markers = repo.obsstore.precursors[n] |
224 | 511 |
for mark in markers: |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
512 |
for newernode in mark[1]: |
224 | 513 |
if newernode is not None: |
514 |
nodes.append(newernode) |
|
218
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
515 |
else: |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
516 |
new.add(n) |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
517 |
if new: |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
518 |
newbm[branch] = list(new) |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
519 |
return newbm |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
520 |
remote.ignorevisiblebranchmap = True |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
521 |
remote.branchmap = branchmap |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
522 |
remote.newbranchmap = branchmap |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
523 |
return orig(repo, remote, outgoing, *args, **kwargs) |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
524 |
finally: |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
525 |
remote.__dict__.pop('branchmap', None) # restore class one |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
526 |
remote.__dict__.pop('oldbranchmap', None) |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
527 |
remote.__dict__.pop('newbranchmap', None) |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
528 |
remote.__dict__.pop('ignorevisiblebranchmap', None) |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
529 |
|
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
530 |
# eye are still burning |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
531 |
def wrapvisiblebranchmap(orig, repo): |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
532 |
ignore = getattr(repo, 'ignorevisiblebranchmap', None) |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
533 |
if ignore is None: |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
534 |
return orig(repo) |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
535 |
elif ignore: |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
536 |
return repo.branchmap() |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
537 |
else: |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
538 |
return None # break recursion |
217
786eb34d93ea
obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
215
diff
changeset
|
539 |
|
307
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
540 |
def wrapclearcache(orig, repo, *args, **kwargs): |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
541 |
try: |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
542 |
return orig(repo, *args, **kwargs) |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
543 |
finally: |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
544 |
repo._clearobsoletecache() |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
545 |
|
217
786eb34d93ea
obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
215
diff
changeset
|
546 |
|
71
19e1930587a0
[obsolete] Move extension compat code
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
70
diff
changeset
|
547 |
### New commands |
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
548 |
############################# |
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
549 |
|
276
f26e9bc5f7fc
obsolete: use new-style command registration
Patrick Mezard <patrick@mezard.eu>
parents:
275
diff
changeset
|
550 |
cmdtable = {} |
f26e9bc5f7fc
obsolete: use new-style command registration
Patrick Mezard <patrick@mezard.eu>
parents:
275
diff
changeset
|
551 |
command = cmdutil.command(cmdtable) |
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
552 |
|
276
f26e9bc5f7fc
obsolete: use new-style command registration
Patrick Mezard <patrick@mezard.eu>
parents:
275
diff
changeset
|
553 |
@command('debugobsolete', [], _('SUBJECT OBJECT')) |
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
554 |
def cmddebugobsolete(ui, repo, subject, object): |
278
fa0b9b8a83c0
obsolete: add or fix debug commands help
Patrick Mezard <patrick@mezard.eu>
parents:
277
diff
changeset
|
555 |
"""add an obsolete relation between two nodes |
74
c7dd26dec7fc
[obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
73
diff
changeset
|
556 |
|
278
fa0b9b8a83c0
obsolete: add or fix debug commands help
Patrick Mezard <patrick@mezard.eu>
parents:
277
diff
changeset
|
557 |
The subject is expected to be a newer version of the object. |
fa0b9b8a83c0
obsolete: add or fix debug commands help
Patrick Mezard <patrick@mezard.eu>
parents:
277
diff
changeset
|
558 |
""" |
224 | 559 |
lock = repo.lock() |
560 |
try: |
|
561 |
sub = repo[subject] |
|
562 |
obj = repo[object] |
|
563 |
repo.addobsolete(sub.node(), obj.node()) |
|
564 |
finally: |
|
565 |
lock.release() |
|
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
566 |
return 0 |
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
567 |
|
276
f26e9bc5f7fc
obsolete: use new-style command registration
Patrick Mezard <patrick@mezard.eu>
parents:
275
diff
changeset
|
568 |
@command('debugconvertobsolete', [], '') |
224 | 569 |
def cmddebugconvertobsolete(ui, repo): |
278
fa0b9b8a83c0
obsolete: add or fix debug commands help
Patrick Mezard <patrick@mezard.eu>
parents:
277
diff
changeset
|
570 |
"""import markers from an .hg/obsolete-relations file""" |
224 | 571 |
cnt = 0 |
572 |
l = repo.lock() |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
573 |
some = False |
224 | 574 |
try: |
575 |
repo._importoldobsolete = True |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
576 |
store = repo.obsstore |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
577 |
### very first format |
224 | 578 |
try: |
579 |
f = repo.opener('obsolete-relations') |
|
580 |
try: |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
581 |
some = True |
224 | 582 |
for line in f: |
583 |
subhex, objhex = line.split() |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
584 |
suc = bin(subhex) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
585 |
prec = bin(objhex) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
586 |
sucs = (suc==nullid) and [] or [suc] |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
587 |
meta = { |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
588 |
'date': '%i %i' % util.makedate(), |
224 | 589 |
'user': ui.username(), |
590 |
} |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
591 |
store.create(prec, sucs, 0, meta) |
224 | 592 |
cnt += 1 |
593 |
finally: |
|
594 |
f.close() |
|
595 |
util.unlink(repo.join('obsolete-relations')) |
|
596 |
except IOError: |
|
597 |
pass |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
598 |
### second (json) format |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
599 |
data = repo.sopener.tryread('obsoletemarkers') |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
600 |
if data: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
601 |
some = True |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
602 |
for oldmark in json.loads(data): |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
603 |
del oldmark['id'] # dropped for now |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
604 |
del oldmark['reason'] # unused until then |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
605 |
oldmark['subjects'] = [bin(n) for n in oldmark['subjects']] |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
606 |
oldmark['object'] = bin(oldmark['object']) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
607 |
oldmark['date'] = '%i %i' % tuple(oldmark['date']) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
608 |
store.create(oldmark.pop('object'), |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
609 |
oldmark.pop('subjects'), |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
610 |
0, oldmark) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
611 |
cnt += 1 |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
612 |
util.unlink(repo.sjoin('obsoletemarkers')) |
224 | 613 |
finally: |
614 |
del repo._importoldobsolete |
|
615 |
l.release() |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
616 |
if not some: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
617 |
ui.warn('nothing to do\n') |
224 | 618 |
ui.status('%i obsolete marker converted\n' % cnt) |
619 |
||
276
f26e9bc5f7fc
obsolete: use new-style command registration
Patrick Mezard <patrick@mezard.eu>
parents:
275
diff
changeset
|
620 |
@command('debugsuccessors', [], '') |
273
87e4d1eec5e8
obsolete: add debugsuccessors command
Patrick Mezard <patrick@mezard.eu>
parents:
254
diff
changeset
|
621 |
def cmddebugsuccessors(ui, repo): |
87e4d1eec5e8
obsolete: add debugsuccessors command
Patrick Mezard <patrick@mezard.eu>
parents:
254
diff
changeset
|
622 |
"""dump obsolete changesets and their successors |
87e4d1eec5e8
obsolete: add debugsuccessors command
Patrick Mezard <patrick@mezard.eu>
parents:
254
diff
changeset
|
623 |
|
87e4d1eec5e8
obsolete: add debugsuccessors command
Patrick Mezard <patrick@mezard.eu>
parents:
254
diff
changeset
|
624 |
Each line matches an existing marker, the first identifier is the |
87e4d1eec5e8
obsolete: add debugsuccessors command
Patrick Mezard <patrick@mezard.eu>
parents:
254
diff
changeset
|
625 |
obsolete changeset identifier, followed by it successors. |
87e4d1eec5e8
obsolete: add debugsuccessors command
Patrick Mezard <patrick@mezard.eu>
parents:
254
diff
changeset
|
626 |
""" |
87e4d1eec5e8
obsolete: add debugsuccessors command
Patrick Mezard <patrick@mezard.eu>
parents:
254
diff
changeset
|
627 |
lock = repo.lock() |
87e4d1eec5e8
obsolete: add debugsuccessors command
Patrick Mezard <patrick@mezard.eu>
parents:
254
diff
changeset
|
628 |
try: |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
629 |
allsuccessors = repo.obsstore.precursors |
273
87e4d1eec5e8
obsolete: add debugsuccessors command
Patrick Mezard <patrick@mezard.eu>
parents:
254
diff
changeset
|
630 |
for old in sorted(allsuccessors): |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
631 |
successors = [sorted(m[1]) for m in allsuccessors[old]] |
273
87e4d1eec5e8
obsolete: add debugsuccessors command
Patrick Mezard <patrick@mezard.eu>
parents:
254
diff
changeset
|
632 |
for i, group in enumerate(sorted(successors)): |
87e4d1eec5e8
obsolete: add debugsuccessors command
Patrick Mezard <patrick@mezard.eu>
parents:
254
diff
changeset
|
633 |
ui.write('%s' % short(old)) |
87e4d1eec5e8
obsolete: add debugsuccessors command
Patrick Mezard <patrick@mezard.eu>
parents:
254
diff
changeset
|
634 |
for new in group: |
87e4d1eec5e8
obsolete: add debugsuccessors command
Patrick Mezard <patrick@mezard.eu>
parents:
254
diff
changeset
|
635 |
ui.write(' %s' % short(new)) |
87e4d1eec5e8
obsolete: add debugsuccessors command
Patrick Mezard <patrick@mezard.eu>
parents:
254
diff
changeset
|
636 |
ui.write('\n') |
87e4d1eec5e8
obsolete: add debugsuccessors command
Patrick Mezard <patrick@mezard.eu>
parents:
254
diff
changeset
|
637 |
finally: |
87e4d1eec5e8
obsolete: add debugsuccessors command
Patrick Mezard <patrick@mezard.eu>
parents:
254
diff
changeset
|
638 |
lock.release() |
224 | 639 |
|
79
9906560f585e
[obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
75
diff
changeset
|
640 |
### Altering existing command |
9906560f585e
[obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
75
diff
changeset
|
641 |
############################# |
9906560f585e
[obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
75
diff
changeset
|
642 |
|
9906560f585e
[obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
75
diff
changeset
|
643 |
def wrapmayobsoletewc(origfn, ui, repo, *args, **opts): |
9906560f585e
[obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
75
diff
changeset
|
644 |
res = origfn(ui, repo, *args, **opts) |
9906560f585e
[obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
75
diff
changeset
|
645 |
if repo['.'].obsolete(): |
9906560f585e
[obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
75
diff
changeset
|
646 |
ui.warn(_('Working directory parent is obsolete\n')) |
9906560f585e
[obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
75
diff
changeset
|
647 |
return res |
9906560f585e
[obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
75
diff
changeset
|
648 |
|
224 | 649 |
def noextinctsvisibleheads(orig, repo): |
650 |
repo._turn_extinct_secret() |
|
651 |
return orig(repo) |
|
652 |
||
320
63f267bd2176
obsolete: basic commit --amend support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
311
diff
changeset
|
653 |
def wrapcmdutilamend(orig, ui, repo, commitfunc, old, *args, **kwargs): |
63f267bd2176
obsolete: basic commit --amend support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
311
diff
changeset
|
654 |
oldnode = old.node() |
63f267bd2176
obsolete: basic commit --amend support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
311
diff
changeset
|
655 |
new = orig(ui, repo, commitfunc, old, *args, **kwargs) |
63f267bd2176
obsolete: basic commit --amend support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
311
diff
changeset
|
656 |
if new != oldnode: |
63f267bd2176
obsolete: basic commit --amend support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
311
diff
changeset
|
657 |
lock = repo.lock() |
63f267bd2176
obsolete: basic commit --amend support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
311
diff
changeset
|
658 |
try: |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
659 |
meta = { |
320
63f267bd2176
obsolete: basic commit --amend support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
311
diff
changeset
|
660 |
'subjects': [new], |
63f267bd2176
obsolete: basic commit --amend support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
311
diff
changeset
|
661 |
'object': oldnode, |
63f267bd2176
obsolete: basic commit --amend support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
311
diff
changeset
|
662 |
'date': util.makedate(), |
63f267bd2176
obsolete: basic commit --amend support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
311
diff
changeset
|
663 |
'user': ui.username(), |
63f267bd2176
obsolete: basic commit --amend support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
311
diff
changeset
|
664 |
'reason': 'commit --amend', |
63f267bd2176
obsolete: basic commit --amend support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
311
diff
changeset
|
665 |
} |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
666 |
repo.obsstore.create(oldnode, [new], 0, meta) |
320
63f267bd2176
obsolete: basic commit --amend support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
311
diff
changeset
|
667 |
repo._clearobsoletecache() |
63f267bd2176
obsolete: basic commit --amend support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
311
diff
changeset
|
668 |
repo._turn_extinct_secret() |
63f267bd2176
obsolete: basic commit --amend support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
311
diff
changeset
|
669 |
finally: |
63f267bd2176
obsolete: basic commit --amend support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
311
diff
changeset
|
670 |
lock.release() |
63f267bd2176
obsolete: basic commit --amend support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
311
diff
changeset
|
671 |
return new |
63f267bd2176
obsolete: basic commit --amend support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
311
diff
changeset
|
672 |
|
79
9906560f585e
[obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
75
diff
changeset
|
673 |
def uisetup(ui): |
9906560f585e
[obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
75
diff
changeset
|
674 |
extensions.wrapcommand(commands.table, "update", wrapmayobsoletewc) |
9906560f585e
[obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
75
diff
changeset
|
675 |
extensions.wrapcommand(commands.table, "pull", wrapmayobsoletewc) |
320
63f267bd2176
obsolete: basic commit --amend support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
311
diff
changeset
|
676 |
if util.safehasattr(cmdutil, 'amend'): |
63f267bd2176
obsolete: basic commit --amend support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
311
diff
changeset
|
677 |
extensions.wrapfunction(cmdutil, 'amend', wrapcmdutilamend) |
214
a140d1857931
obsolete: do not warn about unpushed extinct changeset.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
213
diff
changeset
|
678 |
extensions.wrapfunction(discovery, 'findcommonoutgoing', wrapfindcommonoutgoing) |
217
786eb34d93ea
obsolete: refuse to push unstable changeset without -f
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
215
diff
changeset
|
679 |
extensions.wrapfunction(discovery, 'checkheads', wrapcheckheads) |
224 | 680 |
extensions.wrapfunction(phases, 'visibleheads', noextinctsvisibleheads) |
307
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
681 |
extensions.wrapfunction(phases, 'advanceboundary', wrapclearcache) |
218
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
682 |
if util.safehasattr(phases, 'visiblebranchmap'): |
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
683 |
extensions.wrapfunction(phases, 'visiblebranchmap', wrapvisiblebranchmap) |
79
9906560f585e
[obsolete] issue a warning when parent of current directory is obsolete.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
75
diff
changeset
|
684 |
|
70
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
685 |
### serialisation |
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
686 |
############################# |
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
687 |
|
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
688 |
def _obsserialise(obssubrels, flike): |
74
c7dd26dec7fc
[obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
73
diff
changeset
|
689 |
"""serialise an obsolete relation mapping in a plain text one |
c7dd26dec7fc
[obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
73
diff
changeset
|
690 |
|
c7dd26dec7fc
[obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
73
diff
changeset
|
691 |
this is for subject -> [objects] mapping |
c7dd26dec7fc
[obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
73
diff
changeset
|
692 |
|
c7dd26dec7fc
[obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
73
diff
changeset
|
693 |
format is:: |
c7dd26dec7fc
[obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
73
diff
changeset
|
694 |
|
c7dd26dec7fc
[obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
73
diff
changeset
|
695 |
<subject-full-hex> <object-full-hex>\n""" |
70
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
696 |
for sub, objs in obssubrels.iteritems(): |
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
697 |
for obj in objs: |
80
5d029a358252
[obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
79
diff
changeset
|
698 |
if sub is None: |
5d029a358252
[obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
79
diff
changeset
|
699 |
sub = nullid |
70
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
700 |
flike.write('%s %s\n' % (hex(sub), hex(obj))) |
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
701 |
|
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
702 |
def _obsdeserialise(flike): |
74
c7dd26dec7fc
[obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
73
diff
changeset
|
703 |
"""read a file like object serialised with _obsserialise |
c7dd26dec7fc
[obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
73
diff
changeset
|
704 |
|
c7dd26dec7fc
[obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
73
diff
changeset
|
705 |
this desierialize into a {subject -> objects} mapping""" |
70
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
706 |
rels = {} |
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
707 |
for line in flike: |
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
708 |
subhex, objhex = line.split() |
80
5d029a358252
[obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
79
diff
changeset
|
709 |
subnode = bin(subhex) |
5d029a358252
[obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
79
diff
changeset
|
710 |
if subnode == nullid: |
5d029a358252
[obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
79
diff
changeset
|
711 |
subnode = None |
5d029a358252
[obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
79
diff
changeset
|
712 |
rels.setdefault( subnode, set()).add(bin(objhex)) |
70
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
713 |
return rels |
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
714 |
|
87
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
86
diff
changeset
|
715 |
### diagnostique tools |
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
86
diff
changeset
|
716 |
############################# |
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
86
diff
changeset
|
717 |
|
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
86
diff
changeset
|
718 |
def unstables(repo): |
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
86
diff
changeset
|
719 |
"""Return all unstable changeset""" |
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
86
diff
changeset
|
720 |
return scmutil.revrange(repo, ['obsolete():: and (not obsolete())']) |
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
86
diff
changeset
|
721 |
|
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
86
diff
changeset
|
722 |
def newerversion(repo, obs): |
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
86
diff
changeset
|
723 |
"""Return the newer version of an obsolete changeset""" |
224 | 724 |
toproceed = set([(obs,)]) |
725 |
# XXX known optimization available |
|
87
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
86
diff
changeset
|
726 |
newer = set() |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
727 |
objectrels = repo.obsstore.precursors |
87
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
86
diff
changeset
|
728 |
while toproceed: |
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
86
diff
changeset
|
729 |
current = toproceed.pop() |
224 | 730 |
assert len(current) <= 1, 'splitting not handled yet. %r' % current |
731 |
if current: |
|
732 |
n, = current |
|
733 |
if n in objectrels: |
|
734 |
markers = objectrels[n] |
|
735 |
for mark in markers: |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
736 |
toproceed.add(tuple(mark[1])) |
224 | 737 |
else: |
738 |
newer.add(tuple(current)) |
|
132
64d16f07d67f
obsolete: alter newerversion return
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
131
diff
changeset
|
739 |
else: |
64d16f07d67f
obsolete: alter newerversion return
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
131
diff
changeset
|
740 |
newer.add(()) |
87
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
86
diff
changeset
|
741 |
return sorted(newer) |
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
86
diff
changeset
|
742 |
|
224 | 743 |
### obsolete relation storage |
744 |
############################# |
|
745 |
def add2set(d, key, mark): |
|
746 |
"""add <mark> to a `set` in <d>[<key>]""" |
|
747 |
d.setdefault(key, []).append(mark) |
|
748 |
||
749 |
def markerid(marker): |
|
750 |
KEYS = ['subjects', "object", "date", "user", "reason"] |
|
751 |
for key in KEYS: |
|
752 |
assert key in marker |
|
753 |
keys = sorted(marker.keys()) |
|
754 |
a = util.sha1() |
|
755 |
for key in keys: |
|
756 |
if key == 'subjects': |
|
757 |
for sub in sorted(marker[key]): |
|
758 |
a.update(sub) |
|
759 |
elif key == 'id': |
|
760 |
pass |
|
761 |
else: |
|
762 |
a.update(str(marker[key])) |
|
763 |
a.update('\0') |
|
764 |
return a.digest() |
|
765 |
||
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
766 |
# mercurial backport |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
767 |
|
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
768 |
def encodemeta(meta): |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
769 |
"""Return encoded metadata string to string mapping. |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
770 |
|
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
771 |
Assume no ':' in key and no '\0' in both key and value.""" |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
772 |
for key, value in meta.iteritems(): |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
773 |
if ':' in key or '\0' in key: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
774 |
raise ValueError("':' and '\0' are forbidden in metadata key'") |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
775 |
if '\0' in value: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
776 |
raise ValueError("':' are forbidden in metadata value'") |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
777 |
return '\0'.join(['%s:%s' % (k, meta[k]) for k in sorted(meta)]) |
224 | 778 |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
779 |
def decodemeta(data): |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
780 |
"""Return string to string dictionary from encoded version.""" |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
781 |
d = {} |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
782 |
for l in data.split('\0'): |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
783 |
if l: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
784 |
key, value = l.split(':') |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
785 |
d[key] = value |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
786 |
return d |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
787 |
|
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
788 |
# data used for parsing and writing |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
789 |
_fmversion = 0 |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
790 |
_fmfixed = '>BIB20s' |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
791 |
_fmnode = '20s' |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
792 |
_fmfsize = struct.calcsize(_fmfixed) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
793 |
_fnodesize = struct.calcsize(_fmnode) |
224 | 794 |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
795 |
def _readmarkers(data): |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
796 |
"""Read and enumerate markers from raw data""" |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
797 |
off = 0 |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
798 |
diskversion = _unpack('>B', data[off:off + 1])[0] |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
799 |
off += 1 |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
800 |
if diskversion != _fmversion: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
801 |
raise util.Abort(_('parsing obsolete marker: unknown version %r') |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
802 |
% diskversion) |
224 | 803 |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
804 |
# Loop on markers |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
805 |
l = len(data) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
806 |
while off + _fmfsize <= l: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
807 |
# read fixed part |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
808 |
cur = data[off:off + _fmfsize] |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
809 |
off += _fmfsize |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
810 |
nbsuc, mdsize, flags, pre = _unpack(_fmfixed, cur) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
811 |
# read replacement |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
812 |
sucs = () |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
813 |
if nbsuc: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
814 |
s = (_fnodesize * nbsuc) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
815 |
cur = data[off:off + s] |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
816 |
sucs = _unpack(_fmnode * nbsuc, cur) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
817 |
off += s |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
818 |
# read metadata |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
819 |
# (metadata will be decoded on demand) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
820 |
metadata = data[off:off + mdsize] |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
821 |
if len(metadata) != mdsize: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
822 |
raise util.Abort(_('parsing obsolete marker: metadata is too ' |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
823 |
'short, %d bytes expected, got %d') |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
824 |
% (len(metadata), mdsize)) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
825 |
off += mdsize |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
826 |
yield (pre, sucs, flags, metadata) |
224 | 827 |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
828 |
class obsstore(object): |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
829 |
"""Store obsolete markers |
224 | 830 |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
831 |
Markers can be accessed with two mappings: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
832 |
- precursors: old -> set(new) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
833 |
- successors: new -> set(old) |
224 | 834 |
""" |
835 |
||
836 |
def __init__(self): |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
837 |
self._all = [] |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
838 |
# new markers to serialize |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
839 |
self._new = [] |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
840 |
self.precursors = {} |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
841 |
self.successors = {} |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
842 |
|
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
843 |
def __iter__(self): |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
844 |
return iter(self._all) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
845 |
|
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
846 |
def __nonzero__(self): |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
847 |
return bool(self._all) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
848 |
|
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
849 |
def create(self, prec, succs=(), flag=0, metadata=None): |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
850 |
"""obsolete: add a new obsolete marker |
224 | 851 |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
852 |
* ensuring it is hashable |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
853 |
* check mandatory metadata |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
854 |
* encode metadata |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
855 |
""" |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
856 |
if metadata is None: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
857 |
metadata = {} |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
858 |
if len(prec) != 20: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
859 |
raise ValueError(prec) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
860 |
for succ in succs: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
861 |
if len(succ) != 20: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
862 |
raise ValueError(prec) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
863 |
marker = (str(prec), tuple(succs), int(flag), encodemeta(metadata)) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
864 |
self.add(marker) |
224 | 865 |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
866 |
def add(self, marker): |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
867 |
"""Add a new marker to the store |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
868 |
|
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
869 |
This marker still needs to be written to disk""" |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
870 |
self._new.append(marker) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
871 |
self._load(marker) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
872 |
|
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
873 |
def loadmarkers(self, data): |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
874 |
"""Load all markers in data, mark them as known.""" |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
875 |
for marker in _readmarkers(data): |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
876 |
self._load(marker) |
224 | 877 |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
878 |
def mergemarkers(self, data): |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
879 |
other = set(_readmarkers(data)) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
880 |
local = set(self._all) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
881 |
new = other - local |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
882 |
for marker in new: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
883 |
self.add(marker) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
884 |
|
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
885 |
def flushmarkers(self, stream): |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
886 |
"""Write all markers to a stream |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
887 |
|
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
888 |
After this operation, "new" markers are considered "known".""" |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
889 |
self._writemarkers(stream) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
890 |
self._new[:] = [] |
224 | 891 |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
892 |
def _load(self, marker): |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
893 |
self._all.append(marker) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
894 |
pre, sucs = marker[:2] |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
895 |
self.precursors.setdefault(pre, set()).add(marker) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
896 |
for suc in sucs: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
897 |
self.successors.setdefault(suc, set()).add(marker) |
224 | 898 |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
899 |
def _writemarkers(self, stream=None): |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
900 |
# Kept separate from flushmarkers(), it will be reused for |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
901 |
# markers exchange. |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
902 |
if stream is None: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
903 |
final = [] |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
904 |
w = final.append |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
905 |
else: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
906 |
w = stream.write |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
907 |
w(_pack('>B', _fmversion)) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
908 |
for marker in self._all: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
909 |
pre, sucs, flags, metadata = marker |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
910 |
nbsuc = len(sucs) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
911 |
format = _fmfixed + (_fmnode * nbsuc) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
912 |
data = [nbsuc, len(metadata), flags, pre] |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
913 |
data.extend(sucs) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
914 |
w(_pack(format, *data)) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
915 |
w(metadata) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
916 |
if stream is None: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
917 |
return ''.join(final) |
224 | 918 |
|
87
246b8fefd0a5
[evolution/obsolete] very experimental and crude evolve support.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
86
diff
changeset
|
919 |
|
86
7f763bada042
[obsolete] code section comment for repo subclassing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
85
diff
changeset
|
920 |
### repo subclassing |
7f763bada042
[obsolete] code section comment for repo subclassing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
85
diff
changeset
|
921 |
############################# |
7f763bada042
[obsolete] code section comment for repo subclassing
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
85
diff
changeset
|
922 |
|
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
923 |
def reposetup(ui, repo): |
47
b73b3e3c9560
Don't overwrite non local repo.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
46
diff
changeset
|
924 |
if not repo.local(): |
b73b3e3c9560
Don't overwrite non local repo.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
46
diff
changeset
|
925 |
return |
b73b3e3c9560
Don't overwrite non local repo.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
46
diff
changeset
|
926 |
|
44
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
927 |
opull = repo.pull |
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
928 |
opush = repo.push |
224 | 929 |
olock = repo.lock |
202
83b7e2c62ac3
[obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
197
diff
changeset
|
930 |
o_rollback = repo._rollback |
210
168ea7d200a0
obsolete: blindly obsolete unstability cache when changeset are added
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
205
diff
changeset
|
931 |
o_updatebranchcache = repo.updatebranchcache |
44
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
932 |
|
203
9799d0aa53c8
[obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
202
diff
changeset
|
933 |
# /!\ api change in Hg 2.2 (97efd26eb9576f39590812ea9) /!\ |
9799d0aa53c8
[obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
202
diff
changeset
|
934 |
if util.safehasattr(repo, '_journalfiles'): # Hg 2.2 |
9799d0aa53c8
[obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
202
diff
changeset
|
935 |
o_journalfiles = repo._journalfiles |
205
7ba30bd95a88
obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
204
diff
changeset
|
936 |
o_writejournal = repo._writejournal |
203
9799d0aa53c8
[obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
202
diff
changeset
|
937 |
|
9799d0aa53c8
[obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
202
diff
changeset
|
938 |
|
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
939 |
class obsoletingrepo(repo.__class__): |
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
940 |
|
53
0bcbf690dfca
reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
52
diff
changeset
|
941 |
### Public method |
0bcbf690dfca
reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
52
diff
changeset
|
942 |
def obsoletedby(self, node): |
0bcbf690dfca
reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
52
diff
changeset
|
943 |
"""return the set of node that make <node> obsolete (obj)""" |
224 | 944 |
others = set() |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
945 |
for marker in self.obsstore.precursors.get(node, []): |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
946 |
others.update(marker[1]) |
224 | 947 |
return others |
53
0bcbf690dfca
reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
52
diff
changeset
|
948 |
|
0bcbf690dfca
reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
52
diff
changeset
|
949 |
def obsolete(self, node): |
0bcbf690dfca
reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
52
diff
changeset
|
950 |
"""return the set of node that <node> make obsolete (sub)""" |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
951 |
return set(marker[0] for marker in self.obsstore.successors.get(node, [])) |
224 | 952 |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
953 |
@storecache('obsstore') |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
954 |
def obsstore(self): |
224 | 955 |
if not getattr(self, '_importoldobsolete', False): |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
956 |
data = repo.opener.tryread('obsolete-relations') |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
957 |
if not data: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
958 |
data = repo.sopener.tryread('obsoletemarkers') |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
959 |
if data: |
224 | 960 |
raise util.Abort('old format of obsolete marker detected!\n' |
961 |
'run `hg debugconvertobsolete` once.') |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
962 |
store = obsstore() |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
963 |
data = self.sopener.tryread('obsstore') |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
964 |
if data: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
965 |
store.loadmarkers(data) |
224 | 966 |
return store |
53
0bcbf690dfca
reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
52
diff
changeset
|
967 |
|
109
a2e8057117d3
obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
95
diff
changeset
|
968 |
@util.propertycache |
a2e8057117d3
obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
95
diff
changeset
|
969 |
def _obsoleteset(self): |
135
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
970 |
"""the set of obsolete revision""" |
109
a2e8057117d3
obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
95
diff
changeset
|
971 |
obs = set() |
126
c083fb43daee
obsolete: stop using rev as it rebuild the cache every time there is a fault
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
125
diff
changeset
|
972 |
nm = self.changelog.nodemap |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
973 |
for obj in self.obsstore.precursors: |
203
9799d0aa53c8
[obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
202
diff
changeset
|
974 |
try: # /!\api change in Hg 2.2 (e8d37b78acfb22ae2c1fb126c2)/!\ |
9799d0aa53c8
[obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
202
diff
changeset
|
975 |
rev = nm.get(obj) |
9799d0aa53c8
[obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
202
diff
changeset
|
976 |
except TypeError: #XXX to remove while breaking Hg 2.1 support |
9799d0aa53c8
[obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
202
diff
changeset
|
977 |
rev = nm.get(obj, None) |
126
c083fb43daee
obsolete: stop using rev as it rebuild the cache every time there is a fault
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
125
diff
changeset
|
978 |
if rev is not None: |
c083fb43daee
obsolete: stop using rev as it rebuild the cache every time there is a fault
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
125
diff
changeset
|
979 |
obs.add(rev) |
109
a2e8057117d3
obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
95
diff
changeset
|
980 |
return obs |
a2e8057117d3
obsolete: smarter initialisation of obsolete stuff from disk.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
95
diff
changeset
|
981 |
|
135
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
982 |
@util.propertycache |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
983 |
def _unstableset(self): |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
984 |
"""the set of non obsolete revision with obsolete parent""" |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
985 |
return set(self.revs('(obsolete()::) - obsolete()')) |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
986 |
|
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
987 |
@util.propertycache |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
988 |
def _suspendedset(self): |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
989 |
"""the set of obsolete parent with non obsolete descendant""" |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
990 |
return set(self.revs('obsolete() and obsolete()::unstable()')) |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
991 |
|
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
992 |
@util.propertycache |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
993 |
def _extinctset(self): |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
994 |
"""the set of obsolete parent without non obsolete descendant""" |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
995 |
return set(self.revs('obsolete() - obsolete()::unstable()')) |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
996 |
|
307
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
997 |
@util.propertycache |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
998 |
def _latecomerset(self): |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
999 |
"""the set of rev trying to obsolete public revision""" |
332
36e2016d6563
obsolete: public changeset are no longer latecomer.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
321
diff
changeset
|
1000 |
query = 'allsuccessors(public()) - obsolete() - public()' |
36e2016d6563
obsolete: public changeset are no longer latecomer.
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
321
diff
changeset
|
1001 |
return set(self.revs(query)) |
307
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
1002 |
|
135
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
1003 |
def _clearobsoletecache(self): |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
1004 |
if '_obsoleteset' in vars(self): |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
1005 |
del self._obsoleteset |
210
168ea7d200a0
obsolete: blindly obsolete unstability cache when changeset are added
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
205
diff
changeset
|
1006 |
self._clearunstablecache() |
168ea7d200a0
obsolete: blindly obsolete unstability cache when changeset are added
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
205
diff
changeset
|
1007 |
|
168ea7d200a0
obsolete: blindly obsolete unstability cache when changeset are added
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
205
diff
changeset
|
1008 |
def updatebranchcache(self): |
168ea7d200a0
obsolete: blindly obsolete unstability cache when changeset are added
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
205
diff
changeset
|
1009 |
o_updatebranchcache() |
168ea7d200a0
obsolete: blindly obsolete unstability cache when changeset are added
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
205
diff
changeset
|
1010 |
self._clearunstablecache() |
168ea7d200a0
obsolete: blindly obsolete unstability cache when changeset are added
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
205
diff
changeset
|
1011 |
|
168ea7d200a0
obsolete: blindly obsolete unstability cache when changeset are added
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
205
diff
changeset
|
1012 |
def _clearunstablecache(self): |
135
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
1013 |
if '_unstableset' in vars(self): |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
1014 |
del self._unstableset |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
1015 |
if '_suspendedset' in vars(self): |
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
1016 |
del self._suspendedset |
254
3ff969da57ef
obsolete: fix error in cache invalidation
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
253
diff
changeset
|
1017 |
if '_extinctset' in vars(self): |
135
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
1018 |
del self._extinctset |
307
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
1019 |
if '_latecomerset' in vars(self): |
9ac56d36d6ff
obsolete: add latecomer computation and display
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
306
diff
changeset
|
1020 |
del self._latecomerset |
135
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
1021 |
|
53
0bcbf690dfca
reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
52
diff
changeset
|
1022 |
def addobsolete(self, sub, obj): |
0bcbf690dfca
reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
52
diff
changeset
|
1023 |
"""Add a relation marking that node <sub> is a new version of <obj>""" |
224 | 1024 |
assert sub != obj |
1025 |
if not repo[obj].phase(): |
|
1026 |
if sub is None: |
|
1027 |
self.ui.warn( |
|
1028 |
_("trying to kill immutable changeset %(obj)s\n") |
|
1029 |
% {'obj': short(obj)}) |
|
1030 |
if sub is not None: |
|
1031 |
self.ui.warn( |
|
1032 |
_("%(sub)s try to obsolete immutable changeset %(obj)s\n") |
|
1033 |
% {'sub': short(sub), 'obj': short(obj)}) |
|
1034 |
lock = self.lock() |
|
53
0bcbf690dfca
reorganise code
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
52
diff
changeset
|
1035 |
try: |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1036 |
meta = { |
224 | 1037 |
'date': util.makedate(), |
1038 |
'user': ui.username(), |
|
1039 |
'reason': 'unknown', |
|
1040 |
} |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1041 |
subs = (sub == nullid) and [] or [sub] |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1042 |
mid = self.obsstore.create(obj, subs, 0, meta) |
224 | 1043 |
self._clearobsoletecache() |
1044 |
self._turn_extinct_secret() |
|
1045 |
return mid |
|
1046 |
finally: |
|
1047 |
lock.release() |
|
1048 |
||
298
f597421662f7
obsolete: unify collapsed revisions markers handling
Patrick Mezard <patrick@mezard.eu>
parents:
297
diff
changeset
|
1049 |
def addcollapsedobsolete(self, oldnodes, newnode): |
f597421662f7
obsolete: unify collapsed revisions markers handling
Patrick Mezard <patrick@mezard.eu>
parents:
297
diff
changeset
|
1050 |
"""Mark oldnodes as collapsed into newnode.""" |
f597421662f7
obsolete: unify collapsed revisions markers handling
Patrick Mezard <patrick@mezard.eu>
parents:
297
diff
changeset
|
1051 |
# Assume oldnodes are all descendants of a single rev |
f597421662f7
obsolete: unify collapsed revisions markers handling
Patrick Mezard <patrick@mezard.eu>
parents:
297
diff
changeset
|
1052 |
rootrevs = self.revs('roots(%ln)', oldnodes) |
f597421662f7
obsolete: unify collapsed revisions markers handling
Patrick Mezard <patrick@mezard.eu>
parents:
297
diff
changeset
|
1053 |
assert len(rootrevs) == 1, rootrevs |
f597421662f7
obsolete: unify collapsed revisions markers handling
Patrick Mezard <patrick@mezard.eu>
parents:
297
diff
changeset
|
1054 |
rootnode = self[rootrevs[0]].node() |
f597421662f7
obsolete: unify collapsed revisions markers handling
Patrick Mezard <patrick@mezard.eu>
parents:
297
diff
changeset
|
1055 |
for n in oldnodes: |
f597421662f7
obsolete: unify collapsed revisions markers handling
Patrick Mezard <patrick@mezard.eu>
parents:
297
diff
changeset
|
1056 |
self.addobsolete(newnode, n) |
f597421662f7
obsolete: unify collapsed revisions markers handling
Patrick Mezard <patrick@mezard.eu>
parents:
297
diff
changeset
|
1057 |
|
224 | 1058 |
def _turn_extinct_secret(self): |
1059 |
"""ensure all extinct changeset are secret""" |
|
135
1a08daef8a53
obsolete: add revset for various error case
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
132
diff
changeset
|
1060 |
self._clearobsoletecache() |
224 | 1061 |
# this is mainly for safety purpose |
1062 |
# both pull and push |
|
300
3b1f326878e5
obsolete: suspended changeset with secret only children should be secret too
Patrick Mezard <patrick@mezard.eu>
parents:
299
diff
changeset
|
1063 |
query = '(obsolete() - obsolete()::(unstable() - secret())) - secret()' |
3b1f326878e5
obsolete: suspended changeset with secret only children should be secret too
Patrick Mezard <patrick@mezard.eu>
parents:
299
diff
changeset
|
1064 |
expobs = [c.node() for c in repo.set(query)] |
224 | 1065 |
phases.retractboundary(repo, 2, expobs) |
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
1066 |
|
37
9493ffa68633
Documentation !
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
32
diff
changeset
|
1067 |
### Disk IO |
224 | 1068 |
|
1069 |
def lock(self, *args, **kwargs): |
|
1070 |
l = olock(*args, **kwargs) |
|
1071 |
if not getattr(l.releasefn, 'obspatched', False): |
|
1072 |
oreleasefn = l.releasefn |
|
1073 |
def releasefn(*args, **kwargs): |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1074 |
if 'obsstore' in vars(self) and self.obsstore._new: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1075 |
f = self.sopener('obsstore', 'wb', atomictemp=True) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1076 |
try: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1077 |
self.obsstore.flushmarkers(f) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1078 |
f.close() |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1079 |
except: # re-raises |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1080 |
f.discard() |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1081 |
raise |
224 | 1082 |
oreleasefn(*args, **kwargs) |
1083 |
releasefn.obspatched = True |
|
1084 |
l.releasefn = releasefn |
|
1085 |
return l |
|
1086 |
||
50
19b22ad56b32
clone support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
47
diff
changeset
|
1087 |
|
44
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
1088 |
### pull // push support |
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
1089 |
|
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
1090 |
def pull(self, remote, *args, **kwargs): |
74
c7dd26dec7fc
[obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
73
diff
changeset
|
1091 |
"""wrapper around push that push obsolete relation""" |
224 | 1092 |
l = repo.lock() |
1093 |
try: |
|
1094 |
result = opull(remote, *args, **kwargs) |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1095 |
remoteobs = remote.listkeys('obsolete') |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1096 |
if 'dump' in remoteobs: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1097 |
data = base85.b85decode(remoteobs['dump']) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1098 |
self.obsstore.mergemarkers(data) |
224 | 1099 |
self._clearobsoletecache() |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1100 |
self._turn_extinct_secret() |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1101 |
return result |
224 | 1102 |
finally: |
1103 |
l.release() |
|
44
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
1104 |
|
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
1105 |
def push(self, remote, *args, **opts): |
74
c7dd26dec7fc
[obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
73
diff
changeset
|
1106 |
"""wrapper around pull that pull obsolete relation""" |
224 | 1107 |
self._turn_extinct_secret() |
44
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
1108 |
result = opush(remote, *args, **opts) |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1109 |
if 'obsolete' in self.listkeys('namespaces') and self.obsstore: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1110 |
data = self.obsstore._writemarkers() |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1111 |
r = remote.pushkey('obsolete', 'dump', '', |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1112 |
base85.b85encode(data)) |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1113 |
if not r: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1114 |
self.ui.warn(_('failed to push obsolete markers!\n')) |
224 | 1115 |
self._turn_extinct_secret() |
54
ad1a4fb0fc49
Make states more resilient to missing head
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
53
diff
changeset
|
1116 |
|
44
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
1117 |
return result |
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
1118 |
|
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
1119 |
|
52
62bdc2567099
Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
51
diff
changeset
|
1120 |
### rollback support |
62bdc2567099
Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
51
diff
changeset
|
1121 |
|
203
9799d0aa53c8
[obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
202
diff
changeset
|
1122 |
# /!\ api change in Hg 2.2 (97efd26eb9576f39590812ea9) /!\ |
9799d0aa53c8
[obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
202
diff
changeset
|
1123 |
if util.safehasattr(repo, '_journalfiles'): # Hg 2.2 |
9799d0aa53c8
[obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
202
diff
changeset
|
1124 |
def _journalfiles(self): |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1125 |
return o_journalfiles() + (self.sjoin('journal.obsstore'),) |
205
7ba30bd95a88
obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
204
diff
changeset
|
1126 |
|
7ba30bd95a88
obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
204
diff
changeset
|
1127 |
def _writejournal(self, desc): |
7ba30bd95a88
obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
204
diff
changeset
|
1128 |
"""wrapped version of _writejournal that save obsolete data""" |
7ba30bd95a88
obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
204
diff
changeset
|
1129 |
o_writejournal(desc) |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1130 |
filename = 'obsstore' |
224 | 1131 |
filepath = self.sjoin(filename) |
205
7ba30bd95a88
obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
204
diff
changeset
|
1132 |
if os.path.exists(filepath): |
7ba30bd95a88
obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
204
diff
changeset
|
1133 |
journalname = 'journal.' + filename |
224 | 1134 |
journalpath = self.sjoin(journalname) |
205
7ba30bd95a88
obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
204
diff
changeset
|
1135 |
util.copyfile(filepath, journalpath) |
7ba30bd95a88
obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
204
diff
changeset
|
1136 |
|
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
1137 |
else: # XXX removing this bloc will break Hg 2.1 support |
205
7ba30bd95a88
obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
204
diff
changeset
|
1138 |
def _writejournal(self, desc): |
203
9799d0aa53c8
[obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
202
diff
changeset
|
1139 |
"""wrapped version of _writejournal that save obsolete data""" |
9799d0aa53c8
[obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
202
diff
changeset
|
1140 |
entries = list(o_writejournal(desc)) |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1141 |
filename = 'obsstore' |
224 | 1142 |
filepath = self.sjoin(filename) |
203
9799d0aa53c8
[obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
202
diff
changeset
|
1143 |
if os.path.exists(filepath): |
9799d0aa53c8
[obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
202
diff
changeset
|
1144 |
journalname = 'journal.' + filename |
224 | 1145 |
journalpath = self.sjoin(journalname) |
203
9799d0aa53c8
[obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
202
diff
changeset
|
1146 |
util.copyfile(filepath, journalpath) |
9799d0aa53c8
[obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
202
diff
changeset
|
1147 |
entries.append(journalpath) |
9799d0aa53c8
[obsolete] add supprt for futur Hg 2.2
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
202
diff
changeset
|
1148 |
return tuple(entries) |
52
62bdc2567099
Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
51
diff
changeset
|
1149 |
|
205
7ba30bd95a88
obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
204
diff
changeset
|
1150 |
def _rollback(self, dryrun, force): |
202
83b7e2c62ac3
[obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
197
diff
changeset
|
1151 |
"""wrapped version of _rollback that restore obsolete data""" |
205
7ba30bd95a88
obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
204
diff
changeset
|
1152 |
ret = o_rollback(dryrun, force) |
202
83b7e2c62ac3
[obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
197
diff
changeset
|
1153 |
if not (ret or dryrun): #rollback did not failed |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1154 |
src = self.sjoin('undo.obsstore') |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1155 |
dst = self.sjoin('obsstore') |
202
83b7e2c62ac3
[obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
197
diff
changeset
|
1156 |
if os.path.exists(src): |
83b7e2c62ac3
[obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
197
diff
changeset
|
1157 |
util.rename(src, dst) |
205
7ba30bd95a88
obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
204
diff
changeset
|
1158 |
elif os.path.exists(dst): |
7ba30bd95a88
obsolete: fix rollback wrapper for 2.2-rc
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
204
diff
changeset
|
1159 |
# If no state was saved because the file did not existed before. |
202
83b7e2c62ac3
[obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
197
diff
changeset
|
1160 |
os.unlink(dst) |
83b7e2c62ac3
[obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
197
diff
changeset
|
1161 |
# invalidate cache |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
1162 |
self.__dict__.pop('obsstore', None) |
202
83b7e2c62ac3
[obsolete] simplify by using the Hg 2.1 api
Alain Leufroy <alain.leufroy@logilab.fr>
parents:
197
diff
changeset
|
1163 |
return ret |
52
62bdc2567099
Rollback support
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
51
diff
changeset
|
1164 |
|
160
24346b78cd99
mercurial 2.1.2 compat
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
150
diff
changeset
|
1165 |
@storecache('00changelog.i') |
114
1a64195e2b09
nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
112
diff
changeset
|
1166 |
def changelog(self): |
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
1167 |
# << copy pasted from mercurial source |
215
0eceb5a48485
obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
214
diff
changeset
|
1168 |
c = changelog.changelog(self.sopener) |
0eceb5a48485
obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
214
diff
changeset
|
1169 |
if 'HG_PENDING' in os.environ: |
0eceb5a48485
obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
214
diff
changeset
|
1170 |
p = os.environ['HG_PENDING'] |
0eceb5a48485
obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
214
diff
changeset
|
1171 |
if p.startswith(self.root): |
0eceb5a48485
obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
214
diff
changeset
|
1172 |
c.readpending('00changelog.i.a') |
0eceb5a48485
obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
214
diff
changeset
|
1173 |
# >> end of the copy paste |
0eceb5a48485
obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
214
diff
changeset
|
1174 |
old = c.__dict__.pop('hiddenrevs', ()) |
122
c75a73209f1e
Locking while writing obsolete data.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
121
diff
changeset
|
1175 |
if old: |
c75a73209f1e
Locking while writing obsolete data.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
121
diff
changeset
|
1176 |
ui.warn("old wasn't empty ? %r" % old) |
215
0eceb5a48485
obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
214
diff
changeset
|
1177 |
def _sethidden(c, value): |
114
1a64195e2b09
nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
112
diff
changeset
|
1178 |
assert not value |
1a64195e2b09
nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
112
diff
changeset
|
1179 |
|
1a64195e2b09
nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
112
diff
changeset
|
1180 |
|
215
0eceb5a48485
obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
214
diff
changeset
|
1181 |
class hchangelog(c.__class__): |
114
1a64195e2b09
nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
112
diff
changeset
|
1182 |
@util.propertycache |
215
0eceb5a48485
obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
214
diff
changeset
|
1183 |
def hiddenrevs(c): |
114
1a64195e2b09
nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
112
diff
changeset
|
1184 |
shown = ['not obsolete()', '.', 'bookmark()', 'tagged()', |
1a64195e2b09
nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
112
diff
changeset
|
1185 |
'public()'] |
1a64195e2b09
nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
112
diff
changeset
|
1186 |
basicquery = 'obsolete() - (::(%s))' % (' or '.join(shown)) |
1a64195e2b09
nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
112
diff
changeset
|
1187 |
# !!! self is repo not changelog |
1a64195e2b09
nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
112
diff
changeset
|
1188 |
result = set(scmutil.revrange(self, [basicquery])) |
1a64195e2b09
nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
112
diff
changeset
|
1189 |
return result |
215
0eceb5a48485
obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
214
diff
changeset
|
1190 |
c.__class__ = hchangelog |
0eceb5a48485
obsolete: fix changelog reload
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
214
diff
changeset
|
1191 |
return c |
114
1a64195e2b09
nicer hiddenrevs init
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
112
diff
changeset
|
1192 |
|
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
1193 |
repo.__class__ = obsoletingrepo |