tests/test-extensions-afterloaded.t
author Raphaël Gomès <rgomes@octobus.net>
Mon, 04 Nov 2024 15:23:41 +0100
changeset 52311 f7b2806035a7
parent 40463 cfa564037789
permissions -rw-r--r--
rust: update `clap` to the latest 4.x version This brings in more up-to-date dependencies, some bug fixes (none of which are relevant yet), and slightly improved compile times.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
33014
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
     1
Test the extensions.afterloaded() function
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
     2
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
     3
  $ cat > foo.py <<EOF
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
     4
  > from mercurial import extensions
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
     5
  > def uisetup(ui):
38072
d1a49a94c324 py3: add b'' prefixes in tests/test-extensions-afterloaded.t
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33014
diff changeset
     6
  >     ui.write(b"foo.uisetup\\n")
33014
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
     7
  >     ui.flush()
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
     8
  >     def bar_loaded(loaded):
38072
d1a49a94c324 py3: add b'' prefixes in tests/test-extensions-afterloaded.t
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33014
diff changeset
     9
  >         ui.write(b"foo: bar loaded: %r\\n" % (loaded,))
33014
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    10
  >         ui.flush()
38072
d1a49a94c324 py3: add b'' prefixes in tests/test-extensions-afterloaded.t
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33014
diff changeset
    11
  >     extensions.afterloaded(b'bar', bar_loaded)
33014
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    12
  > EOF
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    13
  $ cat > bar.py <<EOF
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    14
  > def uisetup(ui):
38072
d1a49a94c324 py3: add b'' prefixes in tests/test-extensions-afterloaded.t
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33014
diff changeset
    15
  >     ui.write(b"bar.uisetup\\n")
33014
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    16
  >     ui.flush()
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    17
  > EOF
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    18
  $ basepath=`pwd`
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    19
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    20
  $ hg init basic
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    21
  $ cd basic
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    22
  $ echo foo > file
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    23
  $ hg add file
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    24
  $ hg commit -m 'add file'
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    25
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    26
  $ echo '[extensions]' >> .hg/hgrc
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    27
  $ echo "foo = $basepath/foo.py" >> .hg/hgrc
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    28
  $ echo "bar = $basepath/bar.py" >> .hg/hgrc
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    29
  $ hg log -r. -T'{rev}\n'
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    30
  foo.uisetup
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    31
  foo: bar loaded: True
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    32
  bar.uisetup
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    33
  0
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    34
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    35
Test afterloaded with the opposite extension load order
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    36
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    37
  $ cd ..
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    38
  $ hg init basic_reverse
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    39
  $ cd basic_reverse
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    40
  $ echo foo > file
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    41
  $ hg add file
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    42
  $ hg commit -m 'add file'
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    43
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    44
  $ echo '[extensions]' >> .hg/hgrc
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    45
  $ echo "bar = $basepath/bar.py" >> .hg/hgrc
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    46
  $ echo "foo = $basepath/foo.py" >> .hg/hgrc
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    47
  $ hg log -r. -T'{rev}\n'
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    48
  bar.uisetup
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    49
  foo.uisetup
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    50
  foo: bar loaded: True
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    51
  0
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    52
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    53
Test the extensions.afterloaded() function when the requested extension is not
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    54
loaded
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    55
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    56
  $ cd ..
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    57
  $ hg init notloaded
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    58
  $ cd notloaded
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    59
  $ echo foo > file
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    60
  $ hg add file
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    61
  $ hg commit -m 'add file'
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    62
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    63
  $ echo '[extensions]' >> .hg/hgrc
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    64
  $ echo "foo = $basepath/foo.py" >> .hg/hgrc
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    65
  $ hg log -r. -T'{rev}\n'
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    66
  foo.uisetup
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    67
  foo: bar loaded: False
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    68
  0
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    69
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    70
Test the extensions.afterloaded() function when the requested extension is not
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    71
configured but fails the minimum version check
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    72
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    73
  $ cd ..
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    74
  $ cat > minvers.py <<EOF
38072
d1a49a94c324 py3: add b'' prefixes in tests/test-extensions-afterloaded.t
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33014
diff changeset
    75
  > minimumhgversion = b'9999.9999'
33014
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    76
  > def uisetup(ui):
38072
d1a49a94c324 py3: add b'' prefixes in tests/test-extensions-afterloaded.t
Pulkit Goyal <7895pulkit@gmail.com>
parents: 33014
diff changeset
    77
  >     ui.write(b"minvers.uisetup\\n")
33014
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    78
  >     ui.flush()
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    79
  > EOF
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    80
  $ hg init minversion
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    81
  $ cd minversion
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    82
  $ echo foo > file
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    83
  $ hg add file
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    84
  $ hg commit -m 'add file'
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    85
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    86
  $ echo '[extensions]' >> .hg/hgrc
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    87
  $ echo "foo = $basepath/foo.py" >> .hg/hgrc
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    88
  $ echo "bar = $basepath/minvers.py" >> .hg/hgrc
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    89
  $ hg log -r. -T'{rev}\n'
40463
cfa564037789 extensions: include current version in "invalid version" message
Boris Feld <boris.feld@octobus.net>
parents: 38072
diff changeset
    90
  (third party extension bar requires version 9999.9999 or newer of Mercurial (current: *); disabling) (glob)
33014
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    91
  foo.uisetup
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    92
  foo: bar loaded: False
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    93
  0
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    94
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    95
Test the extensions.afterloaded() function when the requested extension is not
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    96
configured but fails the minimum version check, using the opposite load order
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    97
for the two extensions.
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    98
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
    99
  $ cd ..
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
   100
  $ hg init minversion_reverse
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
   101
  $ cd minversion_reverse
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
   102
  $ echo foo > file
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
   103
  $ hg add file
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
   104
  $ hg commit -m 'add file'
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
   105
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
   106
  $ echo '[extensions]' >> .hg/hgrc
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
   107
  $ echo "bar = $basepath/minvers.py" >> .hg/hgrc
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
   108
  $ echo "foo = $basepath/foo.py" >> .hg/hgrc
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
   109
  $ hg log -r. -T'{rev}\n'
40463
cfa564037789 extensions: include current version in "invalid version" message
Boris Feld <boris.feld@octobus.net>
parents: 38072
diff changeset
   110
  (third party extension bar requires version 9999.9999 or newer of Mercurial (current: *); disabling) (glob)
33014
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
   111
  foo.uisetup
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
   112
  foo: bar loaded: False
80a5d237a4ae extensions: call afterloaded() with loaded=False for disabled extensions
Adam Simpkins <simpkins@fb.com>
parents:
diff changeset
   113
  0