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

2018-03-06 Thread quark (Jun Wu)
This revision was automatically updated to reflect the committed changes.
Closed by commit rHG4e41b59633fa: lfs: add a test showing bundle application 
could be broken (authored by quark, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2066?vs=5730=6669

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

AFFECTED FILES
  tests/drawdag.py
  tests/test-lfs-bundle.t

CHANGE DETAILS

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,100 @@
+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:yesyes   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
+
+  $ commitxy() {
+  > hg debugdrawdag "$@" <<'EOS'
+  >  Y  # Y/X=\1\n\nE\nF
+  >  |  # Y/Y=\1\n\nG\nH
+  >  X  # X/X=\1\n\nC\n
+  > # X/Y=\1\n\nD\n
+  > EOS
+  > }
+
+  $ commitz() {
+  > hg debugdrawdag "$@" <<'EOS'
+  >  Z  # Z/X=\1\n\nI\n
+  >  |  # Z/Y=\1\n\nJ\n
+  >  |  # Z/Z=\1\nZ
+  >  Y
+  > EOS
+  > }
+
+  $ enablelfs() {
+  >   cat >> .hg/hgrc < [lfs]
+  > track=all()
+  > 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
+
+  $ 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 bcc7d23fa6b7: integrity check failed on data/X.i:2
+   Y@2: unpacking 46017a6640e7: 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
diff --git a/tests/drawdag.py b/tests/drawdag.py
--- a/tests/drawdag.py
+++ b/tests/drawdag.py
@@ -371,7 +371,8 @@
 comments = list(_getcomments(text))
 filere = re.compile(br'^(\w+)/([\w/]+)\s*=\s*(.*)$', re.M)
 for name, path, content in filere.findall(b'\n'.join(comments)):
-files[name][path] = content.replace(br'\n', b'\n')
+content = content.replace(br'\n', b'\n').replace(br'\1', b'\1')
+files[name][path] = content
 
 committed = {None: node.nullid}  # {name: node}
 



To: quark, #hg-reviewers, indygreg
Cc: mharbison72, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


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

2018-02-14 Thread quark (Jun Wu)
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
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


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

2018-02-14 Thread quark (Jun Wu)
quark updated this revision to Diff 5730.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2066?vs=5326=5730

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

AFFECTED FILES
  tests/drawdag.py
  tests/test-lfs-bundle.t

CHANGE DETAILS

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,100 @@
+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:yesyes   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
+
+  $ commitxy() {
+  > hg debugdrawdag "$@" <<'EOS'
+  >  Y  # Y/X=\1\n\nE\nF
+  >  |  # Y/Y=\1\n\nG\nH
+  >  X  # X/X=\1\n\nC\n
+  > # X/Y=\1\n\nD\n
+  > EOS
+  > }
+
+  $ commitz() {
+  > hg debugdrawdag "$@" <<'EOS'
+  >  Z  # Z/X=\1\n\nI\n
+  >  |  # Z/Y=\1\n\nJ\n
+  >  |  # Z/Z=\1\nZ
+  >  Y
+  > EOS
+  > }
+
+  $ enablelfs() {
+  >   cat >> .hg/hgrc < [lfs]
+  > track=all()
+  > 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
+
+  $ 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 bcc7d23fa6b7: integrity check failed on data/X.i:2
+   Y@2: unpacking 46017a6640e7: 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
diff --git a/tests/drawdag.py b/tests/drawdag.py
--- a/tests/drawdag.py
+++ b/tests/drawdag.py
@@ -371,7 +371,8 @@
 comments = list(_getcomments(text))
 filere = re.compile(br'^(\w+)/([\w/]+)\s*=\s*(.*)$', re.M)
 for name, path, content in filere.findall(b'\n'.join(comments)):
-files[name][path] = content.replace(br'\n', b'\n')
+content = content.replace(br'\n', b'\n').replace(br'\1', b'\1')
+files[name][path] = content
 
 committed = {None: node.nullid}  # {name: node}
 



To: quark, #hg-reviewers, indygreg
Cc: mharbison72, mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


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

2018-02-13 Thread mharbison72 (Matt Harbison)
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
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


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

2018-02-07 Thread quark (Jun Wu)
quark updated this revision to Diff 5326.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2066?vs=5275=5326

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

AFFECTED FILES
  tests/drawdag.py
  tests/test-lfs-bundle.t

CHANGE DETAILS

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,100 @@
+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:yesyes   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
+
+  $ commitxy() {
+  > hg debugdrawdag "$@" <<'EOS'
+  >  Y  # Y/X=\1\n\nE\nF
+  >  |  # Y/Y=\1\n\nG\nH
+  >  X  # X/X=\1\n\nC\n
+  > # X/Y=\1\n\nD\n
+  > EOS
+  > }
+
+  $ commitz() {
+  > hg debugdrawdag "$@" <<'EOS'
+  >  Z  # Z/X=\1\n\nI\n
+  >  |  # Z/Y=\1\n\nJ\n
+  >  |  # Z/Z=\1\nZ
+  >  Y
+  > EOS
+  > }
+
+  $ enablelfs() {
+  >   cat >> .hg/hgrc < [lfs]
+  > track=all()
+  > 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
+
+  $ 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 bcc7d23fa6b7: integrity check failed on data/X.i:2
+   Y@2: unpacking 46017a6640e7: 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
diff --git a/tests/drawdag.py b/tests/drawdag.py
--- a/tests/drawdag.py
+++ b/tests/drawdag.py
@@ -371,7 +371,8 @@
 comments = list(_getcomments(text))
 filere = re.compile(br'^(\w+)/([\w/]+)\s*=\s*(.*)$', re.M)
 for name, path, content in filere.findall(b'\n'.join(comments)):
-files[name][path] = content.replace(br'\n', b'\n')
+content = content.replace(br'\n', b'\n').replace(br'\1', b'\1')
+files[name][path] = content
 
 committed = {None: node.nullid}  # {name: node}
 



To: quark, #hg-reviewers, indygreg
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


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

2018-02-06 Thread quark (Jun Wu)
quark updated this revision to Diff 5275.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2066?vs=5272=5275

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

AFFECTED FILES
  tests/drawdag.py
  tests/test-lfs-bundle.t

CHANGE DETAILS

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,100 @@
+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:yesyes   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\n\nE\nF
+  >  |  # Y/Y=\1\n\nG\nH
+  >  X  # X/X=\1\n\nC\n
+  > # X/Y=\1\n\nD\n
+  > EOS
+  > }
+
+  $ commitz() {
+  > hg debugdrawdag "$@" <<'EOS'
+  >  Z  # Z/X=\1\n\nI\n
+  >  |  # Z/Y=\1\n\nJ\n
+  >  |  # Z/Z=\1\nZ
+  >  Y
+  > EOS
+  > }
+
+  $ enablelfs() {
+  >   cat >> .hg/hgrc < [lfs]
+  > track=all()
+  > 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
+
+  $ 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 bcc7d23fa6b7: integrity check failed on data/X.i:2
+   Y@2: unpacking 46017a6640e7: 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
diff --git a/tests/drawdag.py b/tests/drawdag.py
--- a/tests/drawdag.py
+++ b/tests/drawdag.py
@@ -371,7 +371,8 @@
 comments = list(_getcomments(text))
 filere = re.compile(br'^(\w+)/([\w/]+)\s*=\s*(.*)$', re.M)
 for name, path, content in filere.findall(b'\n'.join(comments)):
-files[name][path] = content.replace(br'\n', b'\n')
+content = content.replace(br'\n', b'\n').replace(br'\1', b'\1')
+files[name][path] = content
 
 committed = {None: node.nullid}  # {name: node}
 



To: quark, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


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

2018-02-06 Thread quark (Jun Wu)
quark updated this revision to Diff 5272.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2066?vs=5268=5272

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

AFFECTED FILES
  tests/drawdag.py
  tests/test-lfs-bundle.t

CHANGE DETAILS

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,100 @@
+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:yesyes   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\n\nE\nF
+  >  |  # Y/Y=\1\n\nG\nH
+  >  X  # X/X=\1\n\nC\n
+  > # X/Y=\1\n\nD\n
+  > EOS
+  > }
+
+  $ commitz() {
+  > hg debugdrawdag "$@" <<'EOS'
+  >  Z  # Z/X=\1\n\nI\n
+  >  |  # Z/Y=\1\n\nJ\n
+  >  |  # Z/Z=\1\nZ
+  >  Y
+  > EOS
+  > }
+
+  $ enablelfs() {
+  >   cat >> .hg/hgrc < [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
+
+  $ 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 bcc7d23fa6b7: integrity check failed on data/X.i:2
+   Y@2: unpacking 46017a6640e7: 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
diff --git a/tests/drawdag.py b/tests/drawdag.py
--- a/tests/drawdag.py
+++ b/tests/drawdag.py
@@ -371,7 +371,8 @@
 comments = list(_getcomments(text))
 filere = re.compile(br'^(\w+)/([\w/]+)\s*=\s*(.*)$', re.M)
 for name, path, content in filere.findall(b'\n'.join(comments)):
-files[name][path] = content.replace(br'\n', b'\n')
+content = content.replace(br'\n', b'\n').replace(br'\1', b'\1')
+files[name][path] = content
 
 committed = {None: node.nullid}  # {name: node}
 



To: quark, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


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

2018-02-06 Thread quark (Jun Wu)
quark updated this revision to Diff 5268.

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D2066?vs=5263=5268

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

AFFECTED FILES
  tests/test-lfs-bundle.t

CHANGE DETAILS

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,100 @@
+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:yesyes   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\n\nE\nF
+  >  |  # Y/Y=\1\n\nG\nH
+  >  X  # X/X=\1\n\nC\n
+  > # X/Y=\1\n\nD\n
+  > EOS
+  > }
+
+  $ commitz() {
+  > hg debugdrawdag "$@" <<'EOS'
+  >  Z  # Z/X=\1\n\nI\n
+  >  |  # Z/Y=\1\n\nJ\n
+  >  |  # Z/Z=\1\nZ
+  >  Y
+  > EOS
+  > }
+
+  $ enablelfs() {
+  >   cat >> .hg/hgrc < [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
+
+  $ 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



To: quark, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel


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

2018-02-06 Thread quark (Jun Wu)
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

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:yesyes   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\n\nE\nF
+  >  |  # Y/Y=\1\n\nG\nH
+  >  X  # X/X=\1\n\nC\n
+  > # X/Y=\1\n\nD\n
+  > EOS
+  > }
+
+  $ commitz() {
+  > hg debugdrawdag "$@" <<'EOS'
+  >  Z  # Z/X=\1\n\nI\n
+  >  |  # Z/Y=\1\n\nJ\n
+  >  |  # Z/Z=\1\nZ
+  >  Y
+  > EOS
+  > }
+
+  $ enablelfs() {
+  >   cat >> .hg/hgrc < [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



To: quark, #hg-reviewers
Cc: mercurial-devel
___
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel