Mercurial > evolve
annotate hgext/obsolete.py @ 1364:f00d91365ab9
evolve: make uncommit respect allowunsable
Before this patch, the uncommit command was performing the same way regardless
of the value of experimental.evolution.
With this patch if the configuration does not allow unstability, uncommit won't
create instability.
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Wed, 20 May 2015 12:46:13 -0700 |
parents | a307eea46f96 |
children | 777e5c369d99 |
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. |
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 |
aa1255c2ac8f
obsolete: move version checks at the start of the file
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
432
diff
changeset
|
17 except ImportError: |
458
5d47d854716e
obsolete: fix indentation in obsolete import block
Patrick Mezard <patrick@mezard.eu>
parents:
457
diff
changeset
|
18 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
|
19 |
439
6cff54825233
obsolete: reorder import
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
438
diff
changeset
|
20 import sys |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
21 import json |
354
bd26eb9714fb
obsolete: Detect conflicting changeset!
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
351
diff
changeset
|
22 |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
23 from mercurial import cmdutil |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
24 from mercurial import error |
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
25 from mercurial.node import bin, nullid |
39 | 26 |
44
b243c10a5fbe
Add pushkey support for pull and push
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
43
diff
changeset
|
27 |
430
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
28 ##################################################################### |
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
29 ### Older format management ### |
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
30 ##################################################################### |
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
|
31 |
430
07db1d511faf
obsolete: move old format stuff at the end
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
429
diff
changeset
|
32 # 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
|
33 # 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
|
34 |
32
c27491be4431
obsolet: basic support (hide changeset)
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
diff
changeset
|
35 |
491
6989d8fe4ed2
merge evolve and obsolete
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
490
diff
changeset
|
36 def reposetup(ui, repo): |
459
3477326461e3
obsolete: more typos and cleanup
Patrick Mezard <patrick@mezard.eu>
parents:
458
diff
changeset
|
37 """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
|
38 """ |
429
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
39 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
|
40 return |
1216
a307eea46f96
oldobsolete: remove use of obsolete._enabled
Durham Goode <durham@fb.com>
parents:
1061
diff
changeset
|
41 evolveopts = ui.configlist('experimental', 'evolution') |
a307eea46f96
oldobsolete: remove use of obsolete._enabled
Durham Goode <durham@fb.com>
parents:
1061
diff
changeset
|
42 if not evolveopts: |
a307eea46f96
oldobsolete: remove use of obsolete._enabled
Durham Goode <durham@fb.com>
parents:
1061
diff
changeset
|
43 evolveopts = 'all' |
a307eea46f96
oldobsolete: remove use of obsolete._enabled
Durham Goode <durham@fb.com>
parents:
1061
diff
changeset
|
44 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
|
45 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
|
46 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
|
47 break |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
48 else: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
49 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
|
50 if not data: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
51 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
|
52 if data: |
079b231b8ea4
obsolete: introduce an extension helper and use it
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
428
diff
changeset
|
53 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
|
54 'run `hg debugconvertobsolete` once.') |
70
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
55 |
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
56 def _obsdeserialise(flike): |
74
c7dd26dec7fc
[obsolete] update docstring
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
73
diff
changeset
|
57 """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
|
58 |
454
4e34a723115b
obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
453
diff
changeset
|
59 this desierialize into a {subject -> objects} mapping |
4e34a723115b
obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
453
diff
changeset
|
60 |
4e34a723115b
obsolete: more comment
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
453
diff
changeset
|
61 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
|
62 rels = {} |
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
63 for line in flike: |
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
64 subhex, objhex = line.split() |
80
5d029a358252
[obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
79
diff
changeset
|
65 subnode = bin(subhex) |
5d029a358252
[obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
79
diff
changeset
|
66 if subnode == nullid: |
5d029a358252
[obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
79
diff
changeset
|
67 subnode = None |
5d029a358252
[obsolete] add kill support
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
79
diff
changeset
|
68 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
|
69 return rels |
af4f7ef0a3c1
[obsolete] extract serialization logic.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
69
diff
changeset
|
70 |
441
d702f0d26c6a
obsolete: remove debugsuccessors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
440
diff
changeset
|
71 cmdtable = {} |
d702f0d26c6a
obsolete: remove debugsuccessors
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
440
diff
changeset
|
72 command = cmdutil.command(cmdtable) |
276
f26e9bc5f7fc
obsolete: use new-style command registration
Patrick Mezard <patrick@mezard.eu>
parents:
275
diff
changeset
|
73 @command('debugconvertobsolete', [], '') |
224 | 74 def cmddebugconvertobsolete(ui, repo): |
278
fa0b9b8a83c0
obsolete: add or fix debug commands help
Patrick Mezard <patrick@mezard.eu>
parents:
277
diff
changeset
|
75 """import markers from an .hg/obsolete-relations file""" |
224 | 76 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
|
77 err = 0 |
224 | 78 l = repo.lock() |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
79 some = False |
224 | 80 try: |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
81 unlink = [] |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
82 tr = repo.transaction('convert-obsolete') |
224 | 83 try: |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
84 repo._importoldobsolete = True |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
85 store = repo.obsstore |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
86 ### very first format |
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 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
|
89 try: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
90 some = True |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
91 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
|
92 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
|
93 suc = bin(subhex) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
94 prec = bin(objhex) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
95 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
|
96 meta = { |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
97 '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
|
98 'user': ui.username(), |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
99 } |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
100 try: |
1061
f3867e60d072
compat: always call metadata as a keyword argument
Pierre-Yves David <pierre-yves.david@fb.com>
parents:
519
diff
changeset
|
101 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
|
102 cnt += 1 |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
103 except ValueError: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
104 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
|
105 % (line)) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
106 err += 1 |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
107 finally: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
108 f.close() |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
109 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
|
110 except IOError: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
111 pass |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
112 ### second (json) format |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
113 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
|
114 if data: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
115 some = True |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
116 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
|
117 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
|
118 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
|
119 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
|
120 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
|
121 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
|
122 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
|
123 try: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
124 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
|
125 except LOOKUP_ERRORS: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
126 pass |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
127 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
|
128 try: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
129 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
|
130 except LOOKUP_ERRORS: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
131 pass |
224 | 132 |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
133 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
|
134 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
|
135 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
|
136 try: |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
137 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
|
138 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
|
139 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
|
140 0, metadata=meta) |
341
7653f80fd7a4
obsolete: harden convertion from first format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
340
diff
changeset
|
141 cnt += 1 |
7653f80fd7a4
obsolete: harden convertion from first format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
340
diff
changeset
|
142 except ValueError: |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
143 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
|
144 % (oldobject, oldsubjects)) |
341
7653f80fd7a4
obsolete: harden convertion from first format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
340
diff
changeset
|
145 err += 1 |
361
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
146 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
|
147 tr.close() |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
148 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
|
149 util.unlink(path) |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
150 finally: |
ac7969043677
obsolete: adapt to core: marker are written in transaction now
Pierre-Yves.David@ens-lyon.org
parents:
360
diff
changeset
|
151 tr.release() |
224 | 152 finally: |
153 del repo._importoldobsolete | |
154 l.release() | |
334
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
155 if not some: |
fb83210bce32
obsolete: move to official binary format
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
332
diff
changeset
|
156 ui.warn('nothing to do\n') |
224 | 157 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
|
158 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
|
159 ui.write_err('%i conversion failed. check you graph!\n' % err) |