comparison tests/test-unionrepo.t @ 18944:a9c443b3b240

unionrepo: read-only operations on a union of two localrepos unionrepo is just like bundlerepo without bundles. The implementation is very similar to bundlerepo, but I don't see any obvious way to generalize it. Some most obvious use cases for this would be log and diff across local repos, as a kind of preview of pulls, for instance: $ hg -R union:repo1+repo2 heads $ hg -R union:repo1+repo2 log -r REPO1REV -r REPO2REV $ hg -R union:repo1+repo2 log -r '::REPO1REV-::REPO2REV' $ hg -R union:repo1+repo2 log -r 'ancestor(REPO1REV,REPO2REV)' $ hg -R union:repo1+repo2 diff -r REPO1REV -r REPO2REV This is going to be used in RhodeCode, and Bitbucket already uses something similar. Having a core implementation would be beneficial.
author Mads Kiilerich <madski@unity3d.com>
date Fri, 18 Jan 2013 15:54:09 +0100
parents
children e97ce4a5afc5
comparison
equal deleted inserted replaced
18943:27e8dfc2c338 18944:a9c443b3b240
1 Test unionrepo functionality
2
3 Create one repository
4
5 $ hg init repo1
6 $ cd repo1
7 $ touch repo1-0
8 $ echo repo1-0 > f
9 $ hg ci -Aqmrepo1-0
10 $ touch repo1-1
11 $ echo repo1-1 >> f
12 $ hg ci -Aqmrepo1-1
13 $ touch repo1-2
14 $ echo repo1-2 >> f
15 $ hg ci -Aqmrepo1-2
16 $ hg log --template '{rev}:{node|short} {desc|firstline}\n'
17 2:68c0685446a3 repo1-2
18 1:8a58db72e69d repo1-1
19 0:f093fec0529b repo1-0
20 $ tip1=`hg id -q`
21 $ cd ..
22
23 - and a clone with a not-completely-trivial history
24
25 $ hg clone -q repo1 --rev 0 repo2
26 $ cd repo2
27 $ touch repo2-1
28 $ sed '1irepo2-1 at top' f > f.tmp
29 $ mv f.tmp f
30 $ hg ci -Aqmrepo2-1
31 $ touch repo2-2
32 $ hg pull -q ../repo1 -r 1
33 $ hg merge -q
34 $ hg ci -Aqmrepo2-2-merge
35 $ touch repo2-3
36 $ echo repo2-3 >> f
37 $ hg ci -mrepo2-3
38 $ hg log --template '{rev}:{node|short} {desc|firstline}\n'
39 4:2f0d178c469c repo2-3
40 3:9e6fb3e0b9da repo2-2-merge
41 2:8a58db72e69d repo1-1
42 1:c337dba826e7 repo2-1
43 0:f093fec0529b repo1-0
44 $ cd ..
45
46 revisions from repo2 appear as appended / pulled to repo1
47
48 $ hg -R union:repo1+repo2 log --template '{rev}:{node|short} {desc|firstline}\n'
49 5:2f0d178c469c repo2-3
50 4:9e6fb3e0b9da repo2-2-merge
51 3:c337dba826e7 repo2-1
52 2:68c0685446a3 repo1-2
53 1:8a58db72e69d repo1-1
54 0:f093fec0529b repo1-0
55
56 manifest can be retrieved for revisions in both repos
57
58 $ hg -R union:repo1+repo2 mani -r $tip1
59 f
60 repo1-0
61 repo1-1
62 repo1-2
63 $ hg -R union:repo1+repo2 mani -r 4
64 f
65 repo1-0
66 repo1-1
67 repo2-1
68 repo2-2
69
70 files can be retrieved form both repos
71
72 $ hg -R repo1 cat repo1/f -r2
73 repo1-0
74 repo1-1
75 repo1-2
76
77 $ hg -R union:repo1+repo2 cat -r$tip1 repo1/f
78 repo1-0
79 repo1-1
80 repo1-2
81
82 $ hg -R union:repo1+repo2 cat -r4 $TESTTMP/repo1/f
83 repo2-1 at top
84 repo1-0
85 repo1-1
86
87 files can be compared across repos
88
89 $ hg -R union:repo1+repo2 diff -r$tip1 -rtip
90 diff -r 68c0685446a3 -r 2f0d178c469c f
91 --- a/f Thu Jan 01 00:00:00 1970 +0000
92 +++ b/f Thu Jan 01 00:00:00 1970 +0000
93 @@ -1,3 +1,4 @@
94 +repo2-1 at top
95 repo1-0
96 repo1-1
97 -repo1-2
98 +repo2-3
99
100 heads from both repos are found correctly
101
102 $ hg -R union:repo1+repo2 heads --template '{rev}:{node|short} {desc|firstline}\n'
103 5:2f0d178c469c repo2-3
104 2:68c0685446a3 repo1-2
105
106 revsets works across repos
107
108 $ hg -R union:repo1+repo2 id -r "ancestor($tip1, 5)"
109 8a58db72e69d
110
111 annotate works - an indication that linkrevs works
112
113 $ hg --cwd repo1 -R union:../repo2 annotate $TESTTMP/repo1/f -r tip
114 3: repo2-1 at top
115 0: repo1-0
116 1: repo1-1
117 5: repo2-3
118
119 union repos can be cloned ... and clones works correctly
120
121 $ hg clone -U union:repo1+repo2 repo3
122 requesting all changes
123 adding changesets
124 adding manifests
125 adding file changes
126 added 6 changesets with 11 changes to 6 files (+1 heads)
127
128 $ hg -R repo3 paths
129 default = union:repo1+repo2
130
131 $ hg -R repo3 verify
132 checking changesets
133 checking manifests
134 crosschecking files in changesets and manifests
135 checking files
136 6 files, 6 changesets, 11 total revisions
137
138 $ hg -R repo3 heads --template '{rev}:{node|short} {desc|firstline}\n'
139 5:2f0d178c469c repo2-3
140 2:68c0685446a3 repo1-2
141
142 $ hg -R repo3 log --template '{rev}:{node|short} {desc|firstline}\n'
143 5:2f0d178c469c repo2-3
144 4:9e6fb3e0b9da repo2-2-merge
145 3:c337dba826e7 repo2-1
146 2:68c0685446a3 repo1-2
147 1:8a58db72e69d repo1-1
148 0:f093fec0529b repo1-0