changeset 41045:7db1619af061

tests: add test for narrow+share For how narrow+share is supposed to work, see https://www.mercurial-scm.org/wiki/NarrowSharePlan. Differential Revision: https://phab.mercurial-scm.org/D5276
author Martin von Zweigbergk <martinvonz@google.com>
date Fri, 13 Jul 2018 11:26:46 -0700
parents 1e8d9f472ea1
children ce0bc2952e2a
files tests/test-narrow-pull.t tests/test-narrow-share.t
diffstat 2 files changed, 132 insertions(+), 22 deletions(-) [+]
line wrap: on
line diff
--- a/tests/test-narrow-pull.t	Mon Dec 10 10:39:48 2018 -0800
+++ b/tests/test-narrow-pull.t	Fri Jul 13 11:26:46 2018 -0700
@@ -150,25 +150,3 @@
   rollback completed
   abort: pull failed on remote
   [255]
-
-Can use 'hg share':
-  $ cat >> $HGRCPATH <<EOF
-  > [extensions]
-  > share=
-  > EOF
-
-  $ cd ..
-  $ hg share narrow2 narrow2-share
-  updating working directory
-  1 files updated, 0 files merged, 0 files removed, 0 files unresolved
-  $ cd narrow2-share
-  $ hg status
-
-We should also be able to unshare without breaking everything:
-  $ hg unshare
-  $ hg verify
-  checking changesets
-  checking manifests
-  crosschecking files in changesets and manifests
-  checking files
-  checked 1 changesets with 1 changes to 1 files
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/tests/test-narrow-share.t	Fri Jul 13 11:26:46 2018 -0700
@@ -0,0 +1,132 @@
+#testcases flat tree
+
+  $ . "$TESTDIR/narrow-library.sh"
+
+#if tree
+  $ cat << EOF >> $HGRCPATH
+  > [experimental]
+  > treemanifest = 1
+  > EOF
+#endif
+
+  $ cat << EOF >> $HGRCPATH
+  > [extensions]
+  > share =
+  > EOF
+
+  $ hg init remote
+  $ cd remote
+  $ for x in `$TESTDIR/seq.py 0 10`
+  > do
+  >   mkdir d$x
+  >   echo $x > d$x/f
+  >   hg add d$x/f
+  >   hg commit -m "add d$x/f"
+  > done
+  $ cd ..
+
+  $ hg clone --narrow ssh://user@dummy/remote main -q \
+  > --include d1 --include d3 --include d5 --include d7
+
+  $ hg share main share
+  updating working directory
+  4 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ hg -R share tracked
+  I path:d1
+  I path:d3
+  I path:d5
+  I path:d7
+  $ hg -R share files
+  share/d1/f
+  share/d3/f
+  share/d5/f
+  share/d7/f
+
+Narrow the share and check that the main repo's working copy gets updated
+
+# Make d3/f dirty
+  $ echo x >> main/d3/f
+  $ echo y >> main/d3/g
+  $ hg add main/d3/g
+  $ hg -R main st
+  M d3/f
+  A d3/g
+# Make d5/f not match the dirstate timestamp even though it's clean
+  $ sleep 2
+  $ hg -R main st
+  M d3/f
+  A d3/g
+  $ hg -R main debugdirstate --no-dates
+  n 644          2 set                 d1/f
+  n 644          2 unset               d3/f
+  a   0         -1 unset               d3/g
+  n 644          2 set                 d5/f
+  n 644          2 set                 d7/f
+  $ touch main/d5/f
+  $ hg -R share tracked --removeinclude d1 --removeinclude d3 --removeinclude d5
+  comparing with ssh://user@dummy/remote
+  searching for changes
+  looking for local changes to affected paths
+  deleting data/d1/f.i
+  deleting data/d3/f.i
+  deleting data/d5/f.i
+  deleting meta/d1/00manifest.i (tree !)
+  deleting meta/d3/00manifest.i (tree !)
+  deleting meta/d5/00manifest.i (tree !)
+  $ hg -R main tracked
+  I path:d7
+# d1/f, d3/f, d3/g and d5/f should no longer be reported
+  $ hg -R main files
+  main/d7/f
+# d1/f should no longer be there, d3/f should be since it was dirty, d3/g should be there since
+# it was added, and d5/f should be since we couldn't be sure it was clean
+  $ find main/d* -type f | sort
+  main/d1/f
+  main/d3/f
+  main/d3/g
+  main/d5/f
+  main/d7/f
+
+Widen the share and check that the main repo's working copy gets updated
+
+  $ hg -R share tracked --addinclude d1 --addinclude d3 -q
+  $ hg -R share tracked
+  I path:d1
+  I path:d3
+  I path:d7
+  $ hg -R share files
+  share/d1/f
+  share/d3/f
+  share/d7/f
+  $ hg -R main tracked
+  I path:d1
+  I path:d3
+  I path:d7
+# d1/f, d3/f should be back
+  $ hg -R main files
+  main/d1/f
+  main/d3/f
+  main/d3/g
+  main/d7/f
+# d3/f should be modified (not clobbered by the widening), and d3/g should be untracked
+  $ hg -R main st --all
+  M d3/f
+  A d3/g
+  C d1/f
+  C d7/f
+
+We should also be able to unshare without breaking everything:
+
+  $ hg share main share-unshare
+  updating working directory
+  3 files updated, 0 files merged, 0 files removed, 0 files unresolved
+  $ cd share-unshare
+  $ hg unshare
+  $ hg verify
+  checking changesets
+  checking manifests
+  checking directory manifests (tree !)
+  crosschecking files in changesets and manifests
+  checking files
+  checked 11 changesets with 3 changes to 3 files
+  $ cd ..