Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/filelog.py @ 39885:1b65fb4d43d6
storageutil: new function for extracting metadata-less content from text
Other storage backends will want to do this.
I'm not concerned about Python function call overhead because I
expect self.revision() to dwarf the function call overhead time,
since self.revision() requires multiple function calls and may
involve decompression in the common case.
Differential Revision: https://phab.mercurial-scm.org/D4756
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Mon, 24 Sep 2018 14:54:28 -0700 |
parents | 3e896b51aa5d |
children | 2f80eaf38ed4 |
comparison
equal
deleted
inserted
replaced
39884:d269ddbf54f0 | 39885:1b65fb4d43d6 |
---|---|
111 | 111 |
112 def files(self): | 112 def files(self): |
113 return self._revlog.files() | 113 return self._revlog.files() |
114 | 114 |
115 def read(self, node): | 115 def read(self, node): |
116 t = self.revision(node) | 116 return storageutil.filtermetadata(self.revision(node)) |
117 if not t.startswith('\1\n'): | |
118 return t | |
119 s = t.index('\1\n', 2) | |
120 return t[s + 2:] | |
121 | 117 |
122 def add(self, text, meta, transaction, link, p1=None, p2=None): | 118 def add(self, text, meta, transaction, link, p1=None, p2=None): |
123 if meta or text.startswith('\1\n'): | 119 if meta or text.startswith('\1\n'): |
124 text = storageutil.packmeta(meta, text) | 120 text = storageutil.packmeta(meta, text) |
125 return self.addrevision(text, transaction, link, p1, p2) | 121 return self.addrevision(text, transaction, link, p1, p2) |