Mercurial > public > mercurial-scm > hg
comparison mercurial/filelog.py @ 40005:1d97a332c6d9
storageutil: extract copy metadata retrieval out of filelog
As part of implementing an alternate storage backend, I found myself
reinventing this wheel.
Let's create a utility function for doing the work.
Differential Revision: https://phab.mercurial-scm.org/D4800
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Fri, 28 Sep 2018 11:37:49 -0700 |
parents | 0e8836be9541 |
children | 422beffd71ba |
comparison
equal
deleted
inserted
replaced
40004:fa3dc85a747e | 40005:1d97a332c6d9 |
---|---|
113 if meta or text.startswith('\1\n'): | 113 if meta or text.startswith('\1\n'): |
114 text = storageutil.packmeta(meta, text) | 114 text = storageutil.packmeta(meta, text) |
115 return self.addrevision(text, transaction, link, p1, p2) | 115 return self.addrevision(text, transaction, link, p1, p2) |
116 | 116 |
117 def renamed(self, node): | 117 def renamed(self, node): |
118 if self.parents(node)[0] != revlog.nullid: | 118 return storageutil.filerevisioncopied(self, node) |
119 return False | |
120 t = self.revision(node) | |
121 m = storageutil.parsemeta(t)[0] | |
122 # copy and copyrev occur in pairs. In rare cases due to bugs, | |
123 # one can occur without the other. | |
124 if m and "copy" in m and "copyrev" in m: | |
125 return (m["copy"], revlog.bin(m["copyrev"])) | |
126 return False | |
127 | 119 |
128 def size(self, rev): | 120 def size(self, rev): |
129 """return the size of a given revision""" | 121 """return the size of a given revision""" |
130 | 122 |
131 # for revisions with renames, we have to go the slow way | 123 # for revisions with renames, we have to go the slow way |