##// END OF EJS Templates
mercurial_source: add --filemap support
Alexis S. L. Carvalho -
r5379:d3e51dc8 default
parent child Browse files
Show More
@@ -0,0 +1,124 b''
1 #!/bin/sh
2
3 HGMERGE=true; export HGMERGE
4
5 echo '[extensions]' >> $HGRCPATH
6 echo 'hgext.graphlog =' >> $HGRCPATH
7 echo 'hgext.convert =' >> $HGRCPATH
8
9 glog()
10 {
11 hg glog --template '#rev# "#desc#" files: #files#\n' "$@"
12 }
13
14 hg init source
15 cd source
16
17 echo foo > foo
18 echo baz > baz
19 mkdir dir
20 echo dir/file >> dir/file
21 echo dir/file2 >> dir/file2
22 hg ci -d '0 0' -qAm '0: add foo baz dir/'
23
24 echo bar > bar
25 echo quux > quux
26 hg copy foo copied
27 hg ci -d '1 0' -qAm '1: add bar quux; copy foo to copied'
28
29 echo >> foo
30 hg ci -d '2 0' -m '2: change foo'
31
32 hg up -qC 1
33 echo >> bar
34 echo >> quux
35 hg ci -d '3 0' -m '3: change bar quux'
36
37 hg up -qC 2
38 hg merge -qr 3
39 echo >> bar
40 echo >> baz
41 hg ci -d '4 0' -m '4: first merge; change bar baz'
42
43 echo >> bar
44 echo 1 >> baz
45 echo >> quux
46 hg ci -d '5 0' -m '5: change bar baz quux'
47
48 hg up -qC 4
49 echo >> foo
50 echo 2 >> baz
51 hg ci -d '6 0' -m '6: change foo baz'
52
53 hg up -qC 5
54 hg merge -qr 6
55 echo >> bar
56 hg ci -d '7 0' -m '7: second merge; change bar'
57
58 echo >> foo
59 hg ci -m '8: change foo'
60
61 glog
62
63 echo '% final file versions in this repo:'
64 hg manifest --debug
65 hg debugrename copied
66 echo
67
68 cd ..
69
70 splitrepo()
71 {
72 msg="$1"
73 files="$2"
74 opts=$3
75 echo "% $files: $msg"
76 prefix=`echo "$files" | sed -e 's/ /-/g'`
77 fmap="$prefix.fmap"
78 repo="$prefix.repo"
79 for i in $files; do
80 echo "include $i" >> "$fmap"
81 done
82 hg -q convert $opts --filemap "$fmap" --datesort source "$repo"
83 glog -R "$repo"
84 hg -R "$repo" manifest --debug
85 }
86
87 splitrepo 'skip unwanted merges; use 1st parent in 1st merge, 2nd in 2nd' foo
88
89 splitrepo 'merges are not merges anymore' bar
90
91 splitrepo '1st merge is not a merge anymore; 2nd still is' baz
92
93 splitrepo 'we add additional merges when they are interesting' 'foo quux'
94
95 splitrepo 'partial conversion' 'bar quux' '-r 3'
96 splitrepo 'complete the partial conversion' 'bar quux'
97
98 rm -r foo.repo
99 splitrepo 'partial conversion' 'foo' '-r 3'
100 splitrepo 'complete the partial conversion' 'foo'
101
102 splitrepo 'copied file; source not included in new repo' copied
103 hg --cwd copied.repo debugrename copied
104
105 splitrepo 'copied file; source included in new repo' 'foo copied'
106 hg --cwd foo-copied.repo debugrename copied
107
108 cat > renames.fmap <<EOF
109 include dir
110 exclude dir/file2
111 rename dir dir2
112 include foo
113 include copied
114 rename foo foo2
115 rename copied copied2
116 EOF
117 hg -q convert --filemap renames.fmap --datesort source renames.repo
118 glog -R renames.repo
119 hg -R renames.repo manifest --debug
120 hg --cwd renames.repo debugrename copied2
121 echo 'copied:'
122 hg --cwd source cat copied
123 echo 'copied2:'
124 hg --cwd renames.repo cat copied2
@@ -0,0 +1,154 b''
1 @ 8 "8: change foo" files: foo
2 |
3 o 7 "7: second merge; change bar" files: bar baz
4 |\
5 | o 6 "6: change foo baz" files: baz foo
6 | |
7 o | 5 "5: change bar baz quux" files: bar baz quux
8 |/
9 o 4 "4: first merge; change bar baz" files: bar baz
10 |\
11 | o 3 "3: change bar quux" files: bar quux
12 | |
13 o | 2 "2: change foo" files: foo
14 |/
15 o 1 "1: add bar quux; copy foo to copied" files: bar copied quux
16 |
17 o 0 "0: add foo baz dir/" files: baz dir/file dir/file2 foo
18
19 % final file versions in this repo:
20 9463f52fe115e377cf2878d4fc548117211063f2 644 bar
21 94c1be4dfde2ee8d78db8bbfcf81210813307c3d 644 baz
22 6ca237634e1f6bee1b6db94292fb44f092a25842 644 copied
23 3e20847584beff41d7cd16136b7331ab3d754be0 644 dir/file
24 75e6d3f8328f5f6ace6bf10b98df793416a09dca 644 dir/file2
25 9a7b52012991e4873687192c3e17e61ba3e837a3 644 foo
26 bc3eca3f47023a3e70ca0d8cc95a22a6827db19d 644 quux
27 copied renamed from foo:2ed2a3912a0b24502043eae84ee4b279c18b90dd
28
29 % foo: skip unwanted merges; use 1st parent in 1st merge, 2nd in 2nd
30 o 3 "8: change foo" files: foo
31 |
32 o 2 "6: change foo baz" files: foo
33 |
34 o 1 "2: change foo" files: foo
35 |
36 o 0 "0: add foo baz dir/" files: foo
37
38 9a7b52012991e4873687192c3e17e61ba3e837a3 644 foo
39 % bar: merges are not merges anymore
40 o 4 "7: second merge; change bar" files: bar
41 |
42 o 3 "5: change bar baz quux" files: bar
43 |
44 o 2 "4: first merge; change bar baz" files: bar
45 |
46 o 1 "3: change bar quux" files: bar
47 |
48 o 0 "1: add bar quux; copy foo to copied" files: bar
49
50 9463f52fe115e377cf2878d4fc548117211063f2 644 bar
51 % baz: 1st merge is not a merge anymore; 2nd still is
52 o 4 "7: second merge; change bar" files: baz
53 |\
54 | o 3 "6: change foo baz" files: baz
55 | |
56 o | 2 "5: change bar baz quux" files: baz
57 |/
58 o 1 "4: first merge; change bar baz" files: baz
59 |
60 o 0 "0: add foo baz dir/" files: baz
61
62 94c1be4dfde2ee8d78db8bbfcf81210813307c3d 644 baz
63 % foo quux: we add additional merges when they are interesting
64 o 8 "8: change foo" files: foo
65 |
66 o 7 "7: second merge; change bar" files:
67 |\
68 | o 6 "6: change foo baz" files: foo
69 | |
70 o | 5 "5: change bar baz quux" files: quux
71 |/
72 o 4 "4: first merge; change bar baz" files:
73 |\
74 | o 3 "3: change bar quux" files: quux
75 | |
76 o | 2 "2: change foo" files: foo
77 |/
78 o 1 "1: add bar quux; copy foo to copied" files: quux
79 |
80 o 0 "0: add foo baz dir/" files: foo
81
82 9a7b52012991e4873687192c3e17e61ba3e837a3 644 foo
83 bc3eca3f47023a3e70ca0d8cc95a22a6827db19d 644 quux
84 % bar quux: partial conversion
85 o 1 "3: change bar quux" files: bar quux
86 |
87 o 0 "1: add bar quux; copy foo to copied" files: bar quux
88
89 b79105bedc55102f394e90a789c9c380117c1b4a 644 bar
90 db0421cc6b685a458c8d86c7d5c004f94429ea23 644 quux
91 % bar quux: complete the partial conversion
92 o 4 "7: second merge; change bar" files: bar
93 |
94 o 3 "5: change bar baz quux" files: bar quux
95 |
96 o 2 "4: first merge; change bar baz" files: bar
97 |
98 o 1 "3: change bar quux" files: bar quux
99 |
100 o 0 "1: add bar quux; copy foo to copied" files: bar quux
101
102 9463f52fe115e377cf2878d4fc548117211063f2 644 bar
103 bc3eca3f47023a3e70ca0d8cc95a22a6827db19d 644 quux
104 % foo: partial conversion
105 o 0 "0: add foo baz dir/" files: foo
106
107 2ed2a3912a0b24502043eae84ee4b279c18b90dd 644 foo
108 % foo: complete the partial conversion
109 o 3 "8: change foo" files: foo
110 |
111 o 2 "6: change foo baz" files: foo
112 |
113 o 1 "2: change foo" files: foo
114 |
115 o 0 "0: add foo baz dir/" files: foo
116
117 9a7b52012991e4873687192c3e17e61ba3e837a3 644 foo
118 % copied: copied file; source not included in new repo
119 o 0 "1: add bar quux; copy foo to copied" files: copied
120
121 2ed2a3912a0b24502043eae84ee4b279c18b90dd 644 copied
122 copied not renamed
123 % foo copied: copied file; source included in new repo
124 o 4 "8: change foo" files: foo
125 |
126 o 3 "6: change foo baz" files: foo
127 |
128 o 2 "2: change foo" files: foo
129 |
130 o 1 "1: add bar quux; copy foo to copied" files: copied
131 |
132 o 0 "0: add foo baz dir/" files: foo
133
134 6ca237634e1f6bee1b6db94292fb44f092a25842 644 copied
135 9a7b52012991e4873687192c3e17e61ba3e837a3 644 foo
136 copied renamed from foo:2ed2a3912a0b24502043eae84ee4b279c18b90dd
137 o 4 "8: change foo" files: foo2
138 |
139 o 3 "6: change foo baz" files: foo2
140 |
141 o 2 "2: change foo" files: foo2
142 |
143 o 1 "1: add bar quux; copy foo to copied" files: copied2
144 |
145 o 0 "0: add foo baz dir/" files: dir2/file foo2
146
147 e5e3d520be9be45937d0b06b004fadcd6c221fa2 644 copied2
148 3e20847584beff41d7cd16136b7331ab3d754be0 644 dir2/file
149 9a7b52012991e4873687192c3e17e61ba3e837a3 644 foo2
150 copied2 renamed from foo2:2ed2a3912a0b24502043eae84ee4b279c18b90dd
151 copied:
152 foo
153 copied2:
154 foo
@@ -177,6 +177,7 b' class mercurial_source(converter_source)'
177 177 raise NoRepo("could not open hg repo %s as source" % path)
178 178 self.lastrev = None
179 179 self.lastctx = None
180 self._changescache = None
180 181
181 182 def changectx(self, rev):
182 183 if self.lastrev != rev:
@@ -202,7 +203,10 b' class mercurial_source(converter_source)'
202 203
203 204 def getchanges(self, rev):
204 205 ctx = self.changectx(rev)
205 m, a, r = self.repo.status(ctx.parents()[0].node(), ctx.node())[:3]
206 if self._changescache and self._changescache[0] == rev:
207 m, a, r = self._changescache[1]
208 else:
209 m, a, r = self.repo.status(ctx.parents()[0].node(), ctx.node())[:3]
206 210 changes = [(name, rev) for name in m + a + r]
207 211 changes.sort()
208 212 return (changes, self.getcopies(ctx, m + a))
@@ -226,3 +230,14 b' class mercurial_source(converter_source)'
226 230 def gettags(self):
227 231 tags = [t for t in self.repo.tagslist() if t[0] != 'tip']
228 232 return dict([(name, hex(node)) for name, node in tags])
233
234 def getchangedfiles(self, rev, i):
235 ctx = self.changectx(rev)
236 i = i or 0
237 changes = self.repo.status(ctx.parents()[i].node(), ctx.node())[:3]
238
239 if i == 0:
240 self._changescache = (rev, changes)
241
242 return changes[0] + changes[1] + changes[2]
243
General Comments 0
You need to be logged in to leave comments. Login now