Mercurial > public > mercurial-scm > hg
comparison mercurial/filelog.py @ 37833:6614cac550ae stable 4.6
filelog: don't crash on invalid copy metadata (issue5748)
"copy" and "copyrev" are both supposed to appear next to each other.
However, a user report demonstrated a crash that indicates that
something in the wild is producing "copy" without "copyrev"
(probably `hg convert`).
While we should definitely fix the source of the bad metadata,
the bad code causing the crash is already in the wild and who knows
how many repositories are impacted. So let's be more defensive
when accessing the file revision metadata.
author | Gregory Szorc <gregory.szorc@gmail.com> |
---|---|
date | Thu, 30 Nov 2017 21:19:46 -0500 |
parents | 856f381ad74b |
children | 93777d16a25d |
comparison
equal
deleted
inserted
replaced
37832:6169d95dce3b | 37833:6614cac550ae |
---|---|
133 def renamed(self, node): | 133 def renamed(self, node): |
134 if self.parents(node)[0] != revlog.nullid: | 134 if self.parents(node)[0] != revlog.nullid: |
135 return False | 135 return False |
136 t = self.revision(node) | 136 t = self.revision(node) |
137 m = revlog.parsemeta(t)[0] | 137 m = revlog.parsemeta(t)[0] |
138 if m and "copy" in m: | 138 # copy and copyrev occur in pairs. In rare cases due to bugs, |
139 # one can occur without the other. | |
140 if m and "copy" in m and "copyrev" in m: | |
139 return (m["copy"], revlog.bin(m["copyrev"])) | 141 return (m["copy"], revlog.bin(m["copyrev"])) |
140 return False | 142 return False |
141 | 143 |
142 def size(self, rev): | 144 def size(self, rev): |
143 """return the size of a given revision""" | 145 """return the size of a given revision""" |