Mercurial > hg
annotate tests/test-ui-verbosity.py @ 31975:76169296e52f
obsolescence: add test for the "branch replacement" logic during push, case A2
Mercurial checks for the introduction of new heads on push. Evolution comes
into play to detect if existing branches on the server are being replaced by
some of the new one we push.
The current code for this logic is very basic (eg: issue4354) and was poorly
tested. We have a better implementation coming in the evolve extension fixing
these issues and with more serious tests coverage. In the process of upstreaming
this improved logic, we start with adding the test case that are already passing
with the current implementation. Once they are all in, we'll upstream the better
implementation and the extra test case.
See inline documentation for details about the test case added in this
changeset.
author | Pierre-Yves David <pierre-yves.david@ens-lyon.org> |
---|---|
date | Thu, 13 Apr 2017 16:23:01 +0200 |
parents | d83ca854fa21 |
children | 2507bf180413 |
rev | line source |
---|---|
28679
e48a8ac66a41
py3: make test-ui-verbosity use absolute_import
Pulkit Goyal <7895pulkit@gmail.com>
parents:
28678
diff
changeset
|
1 from __future__ import absolute_import, print_function |
28678
870dae78234c
py3: make test-ui-verbosity use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
12865
diff
changeset
|
2 |
3349
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
3 import os |
28842
d466facc5a6e
tests: alias ui as uimod in test-revlog-ancestry/test-ui-verbosity
Yuya Nishihara <yuya@tcha.org>
parents:
28679
diff
changeset
|
4 from mercurial import ( |
d466facc5a6e
tests: alias ui as uimod in test-revlog-ancestry/test-ui-verbosity
Yuya Nishihara <yuya@tcha.org>
parents:
28679
diff
changeset
|
5 ui as uimod, |
d466facc5a6e
tests: alias ui as uimod in test-revlog-ancestry/test-ui-verbosity
Yuya Nishihara <yuya@tcha.org>
parents:
28679
diff
changeset
|
6 ) |
3349
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
7 |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
8 hgrc = os.environ['HGRCPATH'] |
5523
5db730475d6d
tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3349
diff
changeset
|
9 f = open(hgrc) |
5db730475d6d
tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3349
diff
changeset
|
10 basehgrc = f.read() |
5db730475d6d
tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3349
diff
changeset
|
11 f.close() |
3349
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
12 |
28678
870dae78234c
py3: make test-ui-verbosity use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
12865
diff
changeset
|
13 print(' hgrc settings command line options final result ') |
870dae78234c
py3: make test-ui-verbosity use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
12865
diff
changeset
|
14 print(' quiet verbo debug quiet verbo debug quiet verbo debug') |
3349
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
15 |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
16 for i in xrange(64): |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
17 hgrc_quiet = bool(i & 1<<0) |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
18 hgrc_verbose = bool(i & 1<<1) |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
19 hgrc_debug = bool(i & 1<<2) |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
20 cmd_quiet = bool(i & 1<<3) |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
21 cmd_verbose = bool(i & 1<<4) |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
22 cmd_debug = bool(i & 1<<5) |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
23 |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
24 f = open(hgrc, 'w') |
5523
5db730475d6d
tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3349
diff
changeset
|
25 f.write(basehgrc) |
5db730475d6d
tests/*: avoid losing the original settings from $HGRCPATH
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
3349
diff
changeset
|
26 f.write('\n[ui]\n') |
3349
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
27 if hgrc_quiet: |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
28 f.write('quiet = True\n') |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
29 if hgrc_verbose: |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
30 f.write('verbose = True\n') |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
31 if hgrc_debug: |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
32 f.write('debug = True\n') |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
33 f.close() |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
34 |
30559
d83ca854fa21
ui: factor out ui.load() to create a ui without loading configs (API)
Yuya Nishihara <yuya@tcha.org>
parents:
28842
diff
changeset
|
35 u = uimod.ui.load() |
8136
6b5522cb2ad2
ui: refactor option setting
Matt Mackall <mpm@selenic.com>
parents:
5523
diff
changeset
|
36 if cmd_quiet or cmd_debug or cmd_verbose: |
6b5522cb2ad2
ui: refactor option setting
Matt Mackall <mpm@selenic.com>
parents:
5523
diff
changeset
|
37 u.setconfig('ui', 'quiet', str(bool(cmd_quiet))) |
6b5522cb2ad2
ui: refactor option setting
Matt Mackall <mpm@selenic.com>
parents:
5523
diff
changeset
|
38 u.setconfig('ui', 'verbose', str(bool(cmd_verbose))) |
6b5522cb2ad2
ui: refactor option setting
Matt Mackall <mpm@selenic.com>
parents:
5523
diff
changeset
|
39 u.setconfig('ui', 'debug', str(bool(cmd_debug))) |
3349
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
40 |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
41 check = '' |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
42 if u.debugflag: |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
43 if not u.verbose or u.quiet: |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
44 check = ' *' |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
45 elif u.verbose and u.quiet: |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
46 check = ' +' |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
47 |
28678
870dae78234c
py3: make test-ui-verbosity use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
12865
diff
changeset
|
48 print(('%2d %5s %5s %5s %5s %5s %5s -> %5s %5s %5s%s' |
3349
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
49 % (i, hgrc_quiet, hgrc_verbose, hgrc_debug, |
25d270e0b27f
ui.py: untangle updateopts
Alexis S. L. Carvalho <alexis@cecm.usp.br>
parents:
diff
changeset
|
50 cmd_quiet, cmd_verbose, cmd_debug, |
28678
870dae78234c
py3: make test-ui-verbosity use print_function
Pulkit Goyal <7895pulkit@gmail.com>
parents:
12865
diff
changeset
|
51 u.quiet, u.verbose, u.debugflag, check))) |