Mercurial > hg
annotate mercurial/obsolete.py @ 17125:95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
This is the second step toward incremental writing of marker inside a
transaction. The obsstore file is now handled append only.
Header writing have been extracted from _writemarkers.
Because the _writemarkers method have been dropped, the push code
directly reuse the serialised content of local repo `listkeys`. This
is not very pretty, but this part of the protocol still need major
improvement anyway.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Wed, 04 Jul 2012 02:02:48 +0200 |
parents | f1b7683f3f95 |
children | 8fa8717b47b6 |
rev | line source |
---|---|
17070
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
1 # obsolete.py - obsolete markers handling |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
2 # |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
3 # Copyright 2012 Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
4 # Logilab SA <contact@logilab.fr> |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
5 # |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
6 # This software may be used and distributed according to the terms of the |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
7 # GNU General Public License version 2 or any later version. |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
8 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
9 """Obsolete markers handling |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
10 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
11 An obsolete marker maps an old changeset to a list of new |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
12 changesets. If the list of new changesets is empty, the old changeset |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
13 is said to be "killed". Otherwise, the old changeset is being |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
14 "replaced" by the new changesets. |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
15 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
16 Obsolete markers can be used to record and distribute changeset graph |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
17 transformations performed by history rewriting operations, and help |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
18 building new tools to reconciliate conflicting rewriting actions. To |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
19 facilitate conflicts resolution, markers include various annotations |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
20 besides old and news changeset identifiers, such as creation date or |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
21 author name. |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
22 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
23 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
24 Format |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
25 ------ |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
26 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
27 Markers are stored in an append-only file stored in |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
28 '.hg/store/obsstore'. |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
29 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
30 The file starts with a version header: |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
31 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
32 - 1 unsigned byte: version number, starting at zero. |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
33 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
34 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
35 The header is followed by the markers. Each marker is made of: |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
36 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
37 - 1 unsigned byte: number of new changesets "R", could be zero. |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
38 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
39 - 1 unsigned 32-bits integer: metadata size "M" in bytes. |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
40 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
41 - 1 byte: a bit field. It is reserved for flags used in obsolete |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
42 markers common operations, to avoid repeated decoding of metadata |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
43 entries. |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
44 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
45 - 20 bytes: obsoleted changeset identifier. |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
46 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
47 - N*20 bytes: new changesets identifiers. |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
48 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
49 - M bytes: metadata as a sequence of nul-terminated strings. Each |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
50 string contains a key and a value, separated by a color ':', without |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
51 additional encoding. Keys cannot contain '\0' or ':' and values |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
52 cannot contain '\0'. |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
53 """ |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
54 import struct |
17075
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
55 from mercurial import util, base85 |
17070
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
56 from i18n import _ |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
57 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
58 _pack = struct.pack |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
59 _unpack = struct.unpack |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
60 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
61 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
62 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
63 # data used for parsing and writing |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
64 _fmversion = 0 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
65 _fmfixed = '>BIB20s' |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
66 _fmnode = '20s' |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
67 _fmfsize = struct.calcsize(_fmfixed) |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
68 _fnodesize = struct.calcsize(_fmnode) |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
69 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
70 def _readmarkers(data): |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
71 """Read and enumerate markers from raw data""" |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
72 off = 0 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
73 diskversion = _unpack('>B', data[off:off + 1])[0] |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
74 off += 1 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
75 if diskversion != _fmversion: |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
76 raise util.Abort(_('parsing obsolete marker: unknown version %r') |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
77 % diskversion) |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
78 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
79 # Loop on markers |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
80 l = len(data) |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
81 while off + _fmfsize <= l: |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
82 # read fixed part |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
83 cur = data[off:off + _fmfsize] |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
84 off += _fmfsize |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
85 nbsuc, mdsize, flags, pre = _unpack(_fmfixed, cur) |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
86 # read replacement |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
87 sucs = () |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
88 if nbsuc: |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
89 s = (_fnodesize * nbsuc) |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
90 cur = data[off:off + s] |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
91 sucs = _unpack(_fmnode * nbsuc, cur) |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
92 off += s |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
93 # read metadata |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
94 # (metadata will be decoded on demand) |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
95 metadata = data[off:off + mdsize] |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
96 if len(metadata) != mdsize: |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
97 raise util.Abort(_('parsing obsolete marker: metadata is too ' |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
98 'short, %d bytes expected, got %d') |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
99 % (len(metadata), mdsize)) |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
100 off += mdsize |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
101 yield (pre, sucs, flags, metadata) |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
102 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
103 def encodemeta(meta): |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
104 """Return encoded metadata string to string mapping. |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
105 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
106 Assume no ':' in key and no '\0' in both key and value.""" |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
107 for key, value in meta.iteritems(): |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
108 if ':' in key or '\0' in key: |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
109 raise ValueError("':' and '\0' are forbidden in metadata key'") |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
110 if '\0' in value: |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
111 raise ValueError("':' are forbidden in metadata value'") |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
112 return '\0'.join(['%s:%s' % (k, meta[k]) for k in sorted(meta)]) |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
113 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
114 def decodemeta(data): |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
115 """Return string to string dictionary from encoded version.""" |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
116 d = {} |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
117 for l in data.split('\0'): |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
118 if l: |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
119 key, value = l.split(':') |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
120 d[key] = value |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
121 return d |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
122 |
17072
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
123 class marker(object): |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
124 """Wrap obsolete marker raw data""" |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
125 |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
126 def __init__(self, repo, data): |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
127 # the repo argument will be used to create changectx in later version |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
128 self._repo = repo |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
129 self._data = data |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
130 self._decodedmeta = None |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
131 |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
132 def precnode(self): |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
133 """Precursor changeset node identifier""" |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
134 return self._data[0] |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
135 |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
136 def succnodes(self): |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
137 """List of successor changesets node identifiers""" |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
138 return self._data[1] |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
139 |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
140 def metadata(self): |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
141 """Decoded metadata dictionary""" |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
142 if self._decodedmeta is None: |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
143 self._decodedmeta = decodemeta(self._data[3]) |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
144 return self._decodedmeta |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
145 |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
146 def date(self): |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
147 """Creation date as (unixtime, offset)""" |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
148 parts = self.metadata()['date'].split(' ') |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
149 return (float(parts[0]), int(parts[1])) |
517af63ba382
obsolete: helper class to access obsolete marker data
Pierre-Yves.David@ens-lyon.org
parents:
17071
diff
changeset
|
150 |
17070
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
151 class obsstore(object): |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
152 """Store obsolete markers |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
153 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
154 Markers can be accessed with two mappings: |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
155 - precursors: old -> set(new) |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
156 - successors: new -> set(old) |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
157 """ |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
158 |
17124
f1b7683f3f95
obsolete: move obsolete markers read/write logic to obsstore object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17117
diff
changeset
|
159 def __init__(self, sopener): |
17070
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
160 self._all = [] |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
161 # new markers to serialize |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
162 self._new = [] |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
163 self.precursors = {} |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
164 self.successors = {} |
17124
f1b7683f3f95
obsolete: move obsolete markers read/write logic to obsstore object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17117
diff
changeset
|
165 self.sopener = sopener |
f1b7683f3f95
obsolete: move obsolete markers read/write logic to obsstore object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17117
diff
changeset
|
166 data = sopener.tryread('obsstore') |
f1b7683f3f95
obsolete: move obsolete markers read/write logic to obsstore object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17117
diff
changeset
|
167 if data: |
f1b7683f3f95
obsolete: move obsolete markers read/write logic to obsstore object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17117
diff
changeset
|
168 for marker in _readmarkers(data): |
f1b7683f3f95
obsolete: move obsolete markers read/write logic to obsstore object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17117
diff
changeset
|
169 self._load(marker) |
17070
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
170 |
17073
3a79a5682af1
obsolete: add easy way to iterate over obsolete marker object
Pierre-Yves.David@ens-lyon.org
parents:
17072
diff
changeset
|
171 def __iter__(self): |
3a79a5682af1
obsolete: add easy way to iterate over obsolete marker object
Pierre-Yves.David@ens-lyon.org
parents:
17072
diff
changeset
|
172 return iter(self._all) |
3a79a5682af1
obsolete: add easy way to iterate over obsolete marker object
Pierre-Yves.David@ens-lyon.org
parents:
17072
diff
changeset
|
173 |
17075
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
174 def __nonzero__(self): |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
175 return bool(self._all) |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
176 |
17071
11f26e2669aa
command: creation of obsolete marker
Pierre-Yves.David@ens-lyon.org
parents:
17070
diff
changeset
|
177 def create(self, prec, succs=(), flag=0, metadata=None): |
11f26e2669aa
command: creation of obsolete marker
Pierre-Yves.David@ens-lyon.org
parents:
17070
diff
changeset
|
178 """obsolete: add a new obsolete marker |
11f26e2669aa
command: creation of obsolete marker
Pierre-Yves.David@ens-lyon.org
parents:
17070
diff
changeset
|
179 |
11f26e2669aa
command: creation of obsolete marker
Pierre-Yves.David@ens-lyon.org
parents:
17070
diff
changeset
|
180 * ensuring it is hashable |
11f26e2669aa
command: creation of obsolete marker
Pierre-Yves.David@ens-lyon.org
parents:
17070
diff
changeset
|
181 * check mandatory metadata |
11f26e2669aa
command: creation of obsolete marker
Pierre-Yves.David@ens-lyon.org
parents:
17070
diff
changeset
|
182 * encode metadata |
11f26e2669aa
command: creation of obsolete marker
Pierre-Yves.David@ens-lyon.org
parents:
17070
diff
changeset
|
183 """ |
11f26e2669aa
command: creation of obsolete marker
Pierre-Yves.David@ens-lyon.org
parents:
17070
diff
changeset
|
184 if metadata is None: |
11f26e2669aa
command: creation of obsolete marker
Pierre-Yves.David@ens-lyon.org
parents:
17070
diff
changeset
|
185 metadata = {} |
11f26e2669aa
command: creation of obsolete marker
Pierre-Yves.David@ens-lyon.org
parents:
17070
diff
changeset
|
186 if len(prec) != 20: |
11f26e2669aa
command: creation of obsolete marker
Pierre-Yves.David@ens-lyon.org
parents:
17070
diff
changeset
|
187 raise ValueError(prec) |
11f26e2669aa
command: creation of obsolete marker
Pierre-Yves.David@ens-lyon.org
parents:
17070
diff
changeset
|
188 for succ in succs: |
11f26e2669aa
command: creation of obsolete marker
Pierre-Yves.David@ens-lyon.org
parents:
17070
diff
changeset
|
189 if len(succ) != 20: |
17117
217bfb10e6db
obsolete: fix error message at marker creation
Pierre-Yves David <pierre-yves.david@logilab.fr>
parents:
17076
diff
changeset
|
190 raise ValueError(succ) |
17071
11f26e2669aa
command: creation of obsolete marker
Pierre-Yves.David@ens-lyon.org
parents:
17070
diff
changeset
|
191 marker = (str(prec), tuple(succs), int(flag), encodemeta(metadata)) |
11f26e2669aa
command: creation of obsolete marker
Pierre-Yves.David@ens-lyon.org
parents:
17070
diff
changeset
|
192 self.add(marker) |
11f26e2669aa
command: creation of obsolete marker
Pierre-Yves.David@ens-lyon.org
parents:
17070
diff
changeset
|
193 |
17070
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
194 def add(self, marker): |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
195 """Add a new marker to the store |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
196 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
197 This marker still needs to be written to disk""" |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
198 self._new.append(marker) |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
199 self._load(marker) |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
200 |
17075
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
201 def mergemarkers(self, data): |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
202 other = set(_readmarkers(data)) |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
203 local = set(self._all) |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
204 new = other - local |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
205 for marker in new: |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
206 self.add(marker) |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
207 |
17124
f1b7683f3f95
obsolete: move obsolete markers read/write logic to obsstore object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17117
diff
changeset
|
208 def flushmarkers(self): |
f1b7683f3f95
obsolete: move obsolete markers read/write logic to obsstore object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17117
diff
changeset
|
209 """Write all markers on disk |
17070
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
210 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
211 After this operation, "new" markers are considered "known".""" |
17125
95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17124
diff
changeset
|
212 # XXX: transaction logic should be used |
17124
f1b7683f3f95
obsolete: move obsolete markers read/write logic to obsstore object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17117
diff
changeset
|
213 if self._new: |
17125
95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17124
diff
changeset
|
214 f = self.sopener('obsstore', 'ab') |
17124
f1b7683f3f95
obsolete: move obsolete markers read/write logic to obsstore object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17117
diff
changeset
|
215 try: |
17125
95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17124
diff
changeset
|
216 if f.tell() == 0: |
95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17124
diff
changeset
|
217 # plain new obsstore |
95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17124
diff
changeset
|
218 f.write(_pack('>B', _fmversion)) |
95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17124
diff
changeset
|
219 _writemarkers(f.write, self._new) |
17124
f1b7683f3f95
obsolete: move obsolete markers read/write logic to obsstore object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17117
diff
changeset
|
220 f.close() |
f1b7683f3f95
obsolete: move obsolete markers read/write logic to obsstore object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17117
diff
changeset
|
221 self._new[:] = [] |
f1b7683f3f95
obsolete: move obsolete markers read/write logic to obsstore object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17117
diff
changeset
|
222 except: # re-raises |
f1b7683f3f95
obsolete: move obsolete markers read/write logic to obsstore object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17117
diff
changeset
|
223 f.discard() |
f1b7683f3f95
obsolete: move obsolete markers read/write logic to obsstore object
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17117
diff
changeset
|
224 raise |
17070
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
225 |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
226 def _load(self, marker): |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
227 self._all.append(marker) |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
228 pre, sucs = marker[:2] |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
229 self.precursors.setdefault(pre, set()).add(marker) |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
230 for suc in sucs: |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
231 self.successors.setdefault(suc, set()).add(marker) |
ad0d6c2b3279
obsolete: introduction of obsolete markers
Pierre-Yves.David@ens-lyon.org
parents:
diff
changeset
|
232 |
17125
95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17124
diff
changeset
|
233 def _writemarkers(write, markers): |
95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17124
diff
changeset
|
234 # Kept separate from flushmarkers(), it will be reused for |
95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17124
diff
changeset
|
235 # markers exchange. |
95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17124
diff
changeset
|
236 for marker in markers: |
95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17124
diff
changeset
|
237 pre, sucs, flags, metadata = marker |
95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17124
diff
changeset
|
238 nbsuc = len(sucs) |
95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17124
diff
changeset
|
239 format = _fmfixed + (_fmnode * nbsuc) |
95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17124
diff
changeset
|
240 data = [nbsuc, len(metadata), flags, pre] |
95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17124
diff
changeset
|
241 data.extend(sucs) |
95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17124
diff
changeset
|
242 write(_pack(format, *data)) |
95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17124
diff
changeset
|
243 write(metadata) |
17075
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
244 |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
245 def listmarkers(repo): |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
246 """List markers over pushkey""" |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
247 if not repo.obsstore: |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
248 return {} |
17125
95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17124
diff
changeset
|
249 data = [_pack('>B', _fmversion)] |
95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17124
diff
changeset
|
250 _writemarkers(data.append, repo.obsstore) |
95d785ccb4e5
obsolete: append new markers to obsstore file instead of rewriting everything
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents:
17124
diff
changeset
|
251 return {'dump': base85.b85encode(''.join(data))} |
17073
3a79a5682af1
obsolete: add easy way to iterate over obsolete marker object
Pierre-Yves.David@ens-lyon.org
parents:
17072
diff
changeset
|
252 |
17075
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
253 def pushmarker(repo, key, old, new): |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
254 """Push markers over pushkey""" |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
255 if key != 'dump': |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
256 repo.ui.warn(_('unknown key: %r') % key) |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
257 return 0 |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
258 if old: |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
259 repo.ui.warn(_('unexpected old value') % key) |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
260 return 0 |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
261 data = base85.b85decode(new) |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
262 lock = repo.lock() |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
263 try: |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
264 repo.obsstore.mergemarkers(data) |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
265 return 1 |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
266 finally: |
28ed1c4511ce
obsolete: exchange obsolete marker over pushkey
Pierre-Yves.David@ens-lyon.org
parents:
17073
diff
changeset
|
267 lock.release() |
17073
3a79a5682af1
obsolete: add easy way to iterate over obsolete marker object
Pierre-Yves.David@ens-lyon.org
parents:
17072
diff
changeset
|
268 |
3a79a5682af1
obsolete: add easy way to iterate over obsolete marker object
Pierre-Yves.David@ens-lyon.org
parents:
17072
diff
changeset
|
269 def allmarkers(repo): |
3a79a5682af1
obsolete: add easy way to iterate over obsolete marker object
Pierre-Yves.David@ens-lyon.org
parents:
17072
diff
changeset
|
270 """all obsolete markers known in a repository""" |
3a79a5682af1
obsolete: add easy way to iterate over obsolete marker object
Pierre-Yves.David@ens-lyon.org
parents:
17072
diff
changeset
|
271 for markerdata in repo.obsstore: |
3a79a5682af1
obsolete: add easy way to iterate over obsolete marker object
Pierre-Yves.David@ens-lyon.org
parents:
17072
diff
changeset
|
272 yield marker(repo, markerdata) |
3a79a5682af1
obsolete: add easy way to iterate over obsolete marker object
Pierre-Yves.David@ens-lyon.org
parents:
17072
diff
changeset
|
273 |
17076
75f4180509a4
obsolete: function and method to access some obsolete data
Pierre-Yves.David@ens-lyon.org
parents:
17075
diff
changeset
|
274 def precursormarkers(ctx): |
75f4180509a4
obsolete: function and method to access some obsolete data
Pierre-Yves.David@ens-lyon.org
parents:
17075
diff
changeset
|
275 """obsolete marker making this changeset obsolete""" |
75f4180509a4
obsolete: function and method to access some obsolete data
Pierre-Yves.David@ens-lyon.org
parents:
17075
diff
changeset
|
276 for data in ctx._repo.obsstore.precursors.get(ctx.node(), ()): |
75f4180509a4
obsolete: function and method to access some obsolete data
Pierre-Yves.David@ens-lyon.org
parents:
17075
diff
changeset
|
277 yield marker(ctx._repo, data) |
75f4180509a4
obsolete: function and method to access some obsolete data
Pierre-Yves.David@ens-lyon.org
parents:
17075
diff
changeset
|
278 |
75f4180509a4
obsolete: function and method to access some obsolete data
Pierre-Yves.David@ens-lyon.org
parents:
17075
diff
changeset
|
279 def successormarkers(ctx): |
75f4180509a4
obsolete: function and method to access some obsolete data
Pierre-Yves.David@ens-lyon.org
parents:
17075
diff
changeset
|
280 """obsolete marker marking this changeset as a successors""" |
75f4180509a4
obsolete: function and method to access some obsolete data
Pierre-Yves.David@ens-lyon.org
parents:
17075
diff
changeset
|
281 for data in ctx._repo.obsstore.successors.get(ctx.node(), ()): |
75f4180509a4
obsolete: function and method to access some obsolete data
Pierre-Yves.David@ens-lyon.org
parents:
17075
diff
changeset
|
282 yield marker(ctx._repo, data) |
75f4180509a4
obsolete: function and method to access some obsolete data
Pierre-Yves.David@ens-lyon.org
parents:
17075
diff
changeset
|
283 |