diff --git a/mercurial/changelog.py b/mercurial/changelog.py --- a/mercurial/changelog.py +++ b/mercurial/changelog.py @@ -26,6 +26,7 @@ from .utils import ( dateutil, stringutil, ) +from .revlogutils import flagutil _defaultextra = {b'branch': b'default'} @@ -579,8 +580,17 @@ class changelog(revlog.revlog): _(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: diff --git a/mercurial/interfaces/repository.py b/mercurial/interfaces/repository.py --- a/mercurial/interfaces/repository.py +++ b/mercurial/interfaces/repository.py @@ -28,12 +28,14 @@ REVISION_FLAG_CENSORED = 1 << 15 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' diff --git a/mercurial/revlog.py b/mercurial/revlog.py --- a/mercurial/revlog.py +++ b/mercurial/revlog.py @@ -53,6 +53,7 @@ from .revlogutils.flagutil import ( REVIDX_ELLIPSIS, REVIDX_EXTSTORED, REVIDX_FLAGS_ORDER, + REVIDX_HASCOPIESINFO, REVIDX_ISCENSORED, REVIDX_RAWTEXT_CHANGING_FLAGS, REVIDX_SIDEDATA, @@ -98,6 +99,7 @@ REVLOGV2_FLAGS REVIDX_ISCENSORED REVIDX_ELLIPSIS REVIDX_SIDEDATA +REVIDX_HASCOPIESINFO REVIDX_EXTSTORED REVIDX_DEFAULT_FLAGS REVIDX_FLAGS_ORDER diff --git a/mercurial/revlogutils/constants.py b/mercurial/revlogutils/constants.py --- a/mercurial/revlogutils/constants.py +++ b/mercurial/revlogutils/constants.py @@ -40,6 +40,8 @@ REVIDX_ELLIPSIS = repository.REVISION_FL 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_FLAGS_ORDER = [ REVIDX_ELLIPSIS, REVIDX_EXTSTORED, REVIDX_SIDEDATA, + REVIDX_HASCOPIESINFO, ] # bitmark for flags that could cause rawdata content change diff --git a/mercurial/revlogutils/flagutil.py b/mercurial/revlogutils/flagutil.py --- a/mercurial/revlogutils/flagutil.py +++ b/mercurial/revlogutils/flagutil.py @@ -15,6 +15,7 @@ from .constants import ( REVIDX_ELLIPSIS, REVIDX_EXTSTORED, REVIDX_FLAGS_ORDER, + REVIDX_HASCOPIESINFO, REVIDX_ISCENSORED, REVIDX_RAWTEXT_CHANGING_FLAGS, REVIDX_SIDEDATA, @@ -28,6 +29,7 @@ REVIDX_ISCENSORED REVIDX_ELLIPSIS REVIDX_EXTSTORED REVIDX_SIDEDATA +REVIDX_HASCOPIESINFO, REVIDX_DEFAULT_FLAGS REVIDX_FLAGS_ORDER REVIDX_RAWTEXT_CHANGING_FLAGS @@ -37,6 +39,7 @@ REVIDX_KNOWN_FLAGS = util.bitsfrom(REVID # Store flag processors (cf. 'addflagprocessor()' to register) flagprocessors = { REVIDX_ISCENSORED: None, + REVIDX_HASCOPIESINFO: None, } diff --git a/tests/test-lfs-serve.t b/tests/test-lfs-serve.t --- a/tests/test-lfs-serve.t +++ b/tests/test-lfs-serve.t @@ -360,9 +360,11 @@ lfs content, and the extension enabled. # 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 content, and the extension enabled. # 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 content, and the extension enabled. # 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 content, and the extension enabled. # 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 content, and the extension enabled. # 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=!