From patchwork Sun Sep 26 20:31:35 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: [2, of, 2, V3] issue6588 fix: filelog can store rev-dups - revs with same content on same parents, but on different changeID From: alexrayne X-Patchwork-Id: 49822 Message-Id: To: mercurial-devel@mercurial-scm.org Date: Sun, 26 Sep 2021 23:31:35 +0300 # HG changeset patch # User alexrayne # Date 1632687562 -10800 # Sun Sep 26 23:19:22 2021 +0300 # Branch stable # Node ID f626e7866c6ccee998543847f7ed3b0f63a3c504 # Parent bf4231a64fb22e0268aea344f03fbab1708ca3a5 issue6588 fix: filelog can store rev-dups - revs with same content on same parents, but on different changeID. * to solve problem with rev-dups, this patch infers changes into revision meta-data - current timestamp. # HG changeset patch # User alexrayne # Date 1632687562 -10800 # Sun Sep 26 23:19:22 2021 +0300 # Branch stable # Node ID f626e7866c6ccee998543847f7ed3b0f63a3c504 # Parent bf4231a64fb22e0268aea344f03fbab1708ca3a5 issue6588 fix: filelog can store rev-dups - revs with same content on same parents, but on different changeID. * to solve problem with rev-dups, this patch infers changes into revision meta-data - current timestamp. diff --git a/mercurial/filelog.py b/mercurial/filelog.py --- a/mercurial/filelog.py +++ b/mercurial/filelog.py @@ -18,6 +18,7 @@ util as interfaceutil, ) from .utils import storageutil +from .utils import dateutil from .revlogutils import ( constants as revlog_constants, rewrite, @@ -209,8 +210,14 @@ def add(self, text, meta, transaction, link, p1=None, p2=None): if meta or text.startswith(b'\1\n'): - text = storageutil.packmeta(meta, text) - rev = self.addrevision(text, transaction, link, p1, p2) + revdata = storageutil.packmeta(meta, text) + else : + revdata = text + rev = self.addrevision(revdata, transaction, link, p1, p2) + if self.linkrev(rev) != link: + meta[b"dup-date"] = dateutil.datestr() + revdata = storageutil.packmeta(meta, text) + rev = self.addrevision(revdata, transaction, link, p1, p2) return self.node(rev) def renamed(self, node):