D6953: sidedatacopies: read rename information from sidedata

marmoute (Pierre-Yves David) phabricator at mercurial-scm.org
Thu Oct 3 01:56:24 EDT 2019


marmoute created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  Repository using the new format now use changeset centric algorithm and read the
  copies information from the changelog sidedata.

REPOSITORY
  rHG Mercurial

REVISION DETAIL
  https://phab.mercurial-scm.org/D6953

AFFECTED FILES
  mercurial/changelog.py
  mercurial/context.py
  mercurial/copies.py
  tests/test-copies-unrelated.t
  tests/test-copies.t

CHANGE DETAILS

diff --git a/tests/test-copies.t b/tests/test-copies.t
--- a/tests/test-copies.t
+++ b/tests/test-copies.t
@@ -309,7 +309,6 @@
   x -> z
   $ hg debugpathcopies 0 2
   x -> z (filelog !)
-  x -> z (sidedata !)
 
 Copy file that exists on both sides of the merge, different content
   $ newrepo
@@ -338,12 +337,14 @@
      x
   $ hg debugp1copies -r 2
   x -> z (changeset !)
+  x -> z (sidedata !)
   $ hg debugp2copies -r 2
-  x -> z (no-changeset !)
+  x -> z (no-changeset no-sidedata !)
   $ hg debugpathcopies 1 2
   x -> z (changeset !)
+  x -> z (sidedata !)
   $ hg debugpathcopies 0 2
-  x -> z (no-changeset !)
+  x -> z (no-changeset no-sidedata !)
 
 Copy x->y on one side of merge and copy x->z on the other side. Pathcopies from one parent
 of the merge to the merge should include the copy from the other side.
@@ -403,7 +404,7 @@
   $ hg debugpathcopies 2 3
   y -> z
   $ hg debugpathcopies 1 3
-  y -> z (no-filelog no-sidedata !)
+  y -> z (no-filelog !)
 
 Create x and y, then rename x to z on one side of merge, and rename y to z and
 modify z on the other side. When storing copies in the changeset, we don't
@@ -448,18 +449,18 @@
   o  0 add x and y
      x y
   $ hg debugpathcopies 1 4
-  y -> z (no-filelog no-sidedata !)
+  y -> z (no-filelog !)
   $ hg debugpathcopies 2 4
-  x -> z (no-filelog no-sidedata !)
+  x -> z (no-filelog !)
   $ hg debugpathcopies 0 4
   x -> z (filelog !)
-  x -> z (sidedata !)
+  y -> z (sidedata !)
   y -> z (compatibility !)
   y -> z (changeset !)
   $ hg debugpathcopies 1 5
-  y -> z (no-filelog no-sidedata !)
+  y -> z (no-filelog !)
   $ hg debugpathcopies 2 5
-  x -> z (no-filelog no-sidedata !)
+  x -> z (no-filelog !)
   $ hg debugpathcopies 0 5
   x -> z
 
diff --git a/tests/test-copies-unrelated.t b/tests/test-copies-unrelated.t
--- a/tests/test-copies-unrelated.t
+++ b/tests/test-copies-unrelated.t
@@ -179,8 +179,8 @@
   o  0 add x
      x
   $ hg debugpathcopies 0 5
-  x -> y (no-filelog no-sidedata !)
-#if no-filelog no-sidedata
+  x -> y (no-filelog !)
+#if no-filelog
   $ hg graft -r 2
   grafting 2:* "modify x again" (glob)
   merging y and x to y
@@ -347,8 +347,8 @@
   o  0 base
      a
   $ hg debugpathcopies 1 5
-  x -> y (no-filelog no-sidedata !)
-#if no-filelog no-sidedata
+  x -> y (no-filelog !)
+#if no-filelog
   $ hg graft -r 2
   grafting 2:* "modify x" (glob)
   merging y and x to y
diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -182,6 +182,8 @@
 
 def usechangesetcentricalgo(repo):
     """Checks if we should use changeset-centric copy algorithms"""
+    if repo.filecopiesmode == 'changeset-sidedata':
+        return True
     readfrom = repo.ui.config('experimental', 'copies.read-from')
     changesetsource = ('changeset-only', 'compatibility')
     return readfrom in changesetsource
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -456,7 +456,10 @@
 
     def filesadded(self):
         filesadded = self._changeset.filesadded
-        if True:
+        if self._repo.filecopiesmode == 'changeset-sidedata':
+            if filesadded is None:
+                filesadded = []
+        else:
             source = self._repo.ui.config('experimental', 'copies.read-from')
             if source == 'changeset-only':
                 if filesadded is None:
@@ -470,7 +473,10 @@
 
     def filesremoved(self):
         filesremoved = self._changeset.filesremoved
-        if True:
+        if self._repo.filecopiesmode == 'changeset-sidedata':
+            if filesremoved is None:
+                filesremoved = []
+        else:
             source = self._repo.ui.config('experimental', 'copies.read-from')
             if source == 'changeset-only':
                 if filesremoved is None:
@@ -486,7 +492,12 @@
     def _copies(self):
         p1copies = self._changeset.p1copies
         p2copies = self._changeset.p2copies
-        if True:
+        if self._repo.filecopiesmode == 'changeset-sidedata':
+            if p1copies is None:
+                p1copies = {}
+            if p2copies is None:
+                p2copies = {}
+        else:
             source = self._repo.ui.config('experimental', 'copies.read-from')
             # If config says to get copy metadata only from changeset, then
             # return that, defaulting to {} if there was no copy metadata.  In
diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -339,23 +339,43 @@
 
     @property
     def filesadded(self):
-        rawindices = self.extra.get('filesadded')
-        return rawindices and decodefileindices(self.files, rawindices)
+        if sidedatamod.SD_FILESADDED in self._sidedata:
+            rawindices = self._sidedata.get(sidedatamod.SD_FILESADDED)
+        else:
+            rawindices = self.extra.get('filesadded')
+        if rawindices is not None:
+            rawindices = decodefileindices(self.files, rawindices)
+        return rawindices
 
     @property
     def filesremoved(self):
-        rawindices = self.extra.get('filesremoved')
-        return rawindices and decodefileindices(self.files, rawindices)
+        if sidedatamod.SD_FILESREMOVED in self._sidedata:
+            rawindices = self._sidedata.get(sidedatamod.SD_FILESREMOVED)
+        else:
+            rawindices = self.extra.get('filesremoved')
+        if rawindices is not None:
+            rawindices = decodefileindices(self.files, rawindices)
+        return rawindices
 
     @property
     def p1copies(self):
-        rawcopies = self.extra.get('p1copies')
-        return rawcopies and decodecopies(self.files, rawcopies)
+        if sidedatamod.SD_P1COPIES in self._sidedata:
+            rawcopies = self._sidedata.get(sidedatamod.SD_P1COPIES)
+        else:
+            rawcopies = self.extra.get('p1copies')
+        if rawcopies is not None:
+            rawcopies = decodecopies(self.files, rawcopies)
+        return rawcopies
 
     @property
     def p2copies(self):
-        rawcopies = self.extra.get('p2copies')
-        return rawcopies and decodecopies(self.files, rawcopies)
+        if sidedatamod.SD_P2COPIES in self._sidedata:
+            rawcopies = self._sidedata.get(sidedatamod.SD_P2COPIES)
+        else:
+            rawcopies = self.extra.get('p2copies')
+        if rawcopies is not None:
+            rawcopies = decodecopies(self.files, rawcopies)
+        return rawcopies
 
     @property
     def description(self):



To: marmoute, #hg-reviewers
Cc: mercurial-devel


More information about the Mercurial-devel mailing list