Patchwork [2,of,2] filelog can store rev-dups - revs with same content on same parents, but on different changeID

login
register
mail settings
Submitter alexrayne
Date Sept. 25, 2021, 8:15 p.m.
Message ID <9ca2887bd01418f96acb.1632600932@black2>
Download mbox | patch
Permalink /patch/49818/
State New
Headers show

Comments

alexrayne - Sept. 25, 2021, 8:15 p.m.
# HG changeset patch
# User alexrayne <alexraynepe196@gmail.com>
# Date 1632600142 -10800
#      Sat Sep 25 23:02:22 2021 +0300
# Branch stable
# Node ID 9ca2887bd01418f96acba219ed4890987b42c295
# Parent  66d9efd861e40c31ca99746ff7d7d432b7d8d1f0
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.

Patch

# HG changeset patch
# User alexrayne <alexraynepe196@gmail.com>
# Date 1632600142 -10800
#      Sat Sep 25 23:02:22 2021 +0300
# Branch stable
# Node ID 9ca2887bd01418f96acba219ed4890987b42c295
# Parent  66d9efd861e40c31ca99746ff7d7d432b7d8d1f0
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)
+            text_to_file = storageutil.packmeta(meta, text)
+        else :
+            text_to_file = text
+        rev = self.addrevision(text_to_file, transaction, link, p1, p2)
+        if self.linkrev(rev) != link:
+            meta[b"dup-date"] = dateutil.datestr()
+            text_to_file = storageutil.packmeta(meta, text)
+            rev = self.addrevision(text_to_file, transaction, link, p1, p2)
         return self.node(rev)
 
     def renamed(self, node):