revlog: forbid revdiff revisions with non-zero flags

Summary:
Calling revdiff with non-zero flags is a sign of a hard-to-debug
error. Raise ProgrammingError in this case.

The change is straightforward. Apply it to both shallow and full
repos.

Reviewed By: DurhamG

Differential Revision: D6910080

fbshipit-source-id: cbcf1a444de90e104867cc9f1525629b7edda851
This commit is contained in:
Jun Wu 2018-02-06 14:18:35 -08:00 committed by Saurabh Singh
parent d76d41a0b2
commit a226ef4969
2 changed files with 7 additions and 0 deletions

View File

@ -230,6 +230,9 @@ class remotefilelog(object):
return linknode
def revdiff(self, node1, node2):
if node1 != nullid and (self.flags(node1) or self.flags(node2)):
raise error.ProgrammingError(
'cannot revdiff revisions with non-zero flags')
return mdiff.textdiff(self.revision(node1, raw=True),
self.revision(node2, raw=True))

View File

@ -1482,6 +1482,10 @@ class revlog(object):
if rev1 != nullrev and self.deltaparent(rev2) == rev1:
return bytes(self._chunk(rev2))
if rev1 > -1 and (self.flags(rev1) or self.flags(rev2)):
raise error.ProgrammingError(
'cannot revdiff revisions with non-zero flags')
return mdiff.textdiff(self.revision(rev1, raw=True),
self.revision(rev2, raw=True))