Patchwork D2066: lfs: add a test showing bundle application could be broken

login
register
mail settings
Submitter phabricator
Date Feb. 7, 2018, 1:14 a.m.
Message ID <differential-rev-PHID-DREV-lhdtc2o5j2jddmypyxvt-req@phab.mercurial-scm.org>
Download mbox | patch
Permalink /patch/27390/
State Superseded
Headers show

Comments

phabricator - Feb. 7, 2018, 1:14 a.m.
quark created this revision.
Herald added a subscriber: mercurial-devel.
Herald added a reviewer: hg-reviewers.

REVISION SUMMARY
  When a bundle containing LFS delta uses non-LFS delta-base, or vice-versa,
  the bundle will fail to apply.

REPOSITORY
  rHG Mercurial

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

AFFECTED FILES
  tests/test-lfs-bundle.t

CHANGE DETAILS




To: quark, #hg-reviewers
Cc: mercurial-devel
phabricator - Feb. 13, 2018, 10:04 p.m.
mharbison72 added a comment.


  This series worked for me in practice.  I assume there's no chance that this lands on stable to help people that are pushing to a repo converted to LFS, but that didn't reclone after converting?

INLINE COMMENTS

> test-lfs-bundle.t:22
> +  > [lfs]
> +  > url=file://$TESTTMP/lfs-remote
> +  > EOF

This needs to be 'url=file:$TESTDIR/lfs-remote' to keep MSYS happy.

REPOSITORY
  rHG Mercurial

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

To: quark, #hg-reviewers, indygreg
Cc: mharbison72, mercurial-devel
phabricator - Feb. 15, 2018, 1 a.m.
quark added a comment.


  In https://phab.mercurial-scm.org/D2066#36976, @mharbison72 wrote:
  
  > This series worked for me in practice.  I assume there's no chance that this lands on stable to help people that are pushing to a repo converted to LFS, but that didn't reclone after converting?
  
  
  That should be fine - there is no need to reclone. But upgrading is needed.

REPOSITORY
  rHG Mercurial

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

To: quark, #hg-reviewers, indygreg
Cc: mharbison72, mercurial-devel

Patch

diff --git a/tests/test-lfs-bundle.t b/tests/test-lfs-bundle.t
new file mode 100644
--- /dev/null
+++ b/tests/test-lfs-bundle.t
@@ -0,0 +1,101 @@ 
+In this test, we want to test LFS bundle application on both LFS and non-LFS
+repos.
+
+To make it more interesting, the file revisions will contain hg filelog
+metadata ('\1\n'). The bundle will have 1 file revision overlapping with the
+destination repo.
+
+#  rev      1          2         3
+#  repo:    yes        yes       no
+#  bundle:  no (base)  yes       yes (deltabase: 2 if possible)
+
+It is interesting because rev 2 could have been stored as LFS in the repo, and
+non-LFS in the bundle; or vice-versa.
+
+Init:
+
+  $ cat >> $HGRCPATH << EOF
+  > [extensions]
+  > lfs=
+  > drawdag=$TESTDIR/drawdag.py
+  > [lfs]
+  > url=file://$TESTTMP/lfs-remote
+  > EOF
+
+Helper functions to create commits:
+
+  $ commitxy() {
+  > hg debugdrawdag "$@" <<'EOS'
+  >  Y  # Y/X=\1\nAAAA\nE\nF
+  >  |  # Y/Y=\1\nAAAA\nG\nH
+  >  X  # X/X=\1\nAAAA\nC\n
+  >     # X/Y=\1\nAAAA\nD\n
+  > EOS
+  > }
+
+  $ commitz() {
+  > hg debugdrawdag "$@" <<'EOS'
+  >  Z  # Z/X=\1\nAAAA\nI\n
+  >  |  # Z/Y=\1\nAAAA\nJ\n
+  >  |  # Z/Z=\1\nZ
+  >  Y
+  > EOS
+  > }
+
+  $ enablelfs() {
+  >   cat >> .hg/hgrc <<EOF
+  > [lfs]
+  > threshold=1
+  > EOF
+  > }
+
+Generate bundles
+
+  $ for i in normal lfs; do
+  >   NAME=src-$i
+  >   hg init $TESTTMP/$NAME
+  >   cd $TESTTMP/$NAME
+  >   [ $i = lfs ] && enablelfs
+  >   commitxy
+  >   commitz
+  >   hg bundle -q --base X -r Y+Z $TESTTMP/$NAME.bundle
+  >   SRCNAMES="$SRCNAMES $NAME"
+  > done
+
+Prepare destination repos
+
+  $ for i in normal lfs; do
+  >   NAME=dst-$i
+  >   hg init $TESTTMP/$NAME
+  >   cd $TESTTMP/$NAME
+  >   [ $i = lfs ] && enablelfs
+  >   commitxy
+  >   DSTNAMES="$DSTNAMES $NAME"
+  > done
+
+Apply bundles
+
+  $ cd $TESTTMP
+  $ for i in $SRCNAMES; do
+  >   for j in $DSTNAMES; do
+  >     echo ---- Applying $i.bundle to $j ----
+  >     cp -R $TESTTMP/$j $TESTTMP/tmp-$i-$j
+  >     cd $TESTTMP/tmp-$i-$j
+  >     if hg unbundle $TESTTMP/$i.bundle -q 2>/dev/null; then
+  >       hg verify -q && echo OK
+  >     else
+  >       echo CRASHED
+  >     fi
+  >   done
+  > done
+  ---- Applying src-normal.bundle to dst-normal ----
+  OK
+  ---- Applying src-normal.bundle to dst-lfs ----
+   X@2: unpacking 0609652b7877: integrity check failed on data/X.i:2
+   Y@2: unpacking e384812cdeb9: integrity check failed on data/Y.i:2
+  2 integrity errors encountered!
+  (first damaged changeset appears to be 2)
+  ---- Applying src-lfs.bundle to dst-normal ----
+  CRASHED
+  ---- Applying src-lfs.bundle to dst-lfs ----
+  OK