Mercurial > hg
comparison mercurial/dirstate.py @ 13032:e41e2b79883d
dirstate: warn on invalid parents rather than aborting
This allows more graceful recovery from some mangled dirstates
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Mon, 22 Nov 2010 12:43:31 -0600 |
parents | e255a5dc29e6 |
children | 6c375e07d673 |
comparison
equal
deleted
inserted
replaced
13031:3da456d0c885 | 13032:e41e2b79883d |
---|---|
34 return | 34 return |
35 del dirs[base] | 35 del dirs[base] |
36 | 36 |
37 class dirstate(object): | 37 class dirstate(object): |
38 | 38 |
39 def __init__(self, opener, ui, root): | 39 def __init__(self, opener, ui, root, validate): |
40 '''Create a new dirstate object. | 40 '''Create a new dirstate object. |
41 | 41 |
42 opener is an open()-like callable that can be used to open the | 42 opener is an open()-like callable that can be used to open the |
43 dirstate file; root is the root of the directory tracked by | 43 dirstate file; root is the root of the directory tracked by |
44 the dirstate. | 44 the dirstate. |
45 ''' | 45 ''' |
46 self._opener = opener | 46 self._opener = opener |
47 self._validate = validate | |
47 self._root = root | 48 self._root = root |
48 self._rootdir = os.path.join(root, '') | 49 self._rootdir = os.path.join(root, '') |
49 self._dirty = False | 50 self._dirty = False |
50 self._dirtypl = False | 51 self._dirtypl = False |
51 self._ui = ui | 52 self._ui = ui |
195 def __iter__(self): | 196 def __iter__(self): |
196 for x in sorted(self._map): | 197 for x in sorted(self._map): |
197 yield x | 198 yield x |
198 | 199 |
199 def parents(self): | 200 def parents(self): |
200 return self._pl | 201 return [self._validate(p) for p in self._pl] |
201 | 202 |
202 def branch(self): | 203 def branch(self): |
203 return self._branch | 204 return self._branch |
204 | 205 |
205 def setparents(self, p1, p2=nullid): | 206 def setparents(self, p1, p2=nullid): |