Mercurial > hg
changeset 34338:0c3e3810cdb6
dirstate: move parent reading to the dirstatemap class
As part of moving dirstate storage logic to a separate class, let's move the
function that reads the parents from the file. This will allow extensions to
write dirstate's that store the parents in other ways.
Differential Revision: https://phab.mercurial-scm.org/D758
author | Durham Goode <durham@fb.com> |
---|---|
date | Tue, 26 Sep 2017 03:56:20 -0700 |
parents | c36c3fa7d35b |
children | ec769bba34d3 |
files | mercurial/dirstate.py |
diffstat | 1 files changed, 15 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/dirstate.py Tue Sep 26 03:56:20 2017 -0700 +++ b/mercurial/dirstate.py Tue Sep 26 03:56:20 2017 -0700 @@ -186,19 +186,7 @@ @propertycache def _pl(self): - try: - fp = self._map._opendirstatefile() - st = fp.read(40) - fp.close() - l = len(st) - if l == 40: - return st[:20], st[20:40] - elif l > 0 and l < 40: - raise error.Abort(_('working directory state appears damaged!')) - except IOError as err: - if err.errno != errno.ENOENT: - raise - return [nullid, nullid] + return self._map.parents() @propertycache def _dirs(self): @@ -1381,3 +1369,17 @@ self._pendingmode = mode return fp + def parents(self): + try: + fp = self._opendirstatefile() + st = fp.read(40) + fp.close() + l = len(st) + if l == 40: + return st[:20], st[20:40] + elif l > 0 and l < 40: + raise error.Abort(_('working directory state appears damaged!')) + except IOError as err: + if err.errno != errno.ENOENT: + raise + return [nullid, nullid]