author | Pierre-Yves David <pierre-yves.david@fb.com> |
Thu, 18 Jun 2015 17:56:02 -0700 | |
branch | stable |
changeset 1387 | eb044bcf342d |
parent 1061 | f3867e60d072 |
child 1216 | a307eea46f96 |
permissions | -rw-r--r-- |
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
1 |
# 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
|
2 |
# Logilab SA <contact@logilab.fr> |
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
3 |
# |
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
4 |
# 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
|
5 |
# GNU General Public License version 2 or any later version. |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
6 |
"""Deprecated extension that formely introduces "Changeset Obsolescence". |
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
7 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
8 |
This concept is now partially in Mercurial core (starting with mercurial 2.3). The remaining logic have been grouped with the evolve extension. |
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
9 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
10 |
Some code cemains in this extensions to detect and convert prehistoric format of obsolete marker than early user may have create. Keep it enabled if you were such user. |
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
11 |
""" |
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
12 |
|
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
13 |
from mercurial import util |
433
aa1255c2ac8f
obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
432
diff
changeset
|
14 |
|
aa1255c2ac8f
obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
432
diff
changeset
|
15 |
try: |
aa1255c2ac8f
obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
432
diff
changeset
|
16 |
from mercurial import obsolete |
489
fdf3ae486e01
Fix mercurial version check
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
486
diff
changeset
|
17 |
if not obsolete._enabled: |
fdf3ae486e01
Fix mercurial version check
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
486
diff
changeset
|
18 |
obsolete._enabled = True |
433
aa1255c2ac8f
obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
432
diff
changeset
|
19 |
except ImportError: |
458
5d47d854716e
obsolete: fix indentation in obsolete import block
Patrick Mezard <patrick@mezard.eu>
parents:
457
diff
changeset
|
20 |
raise util.Abort('Obsolete extension requires Mercurial 2.3 (or later)') |
433
aa1255c2ac8f
obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
432
diff
changeset
|
21 |
|
439
6cff54825233
obsolete: reorder import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
438
diff
changeset
|
22 |
import sys |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
23 |
import json |
354
bd26eb9714fb
obsolete: Detect conflicting changeset!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
351
diff
changeset
|
24 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
25 |
from mercurial import cmdutil |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
26 |
from mercurial import error |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
27 |
from mercurial.node import bin, nullid |
39 | 28 |
|
44
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
29 |
|
430
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
30 |
##################################################################### |
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
31 |
### Older format management ### |
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
32 |
##################################################################### |
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
|
33 |
|
430
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
34 |
# Code related to detection and management of older legacy format never |
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
35 |
# handled by core |
218
ace5608350b6
obsolete: do no complain when push create a new head but obsolete an old one.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
217
diff
changeset
|
36 |
|
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
37 |
|
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
38 |
def reposetup(ui, repo): |
459
3477326461e3
obsolete: more typos and cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
458
diff
changeset
|
39 |
"""Detect that a repo still contains some old obsolete format |
273
87e4d1eec5e8
obsolete: add debugsuccessors command
Patrick Mezard <patrick@mezard.eu>
parents:
254
diff
changeset
|
40 |
""" |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
41 |
if not repo.local(): |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
42 |
return |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
43 |
for arg in sys.argv: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
44 |
if 'debugc' in arg: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
45 |
break |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
46 |
else: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
47 |
data = repo.opener.tryread('obsolete-relations') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
48 |
if not data: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
49 |
data = repo.sopener.tryread('obsoletemarkers') |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
50 |
if data: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
51 |
raise util.Abort('old format of obsolete marker detected!\n' |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
52 |
'run `hg debugconvertobsolete` once.') |
70
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
53 |
|
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
54 |
def _obsdeserialise(flike): |
74
c7dd26dec7fc
[obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
73
diff
changeset
|
55 |
"""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
|
56 |
|
454
4e34a723115b
obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
453
diff
changeset
|
57 |
this desierialize into a {subject -> objects} mapping |
4e34a723115b
obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
453
diff
changeset
|
58 |
|
4e34a723115b
obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
453
diff
changeset
|
59 |
this was the very first format ever.""" |
70
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
60 |
rels = {} |
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
61 |
for line in flike: |
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
62 |
subhex, objhex = line.split() |
80
5d029a358252
[obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
79
diff
changeset
|
63 |
subnode = bin(subhex) |
5d029a358252
[obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
79
diff
changeset
|
64 |
if subnode == nullid: |
5d029a358252
[obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
79
diff
changeset
|
65 |
subnode = None |
5d029a358252
[obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
79
diff
changeset
|
66 |
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
|
67 |
return rels |
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
68 |
|
441
d702f0d26c6a
obsolete: remove debugsuccessors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
440
diff
changeset
|
69 |
cmdtable = {} |
d702f0d26c6a
obsolete: remove debugsuccessors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
440
diff
changeset
|
70 |
command = cmdutil.command(cmdtable) |
276
f26e9bc5f7fc
obsolete: use new-style command registration
Patrick Mezard <patrick@mezard.eu>
parents:
275
diff
changeset
|
71 |
@command('debugconvertobsolete', [], '') |
224 | 72 |
def cmddebugconvertobsolete(ui, repo): |
278
fa0b9b8a83c0
obsolete: add or fix debug commands help
Patrick Mezard <patrick@mezard.eu>
parents:
277
diff
changeset
|
73 |
"""import markers from an .hg/obsolete-relations file""" |
224 | 74 |
cnt = 0 |
337
ebfd1b96a013
obsolete: convert try to guess what invalid node id are
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
336
diff
changeset
|
75 |
err = 0 |
224 | 76 |
l = repo.lock() |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
77 |
some = False |
224 | 78 |
try: |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
79 |
unlink = [] |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
80 |
tr = repo.transaction('convert-obsolete') |
224 | 81 |
try: |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
82 |
repo._importoldobsolete = True |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
83 |
store = repo.obsstore |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
84 |
### very first format |
224 | 85 |
try: |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
86 |
f = repo.opener('obsolete-relations') |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
87 |
try: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
88 |
some = True |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
89 |
for line in f: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
90 |
subhex, objhex = line.split() |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
91 |
suc = bin(subhex) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
92 |
prec = bin(objhex) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
93 |
sucs = (suc==nullid) and [] or [suc] |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
94 |
meta = { |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
95 |
'date': '%i %i' % util.makedate(), |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
96 |
'user': ui.username(), |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
97 |
} |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
98 |
try: |
1061
f3867e60d072
compat: always call metadata as a keyword argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
519
diff
changeset
|
99 |
store.create(tr, prec, sucs, 0, metadata=meta) |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
100 |
cnt += 1 |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
101 |
except ValueError: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
102 |
repo.ui.write_err("invalid old marker line: %s" |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
103 |
% (line)) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
104 |
err += 1 |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
105 |
finally: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
106 |
f.close() |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
107 |
unlink.append(repo.join('obsolete-relations')) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
108 |
except IOError: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
109 |
pass |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
110 |
### second (json) format |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
111 |
data = repo.sopener.tryread('obsoletemarkers') |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
112 |
if data: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
113 |
some = True |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
114 |
for oldmark in json.loads(data): |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
115 |
del oldmark['id'] # dropped for now |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
116 |
del oldmark['reason'] # unused until then |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
117 |
oldobject = str(oldmark.pop('object')) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
118 |
oldsubjects = [str(s) for s in oldmark.pop('subjects', [])] |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
119 |
LOOKUP_ERRORS = (error.RepoLookupError, error.LookupError) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
120 |
if len(oldobject) != 40: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
121 |
try: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
122 |
oldobject = repo[oldobject].node() |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
123 |
except LOOKUP_ERRORS: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
124 |
pass |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
125 |
if any(len(s) != 40 for s in oldsubjects): |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
126 |
try: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
127 |
oldsubjects = [repo[s].node() for s in oldsubjects] |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
128 |
except LOOKUP_ERRORS: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
129 |
pass |
224 | 130 |
|
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
131 |
oldmark['date'] = '%i %i' % tuple(oldmark['date']) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
132 |
meta = dict((k.encode('utf-8'), v.encode('utf-8')) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
133 |
for k, v in oldmark.iteritems()) |
341
7653f80fd7a4
obsolete: harden convertion from first format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
340
diff
changeset
|
134 |
try: |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
135 |
succs = [bin(n) for n in oldsubjects] |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
136 |
succs = [n for n in succs if n != nullid] |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
137 |
store.create(tr, bin(oldobject), succs, |
1061
f3867e60d072
compat: always call metadata as a keyword argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
519
diff
changeset
|
138 |
0, metadata=meta) |
341
7653f80fd7a4
obsolete: harden convertion from first format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
340
diff
changeset
|
139 |
cnt += 1 |
7653f80fd7a4
obsolete: harden convertion from first format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
340
diff
changeset
|
140 |
except ValueError: |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
141 |
repo.ui.write_err("invalid marker %s -> %s\n" |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
142 |
% (oldobject, oldsubjects)) |
341
7653f80fd7a4
obsolete: harden convertion from first format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
340
diff
changeset
|
143 |
err += 1 |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
144 |
unlink.append(repo.sjoin('obsoletemarkers')) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
145 |
tr.close() |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
146 |
for path in unlink: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
147 |
util.unlink(path) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
148 |
finally: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
149 |
tr.release() |
224 | 150 |
finally: |
151 |
del repo._importoldobsolete |
|
152 |
l.release() |
|
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
153 |
if not some: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
154 |
ui.warn('nothing to do\n') |
224 | 155 |
ui.status('%i obsolete marker converted\n' % cnt) |
337
ebfd1b96a013
obsolete: convert try to guess what invalid node id are
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
336
diff
changeset
|
156 |
if err: |
ebfd1b96a013
obsolete: convert try to guess what invalid node id are
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
336
diff
changeset
|
157 |
ui.write_err('%i conversion failed. check you graph!\n' % err) |