Mercurial > hg
changeset 13240:e5060aa22043
filelog: move metadata parsing to a helper function
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 06 Jan 2011 17:04:47 -0600 |
parents | 12ed25f39d0b |
children | bb43a9abca80 |
files | mercurial/filelog.py |
diffstat | 1 files changed, 13 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/mercurial/filelog.py Thu Jan 06 17:04:41 2011 -0600 +++ b/mercurial/filelog.py Thu Jan 06 17:04:47 2011 -0600 @@ -7,6 +7,17 @@ import revlog +def _parsemeta(text): + if not text.startswith('\1\n'): + return {} + s = text.index('\1\n', 2) + mt = text[2:s] + m = {} + for l in mt.splitlines(): + k, v = l.split(": ", 1) + m[k] = v + return m + class filelog(revlog.revlog): def __init__(self, opener, path): revlog.revlog.__init__(self, opener, @@ -19,18 +30,6 @@ s = t.index('\1\n', 2) return t[s + 2:] - def _readmeta(self, node): - t = self.revision(node) - if not t.startswith('\1\n'): - return {} - s = t.index('\1\n', 2) - mt = t[2:s] - m = {} - for l in mt.splitlines(): - k, v = l.split(": ", 1) - m[k] = v - return m - def add(self, text, meta, transaction, link, p1=None, p2=None): if meta or text.startswith('\1\n'): mt = ["%s: %s\n" % (k, v) for k, v in sorted(meta.iteritems())] @@ -40,7 +39,8 @@ def renamed(self, node): if self.parents(node)[0] != revlog.nullid: return False - m = self._readmeta(node) + t = self.revision(node) + m = _parsemeta(t) if m and "copy" in m: return (m["copy"], revlog.bin(m["copyrev"])) return False