tests/test-lfs-bundle.t
author Pierre-Yves David <pierre-yves.david@octobus.net>
Mon, 11 Dec 2023 22:27:59 +0100
changeset 51181 dcaa2df1f688
parent 47071 3e381eb557f3
permissions -rw-r--r--
changelog: never inline changelog The test suite mostly use small repositories, that implies that most changelog in the tests are inlined. As a result, non-inlined changelog are quite poorly tested. Since non-inline changelog are most common case for serious repositories, this lack of testing is a significant problem that results in high profile issue like the one recently fixed by 66417f55ea33 and 849745d7da89. Inlining the changelog does not bring much to the table, the number of total file saved is negligible, and the changelog will be read by most operation anyway. So this changeset is make it so we never inline the changelog, and de-inline the one that are still inlined whenever we touch them. By doing that, we remove the "dual code path" situation for writing new entry to the changelog and move to a "single code path" situation. Having a single code path simplify the code and make sure it is covered by test (if test cover that situation obviously) This impact all tests that care about the number of file and the exchange size, but there is nothing too complicated in them just a lot of churn. The churn is made "worse" by the fact rust will use the persistent nodemap on any changelog now. Which is overall a win as it means testing the persistent nodemap more and having less special cases. In short, having inline changelog is mostly useless and an endless source of pain. We get rid of it.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
36742
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
     1
In this test, we want to test LFS bundle application on both LFS and non-LFS
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
     2
repos.
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
     3
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
     4
To make it more interesting, the file revisions will contain hg filelog
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
     5
metadata ('\1\n'). The bundle will have 1 file revision overlapping with the
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
     6
destination repo.
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
     7
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
     8
#  rev      1          2         3
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
     9
#  repo:    yes        yes       no
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    10
#  bundle:  no (base)  yes       yes (deltabase: 2 if possible)
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    11
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    12
It is interesting because rev 2 could have been stored as LFS in the repo, and
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    13
non-LFS in the bundle; or vice-versa.
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    14
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    15
Init
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    16
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    17
  $ cat >> $HGRCPATH << EOF
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    18
  > [extensions]
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    19
  > lfs=
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    20
  > drawdag=$TESTDIR/drawdag.py
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    21
  > [lfs]
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    22
  > url=file:$TESTTMP/lfs-remote
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    23
  > EOF
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    24
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    25
Helper functions
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    26
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    27
  $ commitxy() {
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    28
  > hg debugdrawdag "$@" <<'EOS'
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    29
  >  Y  # Y/X=\1\nAAAA\nE\nF
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    30
  >  |  # Y/Y=\1\nAAAA\nG\nH
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    31
  >  X  # X/X=\1\nAAAA\nC\n
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    32
  >     # X/Y=\1\nAAAA\nD\n
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    33
  > EOS
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    34
  > }
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    35
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    36
  $ commitz() {
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    37
  > hg debugdrawdag "$@" <<'EOS'
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    38
  >  Z  # Z/X=\1\nAAAA\nI\n
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    39
  >  |  # Z/Y=\1\nAAAA\nJ\n
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    40
  >  |  # Z/Z=\1\nZ
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    41
  >  Y
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    42
  > EOS
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    43
  > }
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    44
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    45
  $ enablelfs() {
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    46
  >   cat >> .hg/hgrc <<EOF
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    47
  > [lfs]
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    48
  > track=all()
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    49
  > EOF
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    50
  > }
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    51
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    52
Generate bundles
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    53
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    54
  $ for i in normal lfs; do
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    55
  >   NAME=src-$i
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    56
  >   hg init $TESTTMP/$NAME
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    57
  >   cd $TESTTMP/$NAME
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    58
  >   [ $i = lfs ] && enablelfs
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    59
  >   commitxy
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    60
  >   commitz
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    61
  >   hg bundle -q --base X -r Y+Z $TESTTMP/$NAME.bundle
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    62
  >   SRCNAMES="$SRCNAMES $NAME"
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    63
  > done
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    64
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    65
Prepare destination repos
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    66
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    67
  $ for i in normal lfs; do
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    68
  >   NAME=dst-$i
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    69
  >   hg init $TESTTMP/$NAME
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    70
  >   cd $TESTTMP/$NAME
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    71
  >   [ $i = lfs ] && enablelfs
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    72
  >   commitxy
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    73
  >   DSTNAMES="$DSTNAMES $NAME"
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    74
  > done
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    75
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    76
Apply bundles
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    77
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    78
  $ for i in $SRCNAMES; do
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    79
  >   for j in $DSTNAMES; do
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    80
  >     echo ---- Applying $i.bundle to $j ----
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    81
  >     cp -R $TESTTMP/$j $TESTTMP/tmp-$i-$j
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    82
  >     cd $TESTTMP/tmp-$i-$j
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    83
  >     if hg unbundle $TESTTMP/$i.bundle -q 2>/dev/null; then
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    84
  >       hg verify -q && echo OK
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    85
  >     else
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    86
  >       echo CRASHED
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    87
  >     fi
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    88
  >   done
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    89
  > done
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    90
  ---- Applying src-normal.bundle to dst-normal ----
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    91
  OK
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    92
  ---- Applying src-normal.bundle to dst-lfs ----
36748
369aadf7a326 revlog: resolve lfs rawtext to vanilla rawtext before applying delta
Jun Wu <quark@fb.com>
parents: 36744
diff changeset
    93
  OK
36742
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    94
  ---- Applying src-lfs.bundle to dst-normal ----
36743
d031609b3cb7 changegroup: do not delta lfs revisions
Jun Wu <quark@fb.com>
parents: 36742
diff changeset
    95
  OK
36742
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    96
  ---- Applying src-lfs.bundle to dst-lfs ----
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    97
  OK
44379
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
    98
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
    99
Hint if the cache location cannot be inferred from the environment
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   100
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   101
#if windows
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   102
  $ unset LOCALAPPDATA
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   103
  $ unset APPDATA
47071
3e381eb557f3 config: add --source option to include source of value
Martin von Zweigbergk <martinvonz@google.com>
parents: 44379
diff changeset
   104
  $ HGRCPATH= hg config lfs --source
44379
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   105
  abort: unknown lfs usercache location
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   106
  (define LOCALAPPDATA or APPDATA in the environment, or set lfs.usercache)
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   107
  [255]
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   108
#endif
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   109
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   110
#if osx
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   111
  $ unset HOME
47071
3e381eb557f3 config: add --source option to include source of value
Martin von Zweigbergk <martinvonz@google.com>
parents: 44379
diff changeset
   112
  $ HGRCPATH= hg config lfs --source
44379
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   113
  abort: unknown lfs usercache location
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   114
  (define HOME in the environment, or set lfs.usercache)
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   115
  [255]
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   116
#endif
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   117
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   118
#if no-windows no-osx
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   119
  $ unset XDG_CACHE_HOME
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   120
  $ unset HOME
47071
3e381eb557f3 config: add --source option to include source of value
Martin von Zweigbergk <martinvonz@google.com>
parents: 44379
diff changeset
   121
  $ HGRCPATH= hg config lfs --source
44379
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   122
  abort: unknown lfs usercache location
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   123
  (define XDG_CACHE_HOME or HOME in the environment, or set lfs.usercache)
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   124
  [255]
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   125
#endif
ca82929e433d lfutil: provide a hint if the largefiles/lfs cache path cannot be determined
Matt Harbison <matt_harbison@yahoo.com>
parents: 37439
diff changeset
   126