##// END OF EJS Templates
tests: use new, use-case-specific methods from merge module...
Martin von Zweigbergk -
r44884:0e5e192a default
parent child Browse files
Show More
@@ -1,93 +1,93 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 as uimod,
6 ui as uimod,
7 )
7 )
8
8
9 u = uimod.ui.load()
9 u = uimod.ui.load()
10
10
11 repo = hg.repository(u, b'test1', create=1)
11 repo = hg.repository(u, b'test1', create=1)
12 os.chdir('test1')
12 os.chdir('test1')
13
13
14
14
15 def commit(text, time):
15 def commit(text, time):
16 repo.commit(text=text, date=b"%d 0" % time)
16 repo.commit(text=text, date=b"%d 0" % time)
17
17
18
18
19 def addcommit(name, time):
19 def addcommit(name, time):
20 f = open(name, 'wb')
20 f = open(name, 'wb')
21 f.write(b'%s\n' % name)
21 f.write(b'%s\n' % name)
22 f.close()
22 f.close()
23 repo[None].add([name])
23 repo[None].add([name])
24 commit(name, time)
24 commit(name, time)
25
25
26
26
27 def update(rev):
27 def update(rev):
28 merge.update(repo, rev, branchmerge=False, force=True)
28 merge.clean_update(repo[rev])
29
29
30
30
31 def merge_(rev):
31 def merge_(rev):
32 merge.update(repo, rev, branchmerge=True, force=False)
32 merge.merge(repo[rev])
33
33
34
34
35 if __name__ == '__main__':
35 if __name__ == '__main__':
36 addcommit(b"A", 0)
36 addcommit(b"A", 0)
37 addcommit(b"B", 1)
37 addcommit(b"B", 1)
38
38
39 update(0)
39 update(0)
40 addcommit(b"C", 2)
40 addcommit(b"C", 2)
41
41
42 merge_(1)
42 merge_(1)
43 commit(b"D", 3)
43 commit(b"D", 3)
44
44
45 update(2)
45 update(2)
46 addcommit(b"E", 4)
46 addcommit(b"E", 4)
47 addcommit(b"F", 5)
47 addcommit(b"F", 5)
48
48
49 update(3)
49 update(3)
50 addcommit(b"G", 6)
50 addcommit(b"G", 6)
51
51
52 merge_(5)
52 merge_(5)
53 commit(b"H", 7)
53 commit(b"H", 7)
54
54
55 update(5)
55 update(5)
56 addcommit(b"I", 8)
56 addcommit(b"I", 8)
57
57
58 # Ancestors
58 # Ancestors
59 print('Ancestors of 5')
59 print('Ancestors of 5')
60 for r in repo.changelog.ancestors([5]):
60 for r in repo.changelog.ancestors([5]):
61 print(r, end=' ')
61 print(r, end=' ')
62
62
63 print('\nAncestors of 6 and 5')
63 print('\nAncestors of 6 and 5')
64 for r in repo.changelog.ancestors([6, 5]):
64 for r in repo.changelog.ancestors([6, 5]):
65 print(r, end=' ')
65 print(r, end=' ')
66
66
67 print('\nAncestors of 5 and 4')
67 print('\nAncestors of 5 and 4')
68 for r in repo.changelog.ancestors([5, 4]):
68 for r in repo.changelog.ancestors([5, 4]):
69 print(r, end=' ')
69 print(r, end=' ')
70
70
71 print('\nAncestors of 7, stop at 6')
71 print('\nAncestors of 7, stop at 6')
72 for r in repo.changelog.ancestors([7], 6):
72 for r in repo.changelog.ancestors([7], 6):
73 print(r, end=' ')
73 print(r, end=' ')
74
74
75 print('\nAncestors of 7, including revs')
75 print('\nAncestors of 7, including revs')
76 for r in repo.changelog.ancestors([7], inclusive=True):
76 for r in repo.changelog.ancestors([7], inclusive=True):
77 print(r, end=' ')
77 print(r, end=' ')
78
78
79 print('\nAncestors of 7, 5 and 3, including revs')
79 print('\nAncestors of 7, 5 and 3, including revs')
80 for r in repo.changelog.ancestors([7, 5, 3], inclusive=True):
80 for r in repo.changelog.ancestors([7, 5, 3], inclusive=True):
81 print(r, end=' ')
81 print(r, end=' ')
82
82
83 # Descendants
83 # Descendants
84 print('\n\nDescendants of 5')
84 print('\n\nDescendants of 5')
85 for r in repo.changelog.descendants([5]):
85 for r in repo.changelog.descendants([5]):
86 print(r, end=' ')
86 print(r, end=' ')
87
87
88 print('\nDescendants of 5 and 3')
88 print('\nDescendants of 5 and 3')
89 for r in repo.changelog.descendants([5, 3]):
89 for r in repo.changelog.descendants([5, 3]):
90 print(r, end=' ')
90 print(r, end=' ')
91
91
92 print('\nDescendants of 5 and 4')
92 print('\nDescendants of 5 and 4')
93 print(*repo.changelog.descendants([5, 4]), sep=' ')
93 print(*repo.changelog.descendants([5, 4]), sep=' ')
General Comments 0
You need to be logged in to leave comments. Login now