tests: disallow using simple store repo with bundlerepo
authorGregory Szorc <gregory.szorc@gmail.com>
Wed, 04 Apr 2018 11:44:38 -0700
changeset 44964 45a4799174a1c6a734fa1ff60bc68dacb1789677
parent 44963 b09a25d745922f97b514bf8e5f0d797e0556cd7a
child 44965 e82a59bfc5e8c1669a2e9228a4cc13100ba1c626
push id777
push usergszorc@mozilla.com
push dateThu, 05 Apr 2018 04:57:58 +0000
tests: disallow using simple store repo with bundlerepo bundlerepo is... going to be difficult to port to an alternate store because it assumes revlogs for storage and essentially overlays the contents of a bundle onto a fake revlog-like primitive. It will be a good test case for our eventual new storage interface. Refactoring bundlerepo to make it work with non-revlog storage is going to be a bit of work. So for now, let's refuse to use the simple store repo when a bundlerepo is in play. A new test requirement advertising support for treating bundle files as repo instances has been added. Some tests have been made conditional on this feature. Additional tests will be annotated in subsequent commits. Having positive opt-in to repo features will be simpler in the long run because it will allow multiple storage backends to declare feature support and we won't have to annotate each test with the set of repo backends that are supported. Again, we'll probably want better integration between repo features and tests. But this is the easiest we can do at the moment. Differential Revision: https://phab.mercurial-scm.org/D3060
tests/hghave.py
tests/simplestorerepo.py
tests/test-manifest.t
tests/test-mq-pull-from-bundle.t
tests/test-narrow-strip.t
tests/test-obsolete.t
tests/test-shelve.t
tests/test-treemanifest.t
--- a/tests/hghave.py
+++ b/tests/hghave.py
@@ -726,22 +726,23 @@ def getrepofeatures():
     """Obtain set of repository features in use.
 
     HGREPOFEATURES can be used to define or remove features. It contains
     a space-delimited list of feature strings. Strings beginning with ``-``
     mean to remove.
     """
     # Default list provided by core.
     features = {
+        'bundlerepo',
         'revlogstore',
     }
 
     # Features that imply other features.
     implies = {
-        'simplestore': ['-revlogstore'],
+        'simplestore': ['-revlogstore', '-bundlerepo'],
     }
 
     for override in os.environ.get('HGREPOFEATURES', '').split(' '):
         if not override:
             continue
 
         if override.startswith('-'):
             if override[1:] in features:
@@ -760,8 +761,12 @@ def getrepofeatures():
 
 @check('reporevlogstore', 'repository using the default revlog store')
 def has_reporevlogstore():
     return 'revlogstore' in getrepofeatures()
 
 @check('reposimplestore', 'repository using simple storage extension')
 def has_reposimplestore():
     return 'simplestore' in getrepofeatures()
+
+@check('repobundlerepo', 'whether we can open bundle files as repos')
+def has_repobundlerepo():
+    return 'bundlerepo' in getrepofeatures()
--- a/tests/simplestorerepo.py
+++ b/tests/simplestorerepo.py
@@ -19,16 +19,17 @@ from mercurial.node import (
     nullid,
     nullrev,
 )
 from mercurial.thirdparty import (
     cbor,
 )
 from mercurial import (
     ancestor,
+    bundlerepo,
     error,
     filelog,
     mdiff,
     pycompat,
     revlog,
 )
 
 # Note for extension authors: ONLY specify testedwith = 'ships-with-hg-core' for
@@ -582,13 +583,16 @@ class filestorage(object):
         # Purge index data starting at the requested revision.
         self._indexdata[rev:] = []
         self._reflectindexupdate()
 
 def reposetup(ui, repo):
     if not repo.local():
         return
 
+    if isinstance(repo, bundlerepo.bundlerepository):
+        raise error.Abort(_('cannot use simple store with bundlerepo'))
+
     class simplestorerepo(repo.__class__):
         def file(self, f):
             return filestorage(self.svfs, f)
 
     repo.__class__ = simplestorerepo
--- a/tests/test-manifest.t
+++ b/tests/test-manifest.t
@@ -1,8 +1,10 @@
+#require repobundlerepo
+
 Source bundle was generated with the following script:
 
 # hg init
 # echo a > a
 # ln -s a l
 # hg ci -Ama -d'0 0'
 # mkdir b
 # echo a > b/a
--- a/tests/test-mq-pull-from-bundle.t
+++ b/tests/test-mq-pull-from-bundle.t
@@ -1,8 +1,10 @@
+#require repobundlerepo
+
   $ cat <<EOF >> $HGRCPATH
   > [extensions]
   > mq=
   > [alias]
   > tlog = log --template "{rev}: {node|short} {desc}\\n"
   > theads = heads --template "{rev}: {desc}\\n"
   > tincoming = incoming --template "{rev}: {desc}\\n"
   > EOF
--- a/tests/test-narrow-strip.t
+++ b/tests/test-narrow-strip.t
@@ -125,16 +125,18 @@ Also verify we can apply the bundle with
   added 1 changesets with 1 changes to 1 files (+1 heads)
   new changesets * (glob)
   (run 'hg heads' to see heads, 'hg merge' to merge)
 
   $ rm .hg/strip-backup/*-backup.hg
   $ hg strip 0
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
   saved backup bundle to $TESTTMP/narrow/.hg/strip-backup/*-backup.hg (glob)
+
+#if repobundlerepo
   $ hg incoming .hg/strip-backup/*-backup.hg
   comparing with .hg/strip-backup/*-backup.hg (glob)
   changeset:   0:* (glob)
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     initial
   
   changeset:   1:9e48d953700d (flat !)
@@ -156,8 +158,9 @@ Also verify we can apply the bundle with
   pulling from .hg/strip-backup/*-backup.hg (glob)
   requesting all changes
   adding changesets
   adding manifests
   adding file changes
   added 3 changesets with 2 changes to 1 files (+1 heads)
   new changesets *:* (glob)
   (run 'hg heads' to see heads, 'hg merge' to merge)
+#endif
--- a/tests/test-obsolete.t
+++ b/tests/test-obsolete.t
@@ -1239,28 +1239,30 @@ Test bundle overlay onto hidden revision
   $ hg log -G --hidden
   @  2:b7d587542d40 (draft) [tip ] B+
   |
   | x  1:44526ebb0f98 (draft *obsolete*) [ ] B [rewritten using amend as 2:b7d587542d40]
   |/
   o  0:4b34ecfb0d56 (draft) [ ] A
   
 
+#if repobundlerepo
   $ hg incoming ../repo-bundleoverlay --bundle ../bundleoverlay.hg
   comparing with ../repo-bundleoverlay
   searching for changes
   1:44526ebb0f98 (draft) [ ] B
   2:c186d7714947 (draft) [tip ] C
   $ hg log -G -R ../bundleoverlay.hg
   o  3:c186d7714947 (draft) [tip ] C
   |
   | @  2:b7d587542d40 (draft) [ ] B+
   |/
   o  0:4b34ecfb0d56 (draft) [ ] A
   
+#endif
 
 #if serve
 
 Test issue 4506
 
   $ cd ..
   $ hg init repo-issue4506
   $ cd repo-issue4506
--- a/tests/test-shelve.t
+++ b/tests/test-shelve.t
@@ -766,20 +766,22 @@ unshelve and conflicts with tracked and 
  other uncommitted changes - merge:
 
   $ hg st
   A f
   ? f.orig
   $ hg shelve
   shelved as default
   0 files updated, 0 files merged, 1 files removed, 0 files unresolved
+#if repobundlerepo
   $ hg log -G --template '{rev}  {desc|firstline}  {author}' -R bundle://.hg/shelved/default.hg -r 'bundle()'
   o  4  changes to: commit stuff  shelve@localhost
   |
   ~
+#endif
   $ hg log -G --template '{rev}  {desc|firstline}  {author}'
   @  3  commit stuff  test
   |
   | o  2  c  test
   |/
   o  0  a  test
   
   $ mv f.orig f
--- a/tests/test-treemanifest.t
+++ b/tests/test-treemanifest.t
@@ -320,25 +320,29 @@ Stripping and recovering changes should 
   M dir1/a
   $ hg --config extensions.strip= strip tip
   1 files updated, 0 files merged, 0 files removed, 0 files unresolved
   saved backup bundle to $TESTTMP/repo-mixed/.hg/strip-backup/51cfd7b1e13b-78a2f3ed-backup.hg
   $ hg debugindex --dir dir1
      rev linkrev nodeid       p1           p2
        0       4 064927a0648a 000000000000 000000000000
        1       5 25ecb8cb8618 000000000000 000000000000
+
+#if repobundlerepo
   $ hg incoming .hg/strip-backup/*
   comparing with .hg/strip-backup/*-backup.hg (glob)
   searching for changes
   changeset:   6:51cfd7b1e13b
   tag:         tip
   user:        test
   date:        Thu Jan 01 00:00:00 1970 +0000
   summary:     modify dir1/a
   
+#endif
+
   $ hg unbundle .hg/strip-backup/*
   adding changesets
   adding manifests
   adding file changes
   added 1 changesets with 1 changes to 1 files
   new changesets 51cfd7b1e13b
   (run 'hg update' to get a working copy)
   $ hg --config extensions.strip= strip tip