Mercurial > evolve
annotate hgext/obsolete.py @ 2105:d4e7d8392cfa mercurial-3.6
compat: closing mercurial-3.6 compatibility branch
The "evolve-6.0.0" release drop compatibility with Mercurial 3.6. No new commit
are expected on this branch.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Tue, 14 Mar 2017 11:30:41 -0700 |
parents | 86e71a0b3319 |
children |
rev | line source |
---|---|
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. |
1665 | 6 """Deprecated extension that formerly introduced "Changeset Obsolescence". |
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
7 |
1669 | 8 This concept is now partially in Mercurial core (starting with Mercurial 2.3). |
1664 | 9 The remaining logic has been grouped with the evolve extension. |
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
10 |
1657 | 11 Some code remains in this extensions to detect and convert prehistoric format |
1550
e47dda53a5c2
check-code: make obsolete.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1465
diff
changeset
|
12 of obsolete marker than early user may have create. Keep it enabled if you |
e47dda53a5c2
check-code: make obsolete.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1465
diff
changeset
|
13 were such user. |
69
aee53d546849
[obsolete] update doc
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
58
diff
changeset
|
14 """ |
228
5a17c0d41a00
proof-read documentation and docstrings
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
226
diff
changeset
|
15 |
1757
86e71a0b3319
errors: add missing imports of mercurial.error
Martin von Zweigbergk <martinvonz@google.com>
parents:
1669
diff
changeset
|
16 from mercurial import error |
433
aa1255c2ac8f
obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
432
diff
changeset
|
17 |
aa1255c2ac8f
obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
432
diff
changeset
|
18 try: |
aa1255c2ac8f
obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
432
diff
changeset
|
19 from mercurial import obsolete |
aa1255c2ac8f
obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
432
diff
changeset
|
20 except ImportError: |
1550
e47dda53a5c2
check-code: make obsolete.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1465
diff
changeset
|
21 raise error.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
|
22 |
439
6cff54825233
obsolete: reorder import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
438
diff
changeset
|
23 import sys |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
24 import json |
354
bd26eb9714fb
obsolete: Detect conflicting changeset!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
351
diff
changeset
|
25 |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
26 from mercurial import cmdutil |
1550
e47dda53a5c2
check-code: make obsolete.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1465
diff
changeset
|
27 from mercurial.i18n import _ |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
28 from mercurial.node import bin, nullid |
1757
86e71a0b3319
errors: add missing imports of mercurial.error
Martin von Zweigbergk <martinvonz@google.com>
parents:
1669
diff
changeset
|
29 from mercurial import util |
39 | 30 |
44
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
31 |
430
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
32 ##################################################################### |
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
33 ### Older format management ### |
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
34 ##################################################################### |
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
|
35 |
430
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
36 # 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
|
37 # 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
|
38 |
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
39 |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
40 def reposetup(ui, repo): |
459
3477326461e3
obsolete: more typos and cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
458
diff
changeset
|
41 """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
|
42 """ |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
43 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
|
44 return |
1216
a307eea46f96
oldobsolete: remove use of obsolete._enabled
Durham Goode <durham@fb.com>
parents:
1061
diff
changeset
|
45 evolveopts = ui.configlist('experimental', 'evolution') |
a307eea46f96
oldobsolete: remove use of obsolete._enabled
Durham Goode <durham@fb.com>
parents:
1061
diff
changeset
|
46 if not evolveopts: |
a307eea46f96
oldobsolete: remove use of obsolete._enabled
Durham Goode <durham@fb.com>
parents:
1061
diff
changeset
|
47 evolveopts = 'all' |
a307eea46f96
oldobsolete: remove use of obsolete._enabled
Durham Goode <durham@fb.com>
parents:
1061
diff
changeset
|
48 ui.setconfig('experimental', 'evolution', evolveopts) |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
49 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
|
50 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
|
51 break |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
52 else: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
53 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
|
54 if not data: |
1465
777e5c369d99
compat: use svfs instead of sopener
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1216
diff
changeset
|
55 data = repo.svfs.tryread('obsoletemarkers') |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
56 if data: |
1550
e47dda53a5c2
check-code: make obsolete.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1465
diff
changeset
|
57 raise error.Abort('old format of obsolete marker detected!\n' |
e47dda53a5c2
check-code: make obsolete.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1465
diff
changeset
|
58 'run `hg debugconvertobsolete` once.') |
70
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
59 |
1647 | 60 def _obsdeserialize(flike): |
1648 | 61 """read a file like object serialized with _obsserialize |
74
c7dd26dec7fc
[obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
73
diff
changeset
|
62 |
1649 | 63 this deserialize into a {subject -> objects} mapping |
454
4e34a723115b
obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
453
diff
changeset
|
64 |
4e34a723115b
obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
453
diff
changeset
|
65 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
|
66 rels = {} |
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
67 for line in flike: |
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
68 subhex, objhex = line.split() |
80
5d029a358252
[obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
79
diff
changeset
|
69 subnode = bin(subhex) |
5d029a358252
[obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
79
diff
changeset
|
70 if subnode == nullid: |
5d029a358252
[obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
79
diff
changeset
|
71 subnode = None |
1550
e47dda53a5c2
check-code: make obsolete.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1465
diff
changeset
|
72 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
|
73 return rels |
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
74 |
441
d702f0d26c6a
obsolete: remove debugsuccessors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
440
diff
changeset
|
75 cmdtable = {} |
d702f0d26c6a
obsolete: remove debugsuccessors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
440
diff
changeset
|
76 command = cmdutil.command(cmdtable) |
276
f26e9bc5f7fc
obsolete: use new-style command registration
Patrick Mezard <patrick@mezard.eu>
parents:
275
diff
changeset
|
77 @command('debugconvertobsolete', [], '') |
224 | 78 def cmddebugconvertobsolete(ui, repo): |
278
fa0b9b8a83c0
obsolete: add or fix debug commands help
Patrick Mezard <patrick@mezard.eu>
parents:
277
diff
changeset
|
79 """import markers from an .hg/obsolete-relations file""" |
224 | 80 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
|
81 err = 0 |
224 | 82 l = repo.lock() |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
83 some = False |
224 | 84 try: |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
85 unlink = [] |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
86 tr = repo.transaction('convert-obsolete') |
224 | 87 try: |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
88 repo._importoldobsolete = True |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
89 store = repo.obsstore |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
90 ### very first format |
224 | 91 try: |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
92 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
|
93 try: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
94 some = True |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
95 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
|
96 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
|
97 suc = bin(subhex) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
98 prec = bin(objhex) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
99 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
|
100 meta = { |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
101 '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
|
102 'user': ui.username(), |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
103 } |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
104 try: |
1061
f3867e60d072
compat: always call metadata as a keyword argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
519
diff
changeset
|
105 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
|
106 cnt += 1 |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
107 except ValueError: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
108 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
|
109 % (line)) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
110 err += 1 |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
111 finally: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
112 f.close() |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
113 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
|
114 except IOError: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
115 pass |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
116 ### second (json) format |
1465
777e5c369d99
compat: use svfs instead of sopener
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
1216
diff
changeset
|
117 data = repo.svfs.tryread('obsoletemarkers') |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
118 if data: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
119 some = True |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
120 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
|
121 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
|
122 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
|
123 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
|
124 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
|
125 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
|
126 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
|
127 try: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
128 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
|
129 except LOOKUP_ERRORS: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
130 pass |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
131 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
|
132 try: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
133 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
|
134 except LOOKUP_ERRORS: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
135 pass |
224 | 136 |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
137 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
|
138 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
|
139 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
|
140 try: |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
141 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
|
142 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
|
143 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
|
144 0, metadata=meta) |
341
7653f80fd7a4
obsolete: harden convertion from first format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
340
diff
changeset
|
145 cnt += 1 |
7653f80fd7a4
obsolete: harden convertion from first format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
340
diff
changeset
|
146 except ValueError: |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
147 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
|
148 % (oldobject, oldsubjects)) |
341
7653f80fd7a4
obsolete: harden convertion from first format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
340
diff
changeset
|
149 err += 1 |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
150 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
|
151 tr.close() |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
152 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
|
153 util.unlink(path) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
154 finally: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
155 tr.release() |
224 | 156 finally: |
157 del repo._importoldobsolete | |
158 l.release() | |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
159 if not some: |
1550
e47dda53a5c2
check-code: make obsolete.py comply with check-code
Laurent Charignon <lcharignon@fb.com>
parents:
1465
diff
changeset
|
160 ui.warn(_('nothing to do\n')) |
224 | 161 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
|
162 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
|
163 ui.write_err('%i conversion failed. check you graph!\n' % err) |