Patchwork D6953: sidedatacopies: read rename information from sidedata

login
register
mail settings
Submitter phabricator
Date Oct. 9, 2019, 11:48 p.m.
Message ID <c1ff0c2a18f967dedb54de83710252fb@localhost.localdomain>
Download mbox | patch
Permalink /patch/42170/
State Not Applicable
Headers show

Comments

phabricator - Oct. 9, 2019, 11:48 p.m.
Closed by commit rHG0171483b082f: sidedatacopies: read rename information from sidedata (authored by marmoute).
This revision was automatically updated to reflect the committed changes.
This revision was not accepted when it landed; it landed in state "Needs Review".

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D6953?vs=17023&id=17027

CHANGES SINCE LAST ACTION
  https://phab.mercurial-scm.org/D6953/new/

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




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

Patch

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,16 @@ 
   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 (compatibility !)
-  y -> z (changeset !)
+  y -> z (no-filelog !)
   $ 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
@@ -188,6 +188,8 @@ 
 
 def usechangesetcentricalgo(repo):
     """Checks if we should use changeset-centric copy algorithms"""
+    if repo.filecopiesmode == b'changeset-sidedata':
+        return True
     readfrom = repo.ui.config(b'experimental', b'copies.read-from')
     changesetsource = (b'changeset-only', b'compatibility')
     return readfrom in changesetsource
diff --git a/mercurial/context.py b/mercurial/context.py
--- a/mercurial/context.py
+++ b/mercurial/context.py
@@ -533,55 +533,76 @@ 
         return sorted(modified)
 
     def filesadded(self):
-        source = self._repo.ui.config(b'experimental', b'copies.read-from')
         filesadded = self._changeset.filesadded
-        if source == b'changeset-only':
-            if filesadded is None:
+        compute_on_none = True
+        if self._repo.filecopiesmode == b'changeset-sidedata':
+            compute_on_none = False
+        else:
+            source = self._repo.ui.config(b'experimental', b'copies.read-from')
+            if source == b'changeset-only':
+                compute_on_none = False
+            elif source != b'compatibility':
+                # filelog mode, ignore any changelog content
+                filesadded = None
+        if filesadded is None:
+            if compute_on_none:
+                filesadded = scmutil.computechangesetfilesadded(self)
+            else:
                 filesadded = []
-        elif source == b'compatibility':
-            if filesadded is None:
-                filesadded = scmutil.computechangesetfilesadded(self)
-        else:
-            filesadded = scmutil.computechangesetfilesadded(self)
         return filesadded
 
     def filesremoved(self):
-        source = self._repo.ui.config(b'experimental', b'copies.read-from')
         filesremoved = self._changeset.filesremoved
-        if source == b'changeset-only':
-            if filesremoved is None:
+        compute_on_none = True
+        if self._repo.filecopiesmode == b'changeset-sidedata':
+            compute_on_none = False
+        else:
+            source = self._repo.ui.config(b'experimental', b'copies.read-from')
+            if source == b'changeset-only':
+                compute_on_none = False
+            elif source != b'compatibility':
+                # filelog mode, ignore any changelog content
+                filesremoved = None
+        if filesremoved is None:
+            if compute_on_none:
+                filesremoved = scmutil.computechangesetfilesremoved(self)
+            else:
                 filesremoved = []
-        elif source == b'compatibility':
-            if filesremoved is None:
-                filesremoved = scmutil.computechangesetfilesremoved(self)
-        else:
-            filesremoved = scmutil.computechangesetfilesremoved(self)
         return filesremoved
 
     @propertycache
     def _copies(self):
-        source = self._repo.ui.config(b'experimental', b'copies.read-from')
         p1copies = self._changeset.p1copies
         p2copies = self._changeset.p2copies
-        # If config says to get copy metadata only from changeset, then return
-        # that, defaulting to {} if there was no copy metadata.
-        # In compatibility mode, we return copy data from the changeset if
-        # it was recorded there, and otherwise we fall back to getting it from
-        # the filelogs (below).
-        if source == b'changeset-only':
-            if p1copies is None:
-                p1copies = {}
-            if p2copies is None:
-                p2copies = {}
-        elif source == b'compatibility':
-            if p1copies is None:
-                # we are in compatiblity mode and there is not data in the
-                # changeset), we get the copy metadata from the filelogs.
+        compute_on_none = True
+        if self._repo.filecopiesmode == b'changeset-sidedata':
+            compute_on_none = False
+        else:
+            source = self._repo.ui.config(b'experimental', b'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
+            # compatibility mode, we return copy data from the changeset if it
+            # was recorded there, and otherwise we fall back to getting it from
+            # the filelogs (below).
+            #
+            # If we are in compatiblity mode and there is not data in the
+            # changeset), we get the copy metadata from the filelogs.
+            #
+            # otherwise, when config said to read only from filelog, we get the
+            # copy metadata from the filelogs.
+            if source == b'changeset-only':
+                compute_on_none = False
+            elif source != b'compatibility':
+                # filelog mode, ignore any changelog content
+                p1copies = p2copies = None
+        if p1copies is None:
+            if compute_on_none:
                 p1copies, p2copies = super(changectx, self)._copies
-        else:
-            # config said to read only from filelog, we get the copy metadata
-            # from the filelogs.
-            p1copies, p2copies = super(changectx, self)._copies
+            else:
+                if p1copies is None:
+                    p1copies = {}
+        if p2copies is None:
+            p2copies = {}
         return p1copies, p2copies
 
     def description(self):
diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -362,28 +362,40 @@ 
 
     @property
     def filesadded(self):
-        rawindices = self.extra.get(b'filesadded')
+        if sidedatamod.SD_FILESADDED in self._sidedata:
+            rawindices = self._sidedata.get(sidedatamod.SD_FILESADDED)
+        else:
+            rawindices = self.extra.get(b'filesadded')
         if rawindices is None:
             return None
         return decodefileindices(self.files, rawindices)
 
     @property
     def filesremoved(self):
-        rawindices = self.extra.get(b'filesremoved')
+        if sidedatamod.SD_FILESREMOVED in self._sidedata:
+            rawindices = self._sidedata.get(sidedatamod.SD_FILESREMOVED)
+        else:
+            rawindices = self.extra.get(b'filesremoved')
         if rawindices is None:
             return None
         return decodefileindices(self.files, rawindices)
 
     @property
     def p1copies(self):
-        rawcopies = self.extra.get(b'p1copies')
+        if sidedatamod.SD_P1COPIES in self._sidedata:
+            rawcopies = self._sidedata.get(sidedatamod.SD_P1COPIES)
+        else:
+            rawcopies = self.extra.get(b'p1copies')
         if rawcopies is None:
             return None
         return decodecopies(self.files, rawcopies)
 
     @property
     def p2copies(self):
-        rawcopies = self.extra.get(b'p2copies')
+        if sidedatamod.SD_P2COPIES in self._sidedata:
+            rawcopies = self._sidedata.get(sidedatamod.SD_P2COPIES)
+        else:
+            rawcopies = self.extra.get(b'p2copies')
         if rawcopies is None:
             return None
         return decodecopies(self.files, rawcopies)