3 # |
3 # |
4 # This software may be used and distributed according to the terms of the |
4 # This software may be used and distributed according to the terms of the |
5 # GNU General Public License version 2 or any later version. |
5 # GNU General Public License version 2 or any later version. |
6 """Deprecated extension that formely introduces "Changeset Obsolescence". |
6 """Deprecated extension that formely introduces "Changeset Obsolescence". |
7 |
7 |
8 This concept is now partially in Mercurial core (starting with mercurial 2.3). The remaining logic have been grouped with the evolve extension. |
8 This concept is now partially in Mercurial core (starting with mercurial 2.3). |
|
9 The remaining logic have been grouped with the evolve extension. |
9 |
10 |
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. |
11 Some code cemains in this extensions to detect and convert prehistoric format |
|
12 of obsolete marker than early user may have create. Keep it enabled if you |
|
13 were such user. |
11 """ |
14 """ |
12 |
15 |
13 from mercurial import util |
16 from mercurial import util |
14 |
17 |
15 try: |
18 try: |
16 from mercurial import obsolete |
19 from mercurial import obsolete |
17 except ImportError: |
20 except ImportError: |
18 raise util.Abort('Obsolete extension requires Mercurial 2.3 (or later)') |
21 raise error.Abort('Obsolete extension requires Mercurial 2.3 (or later)') |
19 |
22 |
20 import sys |
23 import sys |
21 import json |
24 import json |
22 |
25 |
23 from mercurial import cmdutil |
26 from mercurial import cmdutil |
24 from mercurial import error |
27 from mercurial import error |
|
28 from mercurial.i18n import _ |
25 from mercurial.node import bin, nullid |
29 from mercurial.node import bin, nullid |
26 |
30 |
27 |
31 |
28 ##################################################################### |
32 ##################################################################### |
29 ### Older format management ### |
33 ### Older format management ### |
48 else: |
52 else: |
49 data = repo.opener.tryread('obsolete-relations') |
53 data = repo.opener.tryread('obsolete-relations') |
50 if not data: |
54 if not data: |
51 data = repo.svfs.tryread('obsoletemarkers') |
55 data = repo.svfs.tryread('obsoletemarkers') |
52 if data: |
56 if data: |
53 raise util.Abort('old format of obsolete marker detected!\n' |
57 raise error.Abort('old format of obsolete marker detected!\n' |
54 'run `hg debugconvertobsolete` once.') |
58 'run `hg debugconvertobsolete` once.') |
55 |
59 |
56 def _obsdeserialise(flike): |
60 def _obsdeserialise(flike): |
57 """read a file like object serialised with _obsserialise |
61 """read a file like object serialised with _obsserialise |
58 |
62 |
59 this desierialize into a {subject -> objects} mapping |
63 this desierialize into a {subject -> objects} mapping |
63 for line in flike: |
67 for line in flike: |
64 subhex, objhex = line.split() |
68 subhex, objhex = line.split() |
65 subnode = bin(subhex) |
69 subnode = bin(subhex) |
66 if subnode == nullid: |
70 if subnode == nullid: |
67 subnode = None |
71 subnode = None |
68 rels.setdefault( subnode, set()).add(bin(objhex)) |
72 rels.setdefault(subnode, set()).add(bin(objhex)) |
69 return rels |
73 return rels |
70 |
74 |
71 cmdtable = {} |
75 cmdtable = {} |
72 command = cmdutil.command(cmdtable) |
76 command = cmdutil.command(cmdtable) |
73 @command('debugconvertobsolete', [], '') |
77 @command('debugconvertobsolete', [], '') |