##// END OF EJS Templates
convert/svn: stop returning unicode revision identifiers
Patrick Mezard -
r8886:0593c5b5 default
parent child Browse files
Show More
@@ -10,7 +10,7 b' import cPickle as pickle'
10 import tempfile
10 import tempfile
11 import urllib
11 import urllib
12
12
13 from mercurial import strutil, util
13 from mercurial import strutil, util, encoding
14 from mercurial.i18n import _
14 from mercurial.i18n import _
15
15
16 # Subversion stuff. Works best with very recent Python SVN bindings
16 # Subversion stuff. Works best with very recent Python SVN bindings
@@ -50,6 +50,9 b' def geturl(path):'
50 path = os.path.normpath(os.path.abspath(path))
50 path = os.path.normpath(os.path.abspath(path))
51 if os.name == 'nt':
51 if os.name == 'nt':
52 path = '/' + util.normpath(path)
52 path = '/' + util.normpath(path)
53 # Module URL is later compared with the repository URL returned
54 # by svn API, which is UTF-8.
55 path = encoding.tolocal(path)
53 return 'file://%s' % urllib.quote(path)
56 return 'file://%s' % urllib.quote(path)
54 return path
57 return path
55
58
@@ -226,7 +229,7 b' class svn_source(converter_source):'
226 self.rootmodule = self.module
229 self.rootmodule = self.module
227 self.commits = {}
230 self.commits = {}
228 self.paths = {}
231 self.paths = {}
229 self.uuid = svn.ra.get_uuid(self.ra).decode(self.encoding)
232 self.uuid = svn.ra.get_uuid(self.ra)
230 except SubversionException:
233 except SubversionException:
231 ui.traceback()
234 ui.traceback()
232 raise NoRepo("%s does not look like a Subversion repo" % self.url)
235 raise NoRepo("%s does not look like a Subversion repo" % self.url)
@@ -253,8 +256,8 b' class svn_source(converter_source):'
253
256
254 self.head = self.latest(self.module, latest)
257 self.head = self.latest(self.module, latest)
255 if not self.head:
258 if not self.head:
256 raise util.Abort(_('no revision found in module %s') %
259 raise util.Abort(_('no revision found in module %s')
257 self.module.encode(self.encoding))
260 % self.module)
258 self.last_changed = self.revnum(self.head)
261 self.last_changed = self.revnum(self.head)
259
262
260 self._changescache = None
263 self._changescache = None
@@ -314,8 +317,8 b' class svn_source(converter_source):'
314 self.module += '/' + trunk
317 self.module += '/' + trunk
315 self.head = self.latest(self.module, self.last_changed)
318 self.head = self.latest(self.module, self.last_changed)
316 if not self.head:
319 if not self.head:
317 raise util.Abort(_('no revision found in module %s') %
320 raise util.Abort(_('no revision found in module %s')
318 self.module.encode(self.encoding))
321 % self.module)
319
322
320 # First head in the list is the module's head
323 # First head in the list is the module's head
321 self.heads = [self.head]
324 self.heads = [self.head]
@@ -333,8 +336,7 b' class svn_source(converter_source):'
333 continue
336 continue
334 brevid = self.latest(module, self.last_changed)
337 brevid = self.latest(module, self.last_changed)
335 if not brevid:
338 if not brevid:
336 self.ui.note(_('ignoring empty branch %s\n') %
339 self.ui.note(_('ignoring empty branch %s\n') % branch)
337 branch.encode(self.encoding))
338 continue
340 continue
339 self.ui.note(_('found branch %s at %d\n') %
341 self.ui.note(_('found branch %s at %d\n') %
340 (branch, self.revnum(brevid)))
342 (branch, self.revnum(brevid)))
@@ -511,16 +513,13 b' class svn_source(converter_source):'
511 self.convertfp.flush()
513 self.convertfp.flush()
512
514
513 def revid(self, revnum, module=None):
515 def revid(self, revnum, module=None):
514 if not module:
516 return 'svn:%s%s@%s' % (self.uuid, module or self.module, revnum)
515 module = self.module
516 return u"svn:%s%s@%s" % (self.uuid, module.decode(self.encoding),
517 revnum)
518
517
519 def revnum(self, rev):
518 def revnum(self, rev):
520 return int(rev.split('@')[-1])
519 return int(rev.split('@')[-1])
521
520
522 def revsplit(self, rev):
521 def revsplit(self, rev):
523 url, revnum = rev.encode(self.encoding).rsplit('@', 1)
522 url, revnum = rev.rsplit('@', 1)
524 revnum = int(revnum)
523 revnum = int(revnum)
525 parts = url.split('/', 1)
524 parts = url.split('/', 1)
526 uuid = parts.pop(0)[4:]
525 uuid = parts.pop(0)[4:]
@@ -786,7 +785,7 b' class svn_source(converter_source):'
786 desc=log,
785 desc=log,
787 parents=parents,
786 parents=parents,
788 branch=branch,
787 branch=branch,
789 rev=rev.encode('utf-8'))
788 rev=rev)
790
789
791 self.commits[rev] = cset
790 self.commits[rev] = cset
792 # The parents list is *shared* among self.paths and the
791 # The parents list is *shared* among self.paths and the
@@ -1,6 +1,6 b''
1 SVN-fs-dump-format-version: 2
1 SVN-fs-dump-format-version: 2
2
2
3 UUID: 64cf20ed-79ff-4f10-8aaf-041d1993b42e
3 UUID: 7ec0009b-ac71-43a6-9416-7fc295ee5ca1
4
4
5 Revision-number: 0
5 Revision-number: 0
6 Prop-content-length: 56
6 Prop-content-length: 56
@@ -9,7 +9,7 b' Content-length: 56'
9 K 8
9 K 8
10 svn:date
10 svn:date
11 V 27
11 V 27
12 2009-06-21T10:05:28.031033Z
12 2009-06-21T15:50:22.535630Z
13 PROPS-END
13 PROPS-END
14
14
15 Revision-number: 1
15 Revision-number: 1
@@ -27,7 +27,7 b' pmezard'
27 K 8
27 K 8
28 svn:date
28 svn:date
29 V 27
29 V 27
30 2009-06-21T10:05:28.108227Z
30 2009-06-21T15:50:22.584588Z
31 PROPS-END
31 PROPS-END
32
32
33 Node-path: branches
33 Node-path: branches
@@ -72,7 +72,7 b' pmezard'
72 K 8
72 K 8
73 svn:date
73 svn:date
74 V 27
74 V 27
75 2009-06-21T10:05:29.109026Z
75 2009-06-21T15:50:23.143007Z
76 PROPS-END
76 PROPS-END
77
77
78 Node-path: trunk/à
78 Node-path: trunk/à
@@ -125,7 +125,7 b' pmezard'
125 K 8
125 K 8
126 svn:date
126 svn:date
127 V 27
127 V 27
128 2009-06-21T10:05:32.061964Z
128 2009-06-21T15:50:26.088415Z
129 PROPS-END
129 PROPS-END
130
130
131 Node-path: trunk/è
131 Node-path: trunk/è
@@ -167,7 +167,7 b' pmezard'
167 K 8
167 K 8
168 svn:date
168 svn:date
169 V 27
169 V 27
170 2009-06-21T10:05:33.096353Z
170 2009-06-21T15:50:27.162784Z
171 PROPS-END
171 PROPS-END
172
172
173 Node-path: trunk/è
173 Node-path: trunk/è
@@ -178,3 +178,53 b' Node-path: trunk/\xc3\xb9'
178 Node-action: delete
178 Node-action: delete
179
179
180
180
181 Revision-number: 5
182 Prop-content-length: 120
183 Content-length: 120
184
185 K 7
186 svn:log
187 V 18
188 branch to branché
189 K 10
190 svn:author
191 V 7
192 pmezard
193 K 8
194 svn:date
195 V 27
196 2009-06-21T15:50:30.079728Z
197 PROPS-END
198
199 Node-path: branches/branché
200 Node-kind: dir
201 Node-action: add
202 Node-copyfrom-rev: 4
203 Node-copyfrom-path: trunk
204
205
206 Revision-number: 6
207 Prop-content-length: 121
208 Content-length: 121
209
210 K 7
211 svn:log
212 V 19
213 branch to branchée
214 K 10
215 svn:author
216 V 7
217 pmezard
218 K 8
219 svn:date
220 V 27
221 2009-06-21T15:50:33.072456Z
222 PROPS-END
223
224 Node-path: branches/branchée
225 Node-kind: dir
226 Node-action: add
227 Node-copyfrom-rev: 5
228 Node-copyfrom-path: branches/branché
229
230
@@ -35,6 +35,16 b' svn ci -m "copy files"'
35 svn rm trunk/è
35 svn rm trunk/è
36 svn rm trunk/ù
36 svn rm trunk/ù
37 svn ci -m 'remove files'
37 svn ci -m 'remove files'
38
39 # Create branches with and from weird names
40 svn up
41 svn cp trunk branches/branché
42 echo a > branches/branché/a
43 svn ci -m 'branch to branché'
44 svn up
45 svn cp branches/branché branches/branchée
46 echo a >> branches/branché/a
47 svn ci -m 'branch to branchée'
38 cd ..
48 cd ..
39
49
40 svnadmin dump svn-repo > ../encoding.svndump
50 svnadmin dump svn-repo > ../encoding.svndump
General Comments 0
You need to be logged in to leave comments. Login now