##// END OF EJS Templates
convert: separate trunk detection from branch layout detection...
Edouard Gomez -
r5854:8b95f598 default
parent child Browse files
Show More
@@ -181,46 +181,48 class svn_source(converter_source):
181 181 return False
182 182
183 183 def getheads(self):
184 # detect standard /branches, /tags, /trunk layout
184
185 def getcfgpath(name, rev):
186 cfgpath = self.ui.config('convert', 'svn.' + name)
187 path = (cfgpath or name).strip('/')
188 if not self.exists(path, rev):
189 if cfgpath:
190 raise util.Abort(_('expected %s to be at %r, but not found')
191 % (name, path))
192 return None
193 self.ui.note(_('found %s at %r\n') % (name, path))
194 return path
195
185 196 rev = optrev(self.last_changed)
186 rpath = self.url.strip('/')
187 cfgtrunk = self.ui.config('convert', 'svn.trunk')
188 cfgbranches = self.ui.config('convert', 'svn.branches')
189 cfgtags = self.ui.config('convert', 'svn.tags')
190 trunk = (cfgtrunk or 'trunk').strip('/')
191 branches = (cfgbranches or 'branches').strip('/')
192 tags = (cfgtags or 'tags').strip('/')
193 if self.exists(trunk, rev) and self.exists(branches, rev) and self.exists(tags, rev):
194 self.ui.note('found trunk at %r, branches at %r and tags at %r\n' %
195 (trunk, branches, tags))
196 oldmodule = self.module
197 oldmodule = ''
198 trunk = getcfgpath('trunk', rev)
199 tags = getcfgpath('tags', rev)
200 branches = getcfgpath('branches', rev)
201
202 # If the project has a trunk or branches, we will extract heads
203 # from them. We keep the project root otherwise.
204 if trunk:
205 oldmodule = self.module or ''
197 206 self.module += '/' + trunk
198 207 lt = self.latest(self.module, self.last_changed)
199 208 self.head = self.revid(lt)
200 self.heads = [self.head]
209
210 # First head in the list is the module's head
211 self.heads = [self.head]
212 self.tags = '%s/%s' % (oldmodule , (tags or 'tags'))
213
214 # Check if branches bring a few more heads to the list
215 if branches:
216 rpath = self.url.strip('/')
201 217 branchnames = svn.client.ls(rpath + '/' + branches, rev, False,
202 218 self.ctx)
203 219 for branch in branchnames.keys():
204 if oldmodule:
205 module = oldmodule + '/' + branches + '/' + branch
206 else:
207 module = '/' + branches + '/' + branch
220 module = '%s/%s/%s' % (oldmodule, branches, branch)
208 221 brevnum = self.latest(module, self.last_changed)
209 222 brev = self.revid(brevnum, module)
210 223 self.ui.note('found branch %s at %d\n' % (branch, brevnum))
211 224 self.heads.append(brev)
212 225
213 if oldmodule:
214 self.tags = '%s/%s' % (oldmodule, tags)
215 else:
216 self.tags = '/%s' % tags
217
218 elif cfgtrunk or cfgbranches or cfgtags:
219 raise util.Abort('trunk/branch/tags layout expected, but not found')
220 else:
221 self.ui.note('working with one branch\n')
222 self.heads = [self.head]
223 self.tags = tags
224 226 return self.heads
225 227
226 228 def getfile(self, file, rev):
@@ -120,3 +120,58 cd A-hg
120 120 hg glog --template '#rev# #desc|firstline# files: #files#\n'
121 121 hg tags -q
122 122 cd ..
123
124 ########################################
125
126 echo "# now tests that it works with trunk/tags layout, but no branches yet"
127 echo
128 echo % initial svn import
129 mkdir projB
130 cd projB
131 mkdir trunk
132 mkdir tags
133 cd ..
134
135 svnurl=file://$svnpath/svn-repo/projB
136 svn import -m "init projB" projB $svnurl | fix_path
137
138
139 echo % update svn repository
140 svn co $svnurl/trunk B | fix_path
141 cd B
142 echo hello > letter.txt
143 svn add letter.txt
144 svn ci -m hello
145
146 echo world >> letter.txt
147 svn ci -m world
148
149 svn copy -m "tag v0.1" $svnurl/trunk $svnurl/tags/v0.1
150
151 echo 'nice day today!' >> letter.txt
152 svn ci -m "nice day"
153 cd ..
154
155 echo % convert to hg once
156 hg convert $svnurl B-hg
157
158 echo % update svn repository again
159 cd B
160 echo "see second letter" >> letter.txt
161 echo "nice to meet you" > letter2.txt
162 svn add letter2.txt
163 svn ci -m "second letter"
164
165 svn copy -m "tag v0.2" $svnurl/trunk $svnurl/tags/v0.2
166
167 echo "blah-blah-blah" >> letter2.txt
168 svn ci -m "work in progress"
169 cd ..
170
171 echo % test incremental conversion
172 hg convert $svnurl B-hg
173
174 cd B-hg
175 hg glog --template '#rev# #desc|firstline# files: #files#\n'
176 hg tags -q
177 cd ..
@@ -118,3 +118,71 o 0 init projA files:
118 118 tip
119 119 v0.2
120 120 v0.1
121 # now tests that it works with trunk/tags layout, but no branches yet
122
123 % initial svn import
124 Adding projB/trunk
125 Adding projB/tags
126
127 Committed revision 12.
128 % update svn repository
129 Checked out revision 12.
130 A letter.txt
131 Adding letter.txt
132 Transmitting file data .
133 Committed revision 13.
134 Sending letter.txt
135 Transmitting file data .
136 Committed revision 14.
137
138 Committed revision 15.
139 Sending letter.txt
140 Transmitting file data .
141 Committed revision 16.
142 % convert to hg once
143 initializing destination B-hg repository
144 scanning source...
145 sorting...
146 converting...
147 3 init projB
148 2 hello
149 1 world
150 0 nice day
151 updating tags
152 % update svn repository again
153 A letter2.txt
154 Sending letter.txt
155 Adding letter2.txt
156 Transmitting file data ..
157 Committed revision 17.
158
159 Committed revision 18.
160 Sending letter2.txt
161 Transmitting file data .
162 Committed revision 19.
163 % test incremental conversion
164 scanning source...
165 sorting...
166 converting...
167 1 second letter
168 0 work in progress
169 updating tags
170 o 7 update tags files: .hgtags
171 |
172 o 6 work in progress files: letter2.txt
173 |
174 o 5 second letter files: letter.txt letter2.txt
175 |
176 o 4 update tags files: .hgtags
177 |
178 o 3 nice day files: letter.txt
179 |
180 o 2 world files: letter.txt
181 |
182 o 1 hello files: letter.txt
183 |
184 o 0 init projB files:
185
186 tip
187 v0.2
188 v0.1
General Comments 0
You need to be logged in to leave comments. Login now