annotate tests/test-revlog-ancestry.py @ 50791:d51a76b5262b

wrapfunction: use sysstr instead of bytes as argument in "schemes" This is as valid and simpler, it will help us to eventually get ride of `safehasattr`.
author Pierre-Yves David <pierre-yves.david@octobus.net>
date Fri, 03 Feb 2023 04:25:57 +0100
parents 7b289a70c2c8
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
1 import os
28763
abe605bbf0de py3: use absolute_import in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 27344
diff changeset
2 from mercurial import (
abe605bbf0de py3: use absolute_import in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 27344
diff changeset
3 hg,
abe605bbf0de py3: use absolute_import in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 27344
diff changeset
4 merge,
28842
d466facc5a6e tests: alias ui as uimod in test-revlog-ancestry/test-ui-verbosity
Yuya Nishihara <yuya@tcha.org>
parents: 28764
diff changeset
5 ui as uimod,
28763
abe605bbf0de py3: use absolute_import in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 27344
diff changeset
6 )
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
7
30559
d83ca854fa21 ui: factor out ui.load() to create a ui without loading configs (API)
Yuya Nishihara <yuya@tcha.org>
parents: 28842
diff changeset
8 u = uimod.ui.load()
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
9
36482
14d2371216ba py3: add b'' prefixes in tests/test-revlog-ancestry.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30559
diff changeset
10 repo = hg.repository(u, b'test1', create=1)
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
11 os.chdir('test1')
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
12
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40366
diff changeset
13
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
14 def commit(text, time):
36482
14d2371216ba py3: add b'' prefixes in tests/test-revlog-ancestry.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30559
diff changeset
15 repo.commit(text=text, date=b"%d 0" % time)
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
16
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40366
diff changeset
17
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
18 def addcommit(name, time):
36483
5a029f049854 py3: make sure we open the file in bytes mode
Pulkit Goyal <7895pulkit@gmail.com>
parents: 36482
diff changeset
19 f = open(name, 'wb')
36482
14d2371216ba py3: add b'' prefixes in tests/test-revlog-ancestry.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30559
diff changeset
20 f.write(b'%s\n' % name)
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
21 f.close()
50039
7b289a70c2c8 dirstate: use wlock and changing_files context in `test-revlog-ancestry`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48875
diff changeset
22 with repo.wlock():
7b289a70c2c8 dirstate: use wlock and changing_files context in `test-revlog-ancestry`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48875
diff changeset
23 with repo.dirstate.changing_files(repo):
7b289a70c2c8 dirstate: use wlock and changing_files context in `test-revlog-ancestry`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48875
diff changeset
24 repo[None].add([name])
7b289a70c2c8 dirstate: use wlock and changing_files context in `test-revlog-ancestry`
Pierre-Yves David <pierre-yves.david@octobus.net>
parents: 48875
diff changeset
25 commit(name, time)
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
26
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40366
diff changeset
27
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
28 def update(rev):
44400
0e5e192adb6f tests: use new, use-case-specific methods from merge module
Martin von Zweigbergk <martinvonz@google.com>
parents: 43076
diff changeset
29 merge.clean_update(repo[rev])
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
30
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40366
diff changeset
31
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
32 def merge_(rev):
44400
0e5e192adb6f tests: use new, use-case-specific methods from merge module
Martin von Zweigbergk <martinvonz@google.com>
parents: 43076
diff changeset
33 merge.merge(repo[rev])
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
34
43076
2372284d9457 formatting: blacken the codebase
Augie Fackler <augie@google.com>
parents: 40366
diff changeset
35
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
36 if __name__ == '__main__':
36482
14d2371216ba py3: add b'' prefixes in tests/test-revlog-ancestry.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30559
diff changeset
37 addcommit(b"A", 0)
14d2371216ba py3: add b'' prefixes in tests/test-revlog-ancestry.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30559
diff changeset
38 addcommit(b"B", 1)
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
39
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
40 update(0)
36482
14d2371216ba py3: add b'' prefixes in tests/test-revlog-ancestry.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30559
diff changeset
41 addcommit(b"C", 2)
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
42
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
43 merge_(1)
36482
14d2371216ba py3: add b'' prefixes in tests/test-revlog-ancestry.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30559
diff changeset
44 commit(b"D", 3)
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
45
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
46 update(2)
36482
14d2371216ba py3: add b'' prefixes in tests/test-revlog-ancestry.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30559
diff changeset
47 addcommit(b"E", 4)
14d2371216ba py3: add b'' prefixes in tests/test-revlog-ancestry.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30559
diff changeset
48 addcommit(b"F", 5)
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
49
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
50 update(3)
36482
14d2371216ba py3: add b'' prefixes in tests/test-revlog-ancestry.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30559
diff changeset
51 addcommit(b"G", 6)
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
52
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
53 merge_(5)
36482
14d2371216ba py3: add b'' prefixes in tests/test-revlog-ancestry.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30559
diff changeset
54 commit(b"H", 7)
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
55
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
56 update(5)
36482
14d2371216ba py3: add b'' prefixes in tests/test-revlog-ancestry.py
Pulkit Goyal <7895pulkit@gmail.com>
parents: 30559
diff changeset
57 addcommit(b"I", 8)
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
58
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
59 # Ancestors
28764
e677b8daeb3f py3: use print_function in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28763
diff changeset
60 print('Ancestors of 5')
16866
91f3ac205816 revlog: ancestors(*revs) becomes ancestors(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents: 11303
diff changeset
61 for r in repo.changelog.ancestors([5]):
28764
e677b8daeb3f py3: use print_function in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28763
diff changeset
62 print(r, end=' ')
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
63
28764
e677b8daeb3f py3: use print_function in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28763
diff changeset
64 print('\nAncestors of 6 and 5')
16866
91f3ac205816 revlog: ancestors(*revs) becomes ancestors(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents: 11303
diff changeset
65 for r in repo.changelog.ancestors([6, 5]):
28764
e677b8daeb3f py3: use print_function in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28763
diff changeset
66 print(r, end=' ')
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
67
28764
e677b8daeb3f py3: use print_function in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28763
diff changeset
68 print('\nAncestors of 5 and 4')
16866
91f3ac205816 revlog: ancestors(*revs) becomes ancestors(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents: 11303
diff changeset
69 for r in repo.changelog.ancestors([5, 4]):
28764
e677b8daeb3f py3: use print_function in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28763
diff changeset
70 print(r, end=' ')
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
71
28764
e677b8daeb3f py3: use print_function in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28763
diff changeset
72 print('\nAncestors of 7, stop at 6')
16868
eb88ed4269c5 revlog: add optional stoprev arg to revlog.ancestors()
Joshua Redstone <joshua.redstone@fb.com>
parents: 16867
diff changeset
73 for r in repo.changelog.ancestors([7], 6):
28764
e677b8daeb3f py3: use print_function in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28763
diff changeset
74 print(r, end=' ')
16868
eb88ed4269c5 revlog: add optional stoprev arg to revlog.ancestors()
Joshua Redstone <joshua.redstone@fb.com>
parents: 16867
diff changeset
75
28764
e677b8daeb3f py3: use print_function in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28763
diff changeset
76 print('\nAncestors of 7, including revs')
18081
f88c60e740a1 revlog.ancestors: add support for including revs
Siddharth Agarwal <sid0@fb.com>
parents: 16868
diff changeset
77 for r in repo.changelog.ancestors([7], inclusive=True):
28764
e677b8daeb3f py3: use print_function in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28763
diff changeset
78 print(r, end=' ')
18081
f88c60e740a1 revlog.ancestors: add support for including revs
Siddharth Agarwal <sid0@fb.com>
parents: 16868
diff changeset
79
28764
e677b8daeb3f py3: use print_function in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28763
diff changeset
80 print('\nAncestors of 7, 5 and 3, including revs')
18081
f88c60e740a1 revlog.ancestors: add support for including revs
Siddharth Agarwal <sid0@fb.com>
parents: 16868
diff changeset
81 for r in repo.changelog.ancestors([7, 5, 3], inclusive=True):
28764
e677b8daeb3f py3: use print_function in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28763
diff changeset
82 print(r, end=' ')
18081
f88c60e740a1 revlog.ancestors: add support for including revs
Siddharth Agarwal <sid0@fb.com>
parents: 16868
diff changeset
83
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
84 # Descendants
28764
e677b8daeb3f py3: use print_function in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28763
diff changeset
85 print('\n\nDescendants of 5')
16867
1093ad1e8903 revlog: descendants(*revs) becomes descendants(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents: 16866
diff changeset
86 for r in repo.changelog.descendants([5]):
28764
e677b8daeb3f py3: use print_function in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28763
diff changeset
87 print(r, end=' ')
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
88
28764
e677b8daeb3f py3: use print_function in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28763
diff changeset
89 print('\nDescendants of 5 and 3')
16867
1093ad1e8903 revlog: descendants(*revs) becomes descendants(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents: 16866
diff changeset
90 for r in repo.changelog.descendants([5, 3]):
28764
e677b8daeb3f py3: use print_function in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28763
diff changeset
91 print(r, end=' ')
6872
c7cc40fd74f6 Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff changeset
92
28764
e677b8daeb3f py3: use print_function in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28763
diff changeset
93 print('\nDescendants of 5 and 4')
e677b8daeb3f py3: use print_function in test-revlog-ancestry.py
Robert Stanca <robert.stanca7@gmail.com>
parents: 28763
diff changeset
94 print(*repo.changelog.descendants([5, 4]), sep=' ')