tests/test-requires.t
author FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
Sat, 21 Sep 2013 21:33:29 +0900
changeset 19778 55ef79031009
parent 16913 f2719b387380
child 20715 b93791e0de25
permissions -rw-r--r--
localrepo: make supported features manageable in each repositories individually Before this patch, all localrepositories support same features, because supported features are managed by the class variable "supported" of "localrepository". For example, "largefiles" feature provided by largefiles extension is recognized as supported, by adding the feature name to "supported" of "localrepository". So, commands handling multiple repositories at a time like below misunderstand that such features are supported also in repositories not enabling corresponded extensions: - clone/pull from or push to localhost - recursive execution in subrepo tree "reposetup()" can't be used to fix this problem, because it is invoked after checking whether supported features satisfy ones required in the target repository. So, this patch adds the set object named as "featuresetupfuncs" to "localrepository" to manage hook functions to setup supported features of each repositories. If any functions are added to "featuresetupfuncs", they are invoked, and information about supported features is managed in each repositories individually. This patch also adds checking below: - pull from localhost: whether features supported in the local(= dst) repository satisfies ones required in the remote(= src) - push to localhost: whether features supported in the remote(= dst) repository satisfies ones required in the local(= src) Managing supported features by the class variable means that there is no difference of supported features between each instances of "localrepository" in the same Python process, so such checking is not needed before this patch. Even with this patch, if intermediate bundlefile is used as pulling source, pulling indirectly from the remote repository, which requires features more than ones supported in the local, can't be prevented, because bundlefile has no information about "required features" in it.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
13956
ffb5c09ba822 tests: remove redundant mkdir
Martin Geisler <mg@lazybytes.net>
parents: 12346
diff changeset
     1
  $ hg init t
12116
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
     2
  $ cd t
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
     3
  $ echo a > a
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
     4
  $ hg add a
12156
4c94b6d0fb1c tests: remove unneeded -d flags
Martin Geisler <mg@lazybytes.net>
parents: 12116
diff changeset
     5
  $ hg commit -m test
12116
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
     6
  $ rm .hg/requires
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
     7
  $ hg tip
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
     8
  abort: index 00changelog.i unknown format 2!
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 12156
diff changeset
     9
  [255]
12116
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
    10
  $ echo indoor-pool > .hg/requires
f51858009328 tests: unify test-requires
Nicolas Dumazet <nicdumz.commits@gmail.com>
parents: 3851
diff changeset
    11
  $ hg tip
14746
72e4fcb43227 requirements: show all missing features in the error message.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 14483
diff changeset
    12
  abort: unknown repository format: requires features 'indoor-pool' (upgrade Mercurial)!
12316
4134686b83e1 tests: add exit codes to unified tests
Matt Mackall <mpm@selenic.com>
parents: 12156
diff changeset
    13
  [255]
14746
72e4fcb43227 requirements: show all missing features in the error message.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 14483
diff changeset
    14
  $ echo outdoor-pool >> .hg/requires
72e4fcb43227 requirements: show all missing features in the error message.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 14483
diff changeset
    15
  $ hg tip
72e4fcb43227 requirements: show all missing features in the error message.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 14483
diff changeset
    16
  abort: unknown repository format: requires features 'indoor-pool', 'outdoor-pool' (upgrade Mercurial)!
72e4fcb43227 requirements: show all missing features in the error message.
Pierre-Yves David <pierre-yves.david@ens-lyon.org>
parents: 14483
diff changeset
    17
  [255]
19778
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    18
  $ cd ..
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    19
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    20
Test checking between features supported locally and ones required in
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    21
another repository of push/pull/clone on localhost:
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    22
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    23
  $ mkdir supported-locally
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    24
  $ cd supported-locally
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    25
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    26
  $ hg init supported
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    27
  $ echo a > supported/a
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    28
  $ hg -R supported commit -Am '#0 at supported'
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    29
  adding a
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    30
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    31
  $ echo 'featuresetup-test' >> supported/.hg/requires
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    32
  $ cat > $TESTTMP/supported-locally/supportlocally.py <<EOF
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    33
  > from mercurial import localrepo, extensions
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    34
  > def featuresetup(ui, supported):
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    35
  >     for name, module in extensions.extensions(ui):
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    36
  >         if __name__ == module.__name__:
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    37
  >             # support specific feature locally
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    38
  >             supported |= set(['featuresetup-test'])
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    39
  >             return
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    40
  > def uisetup(ui):
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    41
  >     localrepo.localrepository.featuresetupfuncs.add(featuresetup)
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    42
  > EOF
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    43
  $ cat > supported/.hg/hgrc <<EOF
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    44
  > [extensions]
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    45
  > # enable extension locally
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    46
  > supportlocally = $TESTTMP/supported-locally/supportlocally.py
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    47
  > EOF
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    48
  $ hg -R supported status
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    49
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    50
  $ hg init push-dst
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    51
  $ hg -R supported push push-dst
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    52
  pushing to push-dst
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    53
  abort: required features are not supported in the destination: featuresetup-test
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    54
  [255]
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    55
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    56
  $ hg init pull-src
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    57
  $ hg -R pull-src pull supported
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    58
  pulling from supported
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    59
  abort: required features are not supported in the destination: featuresetup-test
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    60
  [255]
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    61
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    62
  $ hg clone supported clone-dst
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    63
  abort: unknown repository format: requires features 'featuresetup-test' (upgrade Mercurial)!
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    64
  [255]
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    65
  $ hg clone --pull supported clone-dst
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    66
  abort: required features are not supported in the destination: featuresetup-test
55ef79031009 localrepo: make supported features manageable in each repositories individually
FUJIWARA Katsunori <foozy@lares.dti.ne.jp>
parents: 16913
diff changeset
    67
  [255]
16913
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 14746
diff changeset
    68
f2719b387380 tests: add missing trailing 'cd ..'
Mads Kiilerich <mads@kiilerich.com>
parents: 14746
diff changeset
    69
  $ cd ..