##// END OF EJS Templates
tests: alias ui as uimod in test-revlog-ancestry/test-ui-verbosity
Yuya Nishihara -
r28842:d466facc default
parent child Browse files
Show More
@@ -1,88 +1,88 b''
1 from __future__ import absolute_import, print_function
1 from __future__ import absolute_import, print_function
2 import os
2 import os
3 from mercurial import (
3 from mercurial import (
4 hg,
4 hg,
5 merge,
5 merge,
6 ui,
6 ui as uimod,
7 )
7 )
8
8
9 u = ui.ui()
9 u = uimod.ui()
10
10
11 repo = hg.repository(u, 'test1', create=1)
11 repo = hg.repository(u, 'test1', create=1)
12 os.chdir('test1')
12 os.chdir('test1')
13
13
14 def commit(text, time):
14 def commit(text, time):
15 repo.commit(text=text, date="%d 0" % time)
15 repo.commit(text=text, date="%d 0" % time)
16
16
17 def addcommit(name, time):
17 def addcommit(name, time):
18 f = open(name, 'w')
18 f = open(name, 'w')
19 f.write('%s\n' % name)
19 f.write('%s\n' % name)
20 f.close()
20 f.close()
21 repo[None].add([name])
21 repo[None].add([name])
22 commit(name, time)
22 commit(name, time)
23
23
24 def update(rev):
24 def update(rev):
25 merge.update(repo, rev, False, True)
25 merge.update(repo, rev, False, True)
26
26
27 def merge_(rev):
27 def merge_(rev):
28 merge.update(repo, rev, True, False)
28 merge.update(repo, rev, True, False)
29
29
30 if __name__ == '__main__':
30 if __name__ == '__main__':
31 addcommit("A", 0)
31 addcommit("A", 0)
32 addcommit("B", 1)
32 addcommit("B", 1)
33
33
34 update(0)
34 update(0)
35 addcommit("C", 2)
35 addcommit("C", 2)
36
36
37 merge_(1)
37 merge_(1)
38 commit("D", 3)
38 commit("D", 3)
39
39
40 update(2)
40 update(2)
41 addcommit("E", 4)
41 addcommit("E", 4)
42 addcommit("F", 5)
42 addcommit("F", 5)
43
43
44 update(3)
44 update(3)
45 addcommit("G", 6)
45 addcommit("G", 6)
46
46
47 merge_(5)
47 merge_(5)
48 commit("H", 7)
48 commit("H", 7)
49
49
50 update(5)
50 update(5)
51 addcommit("I", 8)
51 addcommit("I", 8)
52
52
53 # Ancestors
53 # Ancestors
54 print('Ancestors of 5')
54 print('Ancestors of 5')
55 for r in repo.changelog.ancestors([5]):
55 for r in repo.changelog.ancestors([5]):
56 print(r, end=' ')
56 print(r, end=' ')
57
57
58 print('\nAncestors of 6 and 5')
58 print('\nAncestors of 6 and 5')
59 for r in repo.changelog.ancestors([6, 5]):
59 for r in repo.changelog.ancestors([6, 5]):
60 print(r, end=' ')
60 print(r, end=' ')
61
61
62 print('\nAncestors of 5 and 4')
62 print('\nAncestors of 5 and 4')
63 for r in repo.changelog.ancestors([5, 4]):
63 for r in repo.changelog.ancestors([5, 4]):
64 print(r, end=' ')
64 print(r, end=' ')
65
65
66 print('\nAncestors of 7, stop at 6')
66 print('\nAncestors of 7, stop at 6')
67 for r in repo.changelog.ancestors([7], 6):
67 for r in repo.changelog.ancestors([7], 6):
68 print(r, end=' ')
68 print(r, end=' ')
69
69
70 print('\nAncestors of 7, including revs')
70 print('\nAncestors of 7, including revs')
71 for r in repo.changelog.ancestors([7], inclusive=True):
71 for r in repo.changelog.ancestors([7], inclusive=True):
72 print(r, end=' ')
72 print(r, end=' ')
73
73
74 print('\nAncestors of 7, 5 and 3, including revs')
74 print('\nAncestors of 7, 5 and 3, including revs')
75 for r in repo.changelog.ancestors([7, 5, 3], inclusive=True):
75 for r in repo.changelog.ancestors([7, 5, 3], inclusive=True):
76 print(r, end=' ')
76 print(r, end=' ')
77
77
78 # Descendants
78 # Descendants
79 print('\n\nDescendants of 5')
79 print('\n\nDescendants of 5')
80 for r in repo.changelog.descendants([5]):
80 for r in repo.changelog.descendants([5]):
81 print(r, end=' ')
81 print(r, end=' ')
82
82
83 print('\nDescendants of 5 and 3')
83 print('\nDescendants of 5 and 3')
84 for r in repo.changelog.descendants([5, 3]):
84 for r in repo.changelog.descendants([5, 3]):
85 print(r, end=' ')
85 print(r, end=' ')
86
86
87 print('\nDescendants of 5 and 4')
87 print('\nDescendants of 5 and 4')
88 print(*repo.changelog.descendants([5, 4]), sep=' ')
88 print(*repo.changelog.descendants([5, 4]), sep=' ')
@@ -1,49 +1,51 b''
1 from __future__ import absolute_import, print_function
1 from __future__ import absolute_import, print_function
2
2
3 import os
3 import os
4 from mercurial import ui
4 from mercurial import (
5 ui as uimod,
6 )
5
7
6 hgrc = os.environ['HGRCPATH']
8 hgrc = os.environ['HGRCPATH']
7 f = open(hgrc)
9 f = open(hgrc)
8 basehgrc = f.read()
10 basehgrc = f.read()
9 f.close()
11 f.close()
10
12
11 print(' hgrc settings command line options final result ')
13 print(' hgrc settings command line options final result ')
12 print(' quiet verbo debug quiet verbo debug quiet verbo debug')
14 print(' quiet verbo debug quiet verbo debug quiet verbo debug')
13
15
14 for i in xrange(64):
16 for i in xrange(64):
15 hgrc_quiet = bool(i & 1<<0)
17 hgrc_quiet = bool(i & 1<<0)
16 hgrc_verbose = bool(i & 1<<1)
18 hgrc_verbose = bool(i & 1<<1)
17 hgrc_debug = bool(i & 1<<2)
19 hgrc_debug = bool(i & 1<<2)
18 cmd_quiet = bool(i & 1<<3)
20 cmd_quiet = bool(i & 1<<3)
19 cmd_verbose = bool(i & 1<<4)
21 cmd_verbose = bool(i & 1<<4)
20 cmd_debug = bool(i & 1<<5)
22 cmd_debug = bool(i & 1<<5)
21
23
22 f = open(hgrc, 'w')
24 f = open(hgrc, 'w')
23 f.write(basehgrc)
25 f.write(basehgrc)
24 f.write('\n[ui]\n')
26 f.write('\n[ui]\n')
25 if hgrc_quiet:
27 if hgrc_quiet:
26 f.write('quiet = True\n')
28 f.write('quiet = True\n')
27 if hgrc_verbose:
29 if hgrc_verbose:
28 f.write('verbose = True\n')
30 f.write('verbose = True\n')
29 if hgrc_debug:
31 if hgrc_debug:
30 f.write('debug = True\n')
32 f.write('debug = True\n')
31 f.close()
33 f.close()
32
34
33 u = ui.ui()
35 u = uimod.ui()
34 if cmd_quiet or cmd_debug or cmd_verbose:
36 if cmd_quiet or cmd_debug or cmd_verbose:
35 u.setconfig('ui', 'quiet', str(bool(cmd_quiet)))
37 u.setconfig('ui', 'quiet', str(bool(cmd_quiet)))
36 u.setconfig('ui', 'verbose', str(bool(cmd_verbose)))
38 u.setconfig('ui', 'verbose', str(bool(cmd_verbose)))
37 u.setconfig('ui', 'debug', str(bool(cmd_debug)))
39 u.setconfig('ui', 'debug', str(bool(cmd_debug)))
38
40
39 check = ''
41 check = ''
40 if u.debugflag:
42 if u.debugflag:
41 if not u.verbose or u.quiet:
43 if not u.verbose or u.quiet:
42 check = ' *'
44 check = ' *'
43 elif u.verbose and u.quiet:
45 elif u.verbose and u.quiet:
44 check = ' +'
46 check = ' +'
45
47
46 print(('%2d %5s %5s %5s %5s %5s %5s -> %5s %5s %5s%s'
48 print(('%2d %5s %5s %5s %5s %5s %5s -> %5s %5s %5s%s'
47 % (i, hgrc_quiet, hgrc_verbose, hgrc_debug,
49 % (i, hgrc_quiet, hgrc_verbose, hgrc_debug,
48 cmd_quiet, cmd_verbose, cmd_debug,
50 cmd_quiet, cmd_verbose, cmd_debug,
49 u.quiet, u.verbose, u.debugflag, check)))
51 u.quiet, u.verbose, u.debugflag, check)))
General Comments 0
You need to be logged in to leave comments. Login now