tests/test-lfs-bundle.t
author Pulkit Goyal <7895pulkit@gmail.com>
Thu, 05 Apr 2018 16:46:34 +0530
changeset 37364 1d26f745a10b
parent 37348 f4e84dfc06fd
child 37439 556984ae0005
permissions -rw-r--r--
py3: use pycompat.bytestr in test-journal.t Differential Revision: https://phab.mercurial-scm.org/D3124
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
37348
f4e84dfc06fd tests: skip largefiles and lfs tests when using simple store
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36748
diff changeset
     1
#require no-reposimplestore
f4e84dfc06fd tests: skip largefiles and lfs tests when using simple store
Gregory Szorc <gregory.szorc@gmail.com>
parents: 36748
diff changeset
     2
36742
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
     3
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
     4
repos.
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
     5
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
     6
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
     7
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
     8
destination repo.
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
     9
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    10
#  rev      1          2         3
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    11
#  repo:    yes        yes       no
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    12
#  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
    13
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    14
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
    15
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
    16
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    17
Init
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    18
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    19
  $ cat >> $HGRCPATH << EOF
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    20
  > [extensions]
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
  > drawdag=$TESTDIR/drawdag.py
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    23
  > [lfs]
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    24
  > url=file:$TESTTMP/lfs-remote
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    25
  > EOF
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
Helper functions
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    28
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    29
  $ commitxy() {
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    30
  > hg debugdrawdag "$@" <<'EOS'
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    31
  >  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
    32
  >  |  # 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
    33
  >  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
    34
  >     # 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
    35
  > EOS
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    36
  > }
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    37
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    38
  $ commitz() {
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    39
  > hg debugdrawdag "$@" <<'EOS'
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    40
  >  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
    41
  >  |  # 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
    42
  >  |  # Z/Z=\1\nZ
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    43
  >  Y
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    44
  > EOS
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    45
  > }
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    46
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    47
  $ enablelfs() {
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    48
  >   cat >> .hg/hgrc <<EOF
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    49
  > [lfs]
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    50
  > track=all()
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    51
  > EOF
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    52
  > }
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
Generate bundles
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    55
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    56
  $ 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
    57
  >   NAME=src-$i
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    58
  >   hg init $TESTTMP/$NAME
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    59
  >   cd $TESTTMP/$NAME
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    60
  >   [ $i = lfs ] && enablelfs
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    61
  >   commitxy
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    62
  >   commitz
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    63
  >   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
    64
  >   SRCNAMES="$SRCNAMES $NAME"
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    65
  > done
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
Prepare destination repos
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    68
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    69
  $ 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
    70
  >   NAME=dst-$i
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    71
  >   hg init $TESTTMP/$NAME
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    72
  >   cd $TESTTMP/$NAME
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    73
  >   [ $i = lfs ] && enablelfs
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    74
  >   commitxy
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    75
  >   DSTNAMES="$DSTNAMES $NAME"
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    76
  > done
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
Apply bundles
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    79
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    80
  $ for i in $SRCNAMES; do
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    81
  >   for j in $DSTNAMES; do
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    82
  >     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
    83
  >     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
    84
  >     cd $TESTTMP/tmp-$i-$j
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    85
  >     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
    86
  >       hg verify -q && echo OK
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    87
  >     else
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    88
  >       echo CRASHED
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    89
  >     fi
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    90
  >   done
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    91
  > done
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-normal ----
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    93
  OK
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    94
  ---- 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
    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-normal ----
36743
d031609b3cb7 changegroup: do not delta lfs revisions
Jun Wu <quark@fb.com>
parents: 36742
diff changeset
    97
  OK
36742
4e41b59633fa lfs: add a test showing bundle application could be broken
Jun Wu <quark@fb.com>
parents:
diff changeset
    98
  ---- 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
    99
  OK