From patchwork Thu Aug 16 13:43:09 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [02, of, 10] revlog: add a method to tells whether rev is stored as a snapshot From: Boris Feld X-Patchwork-Id: 33778 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Thu, 16 Aug 2018 15:43:09 +0200 # HG changeset patch # User Paul Morelle # Date 1532086337 -7200 # Fri Jul 20 13:32:17 2018 +0200 # Node ID ced822e5b2a37bcdaea15366627c035a169a05d3 # Parent 4c025c62ceb8de0f58721f7edd4448b7ef95006d # EXP-Topic sparse-snapshot # Available At https://bitbucket.org/octobus/mercurial-devel/ # hg pull https://bitbucket.org/octobus/mercurial-devel/ -r ced822e5b2a3 revlog: add a method to tells whether rev is stored as a snapshot For now we only have one type of snapshot: full snapshot versus nullrev. However we are looking into adding intermediate snapshot where a large diff against another snapshot is performed instead of storing a full new text. The conditional is a bit strange and is done in order to help readability of a some later changesets. diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -2081,6 +2081,16 @@ class revlog(object): else: return rev - 1 + def issnapshot(self, rev): + """tells whether rev is a snapshot + """ + if rev == nullrev: + return True + deltap = self.deltaparent(rev) + if deltap == nullrev: + return True + return False + def revdiff(self, rev1, rev2): """return or calculate a delta between two revisions