Mercurial > hg
annotate tests/test-revlog-ancestry.py @ 23344:6333412245ec stable
mq: when setting message in plain mode, separate it from header (issue4453)
Fix inconsistent handling of plain header separation in mq patcheader - and
contrary to c87f2a5a6e49, do it in the direction of having an empty line
between header and description. Plain patches are like mails and should thus
have an empty line between headers and body in compliance with RFC 822 3.1.
author | Mads Kiilerich <madski@unity3d.com> |
---|---|
date | Sun, 16 Nov 2014 19:57:40 +0100 |
parents | f88c60e740a1 |
children | 43c00ca887d1 |
rev | line source |
---|---|
6872
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
1 import os |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
2 from mercurial import hg, ui, merge |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
3 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
4 u = ui.ui() |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
5 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
6 repo = hg.repository(u, 'test1', create=1) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
7 os.chdir('test1') |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
8 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
9 def commit(text, time): |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
10 repo.commit(text=text, date="%d 0" % time) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
11 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
12 def addcommit(name, time): |
9031
3b76321aa0de
compat: use open() instead of file() everywhere
Alejandro Santos <alejolp@alejolp.com>
parents:
8656
diff
changeset
|
13 f = open(name, 'w') |
6872
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
14 f.write('%s\n' % name) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
15 f.close() |
11303
a1aad8333864
move working dir/dirstate methods from localrepo to workingctx
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
9031
diff
changeset
|
16 repo[None].add([name]) |
6872
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
17 commit(name, time) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
18 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
19 def update(rev): |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
20 merge.update(repo, rev, False, True, False) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
21 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
22 def merge_(rev): |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
23 merge.update(repo, rev, True, False, False) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
24 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
25 if __name__ == '__main__': |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
26 addcommit("A", 0) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
27 addcommit("B", 1) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
28 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
29 update(0) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
30 addcommit("C", 2) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
31 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
32 merge_(1) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
33 commit("D", 3) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
34 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
35 update(2) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
36 addcommit("E", 4) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
37 addcommit("F", 5) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
38 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
39 update(3) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
40 addcommit("G", 6) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
41 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
42 merge_(5) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
43 commit("H", 7) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
44 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
45 update(5) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
46 addcommit("I", 8) |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
47 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
48 # Ancestors |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
49 print 'Ancestors of 5' |
16866
91f3ac205816
revlog: ancestors(*revs) becomes ancestors(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents:
11303
diff
changeset
|
50 for r in repo.changelog.ancestors([5]): |
6923
ebf1462f2145
strip trailing whitespace, replace tabs by spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6872
diff
changeset
|
51 print r, |
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 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
|
54 for r in repo.changelog.ancestors([6, 5]): |
6923
ebf1462f2145
strip trailing whitespace, replace tabs by spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6872
diff
changeset
|
55 print r, |
6872
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
56 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
57 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
|
58 for r in repo.changelog.ancestors([5, 4]): |
6923
ebf1462f2145
strip trailing whitespace, replace tabs by spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6872
diff
changeset
|
59 print r, |
6872
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
60 |
16868
eb88ed4269c5
revlog: add optional stoprev arg to revlog.ancestors()
Joshua Redstone <joshua.redstone@fb.com>
parents:
16867
diff
changeset
|
61 print '\nAncestors of 7, stop at 6' |
eb88ed4269c5
revlog: add optional stoprev arg to revlog.ancestors()
Joshua Redstone <joshua.redstone@fb.com>
parents:
16867
diff
changeset
|
62 for r in repo.changelog.ancestors([7], 6): |
eb88ed4269c5
revlog: add optional stoprev arg to revlog.ancestors()
Joshua Redstone <joshua.redstone@fb.com>
parents:
16867
diff
changeset
|
63 print r, |
eb88ed4269c5
revlog: add optional stoprev arg to revlog.ancestors()
Joshua Redstone <joshua.redstone@fb.com>
parents:
16867
diff
changeset
|
64 |
18081
f88c60e740a1
revlog.ancestors: add support for including revs
Siddharth Agarwal <sid0@fb.com>
parents:
16868
diff
changeset
|
65 print '\nAncestors of 7, including revs' |
f88c60e740a1
revlog.ancestors: add support for including revs
Siddharth Agarwal <sid0@fb.com>
parents:
16868
diff
changeset
|
66 for r in repo.changelog.ancestors([7], inclusive=True): |
f88c60e740a1
revlog.ancestors: add support for including revs
Siddharth Agarwal <sid0@fb.com>
parents:
16868
diff
changeset
|
67 print r, |
f88c60e740a1
revlog.ancestors: add support for including revs
Siddharth Agarwal <sid0@fb.com>
parents:
16868
diff
changeset
|
68 |
f88c60e740a1
revlog.ancestors: add support for including revs
Siddharth Agarwal <sid0@fb.com>
parents:
16868
diff
changeset
|
69 print '\nAncestors of 7, 5 and 3, including revs' |
f88c60e740a1
revlog.ancestors: add support for including revs
Siddharth Agarwal <sid0@fb.com>
parents:
16868
diff
changeset
|
70 for r in repo.changelog.ancestors([7, 5, 3], inclusive=True): |
f88c60e740a1
revlog.ancestors: add support for including revs
Siddharth Agarwal <sid0@fb.com>
parents:
16868
diff
changeset
|
71 print r, |
f88c60e740a1
revlog.ancestors: add support for including revs
Siddharth Agarwal <sid0@fb.com>
parents:
16868
diff
changeset
|
72 |
6872
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
73 # Descendants |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
74 print '\n\nDescendants of 5' |
16867
1093ad1e8903
revlog: descendants(*revs) becomes descendants(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents:
16866
diff
changeset
|
75 for r in repo.changelog.descendants([5]): |
6923
ebf1462f2145
strip trailing whitespace, replace tabs by spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6872
diff
changeset
|
76 print r, |
6872
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
77 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
78 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
|
79 for r in repo.changelog.descendants([5, 3]): |
6923
ebf1462f2145
strip trailing whitespace, replace tabs by spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6872
diff
changeset
|
80 print r, |
6872
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
81 |
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
82 print '\nDescendants of 5 and 4' |
16867
1093ad1e8903
revlog: descendants(*revs) becomes descendants(revs) (API)
Bryan O'Sullivan <bryano@fb.com>
parents:
16866
diff
changeset
|
83 for r in repo.changelog.descendants([5, 4]): |
6923
ebf1462f2145
strip trailing whitespace, replace tabs by spaces
Dirkjan Ochtman <dirkjan@ochtman.nl>
parents:
6872
diff
changeset
|
84 print r, |
6872
c7cc40fd74f6
Add ancestors and descendants to revlog
Stefano Tortarolo <stefano.tortarolo@gmail.com>
parents:
diff
changeset
|
85 |