changeset 45671:2d6aea053153

copies: add a HASCOPIESINFO flag to highlight rev with useful data If some files changes that may impact copy tracing are detected, we set this flag. This helps the copy tracing algorithm to skip fetching possibly expensive data when unnecessary. Differential Revision: https://phab.mercurial-scm.org/D9139
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Thu, 01 Oct 2020 09:29:49 +0200
parents a8fb29b05f92
children f877b3628015
files mercurial/changelog.py mercurial/interfaces/repository.py mercurial/revlog.py mercurial/revlogutils/constants.py mercurial/revlogutils/flagutil.py tests/test-lfs-serve.t
diffstat 6 files changed, 27 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/changelog.py	Wed Sep 16 21:00:02 2020 +0200
+++ b/mercurial/changelog.py	Thu Oct 01 09:29:49 2020 +0200
@@ -26,6 +26,7 @@
     dateutil,
     stringutil,
 )
+from .revlogutils import flagutil
 
 _defaultextra = {b'branch': b'default'}
 
@@ -579,8 +580,17 @@
                     _(b'the name \'%s\' is reserved') % branch
                 )
         sortedfiles = sorted(files.touched)
+        flags = 0
         sidedata = None
         if self._copiesstorage == b'changeset-sidedata':
+            if (
+                files.removed
+                or files.merged
+                or files.salvaged
+                or files.copied_from_p1
+                or files.copied_from_p2
+            ):
+                flags |= flagutil.REVIDX_HASCOPIESINFO
             sidedata = metadata.encode_files_sidedata(files)
 
         if extra:
--- a/mercurial/interfaces/repository.py	Wed Sep 16 21:00:02 2020 +0200
+++ b/mercurial/interfaces/repository.py	Thu Oct 01 09:29:49 2020 +0200
@@ -28,12 +28,14 @@
 REVISION_FLAG_ELLIPSIS = 1 << 14
 REVISION_FLAG_EXTSTORED = 1 << 13
 REVISION_FLAG_SIDEDATA = 1 << 12
+REVISION_FLAG_HASCOPIESINFO = 1 << 11
 
 REVISION_FLAGS_KNOWN = (
     REVISION_FLAG_CENSORED
     | REVISION_FLAG_ELLIPSIS
     | REVISION_FLAG_EXTSTORED
     | REVISION_FLAG_SIDEDATA
+    | REVISION_FLAG_HASCOPIESINFO
 )
 
 CG_DELTAMODE_STD = b'default'
--- a/mercurial/revlog.py	Wed Sep 16 21:00:02 2020 +0200
+++ b/mercurial/revlog.py	Thu Oct 01 09:29:49 2020 +0200
@@ -53,6 +53,7 @@
     REVIDX_ELLIPSIS,
     REVIDX_EXTSTORED,
     REVIDX_FLAGS_ORDER,
+    REVIDX_HASCOPIESINFO,
     REVIDX_ISCENSORED,
     REVIDX_RAWTEXT_CHANGING_FLAGS,
     REVIDX_SIDEDATA,
@@ -98,6 +99,7 @@
 REVIDX_ISCENSORED
 REVIDX_ELLIPSIS
 REVIDX_SIDEDATA
+REVIDX_HASCOPIESINFO
 REVIDX_EXTSTORED
 REVIDX_DEFAULT_FLAGS
 REVIDX_FLAGS_ORDER
--- a/mercurial/revlogutils/constants.py	Wed Sep 16 21:00:02 2020 +0200
+++ b/mercurial/revlogutils/constants.py	Thu Oct 01 09:29:49 2020 +0200
@@ -40,6 +40,8 @@
 REVIDX_EXTSTORED = repository.REVISION_FLAG_EXTSTORED
 # revision data contains extra metadata not part of the official digest
 REVIDX_SIDEDATA = repository.REVISION_FLAG_SIDEDATA
+# revision changes files in a way that could affect copy tracing.
+REVIDX_HASCOPIESINFO = repository.REVISION_FLAG_HASCOPIESINFO
 REVIDX_DEFAULT_FLAGS = 0
 # stable order in which flags need to be processed and their processors applied
 REVIDX_FLAGS_ORDER = [
@@ -47,6 +49,7 @@
     REVIDX_ELLIPSIS,
     REVIDX_EXTSTORED,
     REVIDX_SIDEDATA,
+    REVIDX_HASCOPIESINFO,
 ]
 
 # bitmark for flags that could cause rawdata content change
--- a/mercurial/revlogutils/flagutil.py	Wed Sep 16 21:00:02 2020 +0200
+++ b/mercurial/revlogutils/flagutil.py	Thu Oct 01 09:29:49 2020 +0200
@@ -15,6 +15,7 @@
     REVIDX_ELLIPSIS,
     REVIDX_EXTSTORED,
     REVIDX_FLAGS_ORDER,
+    REVIDX_HASCOPIESINFO,
     REVIDX_ISCENSORED,
     REVIDX_RAWTEXT_CHANGING_FLAGS,
     REVIDX_SIDEDATA,
@@ -28,6 +29,7 @@
 REVIDX_ELLIPSIS
 REVIDX_EXTSTORED
 REVIDX_SIDEDATA
+REVIDX_HASCOPIESINFO,
 REVIDX_DEFAULT_FLAGS
 REVIDX_FLAGS_ORDER
 REVIDX_RAWTEXT_CHANGING_FLAGS
@@ -37,6 +39,7 @@
 # Store flag processors (cf. 'addflagprocessor()' to register)
 flagprocessors = {
     REVIDX_ISCENSORED: None,
+    REVIDX_HASCOPIESINFO: None,
 }
 
 
--- a/tests/test-lfs-serve.t	Wed Sep 16 21:00:02 2020 +0200
+++ b/tests/test-lfs-serve.t	Thu Oct 01 09:29:49 2020 +0200
@@ -360,9 +360,11 @@
   # LFS required- both lfs and non-lfs revlogs have 0x2000 flag
   *** runcommand debugprocessors lfs.bin -R ../server
   registered processor '0x8000'
+  registered processor '0x800'
   registered processor '0x2000'
   *** runcommand debugprocessors nonlfs2.txt -R ../server
   registered processor '0x8000'
+  registered processor '0x800'
   registered processor '0x2000'
   *** runcommand config extensions --cwd ../server
   extensions.debugprocessors=$TESTTMP/debugprocessors.py
@@ -371,6 +373,7 @@
   # LFS not enabled- revlogs don't have 0x2000 flag
   *** runcommand debugprocessors nonlfs3.txt
   registered processor '0x8000'
+  registered processor '0x800'
   *** runcommand config extensions
   extensions.debugprocessors=$TESTTMP/debugprocessors.py
 
@@ -413,9 +416,11 @@
   # LFS enabled- both lfs and non-lfs revlogs have 0x2000 flag
   *** runcommand debugprocessors lfs.bin -R ../server
   registered processor '0x8000'
+  registered processor '0x800'
   registered processor '0x2000'
   *** runcommand debugprocessors nonlfs2.txt -R ../server
   registered processor '0x8000'
+  registered processor '0x800'
   registered processor '0x2000'
   *** runcommand config extensions --cwd ../server
   extensions.debugprocessors=$TESTTMP/debugprocessors.py
@@ -424,6 +429,7 @@
   # LFS enabled without requirement- revlogs have 0x2000 flag
   *** runcommand debugprocessors nonlfs3.txt
   registered processor '0x8000'
+  registered processor '0x800'
   registered processor '0x2000'
   *** runcommand config extensions
   extensions.debugprocessors=$TESTTMP/debugprocessors.py
@@ -432,6 +438,7 @@
   # LFS disabled locally- revlogs don't have 0x2000 flag
   *** runcommand debugprocessors nonlfs.txt -R ../nonlfs
   registered processor '0x8000'
+  registered processor '0x800'
   *** runcommand config extensions --cwd ../nonlfs
   extensions.debugprocessors=$TESTTMP/debugprocessors.py
   extensions.lfs=!