Mercurial > hg
comparison mercurial/filelog.py @ 39878:3e896b51aa5d
storageutil: move metadata parsing and packing from revlog (API)
Parsing and writing of revision text metadata is likely identical
across storage backends. Let's move the code out of revlog so we
don't need to import the revlog module in order to use it.
Differential Revision: https://phab.mercurial-scm.org/D4754
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 24 Sep 2018 14:31:31 -0700 |
parents | a269fa55467e |
children | 1b65fb4d43d6 |
comparison
equal
deleted
inserted
replaced
39877:f8eb71f9e3bd | 39878:3e896b51aa5d |
---|---|
12 repository, | 12 repository, |
13 revlog, | 13 revlog, |
14 ) | 14 ) |
15 from .utils import ( | 15 from .utils import ( |
16 interfaceutil, | 16 interfaceutil, |
17 storageutil, | |
17 ) | 18 ) |
18 | 19 |
19 @interfaceutil.implementer(repository.ifilestorage) | 20 @interfaceutil.implementer(repository.ifilestorage) |
20 class filelog(object): | 21 class filelog(object): |
21 def __init__(self, opener, path): | 22 def __init__(self, opener, path): |
118 s = t.index('\1\n', 2) | 119 s = t.index('\1\n', 2) |
119 return t[s + 2:] | 120 return t[s + 2:] |
120 | 121 |
121 def add(self, text, meta, transaction, link, p1=None, p2=None): | 122 def add(self, text, meta, transaction, link, p1=None, p2=None): |
122 if meta or text.startswith('\1\n'): | 123 if meta or text.startswith('\1\n'): |
123 text = revlog.packmeta(meta, text) | 124 text = storageutil.packmeta(meta, text) |
124 return self.addrevision(text, transaction, link, p1, p2) | 125 return self.addrevision(text, transaction, link, p1, p2) |
125 | 126 |
126 def renamed(self, node): | 127 def renamed(self, node): |
127 if self.parents(node)[0] != revlog.nullid: | 128 if self.parents(node)[0] != revlog.nullid: |
128 return False | 129 return False |
129 t = self.revision(node) | 130 t = self.revision(node) |
130 m = revlog.parsemeta(t)[0] | 131 m = storageutil.parsemeta(t)[0] |
131 # copy and copyrev occur in pairs. In rare cases due to bugs, | 132 # copy and copyrev occur in pairs. In rare cases due to bugs, |
132 # one can occur without the other. | 133 # one can occur without the other. |
133 if m and "copy" in m and "copyrev" in m: | 134 if m and "copy" in m and "copyrev" in m: |
134 return (m["copy"], revlog.bin(m["copyrev"])) | 135 return (m["copy"], revlog.bin(m["copyrev"])) |
135 return False | 136 return False |