Mercurial > hg
comparison mercurial/obsolete.py @ 17774:0496d4f73cf4
obsolete: cheap detection of nullid as successors
Nullid as successors create multiple issues:
- Nullid revnum is -1, confusing algorithm that use revnum unless you add
special handling in all of them.
- Nullid confuses "divergent" changeset detection and resolution. As you can't
add any successors to Nullid without being in even more troubles
Fortunately, there is no good reason to use nullid as a successor. The only
sensible meaning of "succeed by nullid" is "dropped" and this meaning is already
covered by obsolescence marker with empty successors set.
However, letting some nullid successors to slip in may cause terrible damage in
such algorithm difficult to debug. So I prefer to perform and clear detection of
of such pathological changeset. We could be much smarter by cleaning up nullid
successors on the fly but it would be much for expensive. As core Mercurial does
not create any such changeset, I think it is fine to just abort when suspicious
situation is detected.
Earlier experimental version created such changesets, so there are some out
there. The evolve extension added the necessary logic to clean up its mess.
author | Pierre-Yves David <pierre-yves.david@logilab.fr> |
---|---|
date | Mon, 15 Oct 2012 00:12:06 +0200 |
parents | 31f32a96e1e3 |
children | 13744acc4ad7 |
comparison
equal
deleted
inserted
replaced
17773:434e5bd615fc | 17774:0496d4f73cf4 |
---|---|
50 string contains a key and a value, separated by a color ':', without | 50 string contains a key and a value, separated by a color ':', without |
51 additional encoding. Keys cannot contain '\0' or ':' and values | 51 additional encoding. Keys cannot contain '\0' or ':' and values |
52 cannot contain '\0'. | 52 cannot contain '\0'. |
53 """ | 53 """ |
54 import struct | 54 import struct |
55 import util, base85 | 55 import util, base85, node |
56 from i18n import _ | 56 from i18n import _ |
57 | 57 |
58 _pack = struct.pack | 58 _pack = struct.pack |
59 _unpack = struct.unpack | 59 _unpack = struct.unpack |
60 | 60 |
235 self._all.append(mark) | 235 self._all.append(mark) |
236 pre, sucs = mark[:2] | 236 pre, sucs = mark[:2] |
237 self.precursors.setdefault(pre, set()).add(mark) | 237 self.precursors.setdefault(pre, set()).add(mark) |
238 for suc in sucs: | 238 for suc in sucs: |
239 self.successors.setdefault(suc, set()).add(mark) | 239 self.successors.setdefault(suc, set()).add(mark) |
240 if node.nullid in self.successors: | |
241 raise util.Abort(_('bad obsolescence marker detected: ' | |
242 'invalid successors nullid')) | |
240 | 243 |
241 def _encodemarkers(markers, addheader=False): | 244 def _encodemarkers(markers, addheader=False): |
242 # Kept separate from flushmarkers(), it will be reused for | 245 # Kept separate from flushmarkers(), it will be reused for |
243 # markers exchange. | 246 # markers exchange. |
244 if addheader: | 247 if addheader: |