Patchwork D7068: sidedatacopies: only store an entry if it has values

login
register
mail settings
Submitter phabricator
Date Oct. 15, 2019, 10:12 p.m.
Message ID <044b93479ab63474466bd467e52e38ab@localhost.localdomain>
Download mbox | patch
Permalink /patch/42371/
State Not Applicable
Headers show

Comments

phabricator - Oct. 15, 2019, 10:12 p.m.
Closed by commit rHG30570a056fa8: sidedatacopies: only store an entry if it has values (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/D7068?vs=17108&id=17187

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

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

AFFECTED FILES
  mercurial/changelog.py
  mercurial/copies.py
  tests/test-copies-in-changeset.t

CHANGE DETAILS




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

Patch

diff --git a/tests/test-copies-in-changeset.t b/tests/test-copies-in-changeset.t
--- a/tests/test-copies-in-changeset.t
+++ b/tests/test-copies-in-changeset.t
@@ -77,15 +77,11 @@ 
   2\x00a (esc)
 #else
   $ hg debugsidedata -c -v -- -1
-  4 sidedata entries
+  2 sidedata entries
    entry-0010 size 11
     '0\x00a\n1\x00a\n2\x00a'
-   entry-0011 size 0
-    ''
    entry-0012 size 5
     '0\n1\n2'
-   entry-0013 size 0
-    ''
 #endif
 
   $ hg showcopies
@@ -119,11 +115,9 @@ 
 
 #else
   $ hg debugsidedata -c -v -- -1
-  4 sidedata entries
+  3 sidedata entries
    entry-0010 size 3
     '1\x00b'
-   entry-0011 size 0
-    ''
    entry-0012 size 1
     '1'
    entry-0013 size 1
@@ -168,15 +162,9 @@ 
 
 #else
   $ hg debugsidedata -c -v -- -1
-  4 sidedata entries
+  1 sidedata entries
    entry-0010 size 4
     '0\x00b2'
-   entry-0011 size 0
-    ''
-   entry-0012 size 0
-    ''
-   entry-0013 size 0
-    ''
 #endif
 
   $ hg showcopies
@@ -231,15 +219,13 @@ 
 
 #else
   $ hg debugsidedata -c -v -- -1
-  4 sidedata entries
+  3 sidedata entries
    entry-0010 size 7
     '0\x00a\n2\x00f'
    entry-0011 size 3
     '1\x00d'
    entry-0012 size 5
     '0\n1\n2'
-   entry-0013 size 0
-    ''
 #endif
 
   $ hg showcopies
@@ -262,15 +248,11 @@ 
 #else
   $ hg ci -m 'copy a to j'
   $ hg debugsidedata -c -v -- -1
-  4 sidedata entries
+  2 sidedata entries
    entry-0010 size 3
     '0\x00a'
-   entry-0011 size 0
-    ''
    entry-0012 size 1
     '0'
-   entry-0013 size 0
-    ''
 #endif
   $ hg debugdata j 0
   \x01 (esc)
@@ -297,15 +279,11 @@ 
   $ hg ci --amend -m 'copy a to j, v2'
   saved backup bundle to $TESTTMP/repo/.hg/strip-backup/*-*-amend.hg (glob)
   $ hg debugsidedata -c -v -- -1
-  4 sidedata entries
+  2 sidedata entries
    entry-0010 size 3
     '0\x00a'
-   entry-0011 size 0
-    ''
    entry-0012 size 1
     '0'
-   entry-0013 size 0
-    ''
 #endif
   $ hg showcopies --config experimental.copies.read-from=filelog-only
   a -> j
@@ -324,15 +302,6 @@ 
 #else
   $ hg ci -m 'modify j'
   $ hg debugsidedata -c -v -- -1
-  4 sidedata entries
-   entry-0010 size 0
-    ''
-   entry-0011 size 0
-    ''
-   entry-0012 size 0
-    ''
-   entry-0013 size 0
-    ''
 #endif
 
 Test writing only to filelog
@@ -347,15 +316,11 @@ 
 #else
   $ hg ci -m 'copy a to k'
   $ hg debugsidedata -c -v -- -1
-  4 sidedata entries
+  2 sidedata entries
    entry-0010 size 3
     '0\x00a'
-   entry-0011 size 0
-    ''
    entry-0012 size 1
     '0'
-   entry-0013 size 0
-    ''
 #endif
 
   $ hg debugdata k 0
@@ -470,16 +435,10 @@ 
   compression:       zlib   zlib    zlib
   compression-level: default default default
   $ hg debugsidedata -c -- 0
-  4 sidedata entries
-   entry-0010 size 0
-   entry-0011 size 0
+  1 sidedata entries
    entry-0012 size 1
-   entry-0013 size 0
   $ hg debugsidedata -c -- 1
-  4 sidedata entries
-   entry-0010 size 0
-   entry-0011 size 0
-   entry-0012 size 0
+  1 sidedata entries
    entry-0013 size 1
   $ hg debugsidedata -m -- 0
   $ cat << EOF > .hg/hgrc
@@ -522,16 +481,10 @@ 
   compression:       zlib   zlib    zlib
   compression-level: default default default
   $ hg debugsidedata -c -- 0
-  4 sidedata entries
-   entry-0010 size 0
-   entry-0011 size 0
+  1 sidedata entries
    entry-0012 size 1
-   entry-0013 size 0
   $ hg debugsidedata -c -- 1
-  4 sidedata entries
-   entry-0010 size 0
-   entry-0011 size 0
-   entry-0012 size 0
+  1 sidedata entries
    entry-0013 size 1
   $ hg debugsidedata -m -- 0
 
diff --git a/mercurial/copies.py b/mercurial/copies.py
--- a/mercurial/copies.py
+++ b/mercurial/copies.py
@@ -890,10 +890,14 @@ 
         p2copies = encodecopies(sortedfiles, p2copies)
         filesadded = encodefileindices(sortedfiles, filesadded)
         filesremoved = encodefileindices(sortedfiles, filesremoved)
-        sidedata[sidedatamod.SD_P1COPIES] = p1copies
-        sidedata[sidedatamod.SD_P2COPIES] = p2copies
-        sidedata[sidedatamod.SD_FILESADDED] = filesadded
-        sidedata[sidedatamod.SD_FILESREMOVED] = filesremoved
+        if p1copies:
+            sidedata[sidedatamod.SD_P1COPIES] = p1copies
+        if p2copies:
+            sidedata[sidedatamod.SD_P2COPIES] = p2copies
+        if filesadded:
+            sidedata[sidedatamod.SD_FILESADDED] = filesadded
+        if filesremoved:
+            sidedata[sidedatamod.SD_FILESREMOVED] = filesremoved
     return sidedata
 
 
diff --git a/mercurial/changelog.py b/mercurial/changelog.py
--- a/mercurial/changelog.py
+++ b/mercurial/changelog.py
@@ -693,14 +693,16 @@ 
                 extra[b'filesremoved'] = filesremoved
         elif self._copiesstorage == b'changeset-sidedata':
             sidedata = {}
-            if p1copies is not None:
+            if p1copies:
                 sidedata[sidedatamod.SD_P1COPIES] = p1copies
-            if p2copies is not None:
+            if p2copies:
                 sidedata[sidedatamod.SD_P2COPIES] = p2copies
-            if filesadded is not None:
+            if filesadded:
                 sidedata[sidedatamod.SD_FILESADDED] = filesadded
-            if filesremoved is not None:
+            if filesremoved:
                 sidedata[sidedatamod.SD_FILESREMOVED] = filesremoved
+            if not sidedata:
+                sidedata = None
 
         if extra:
             extra = encodeextra(extra)