Mercurial > hg
comparison hgext/largefiles/lfutil.py @ 16066:6a42846cf769 stable
i18n: use util.pconvert() instead of 'str.replace()' for problematic encoding
some problematic encodings use backslash as part of multi-byte characters.
util.pconvert() can treat strings in such encodings correctly, if
win32mbcs is enabled, but str.replace() can not.
author | FUJIWARA Katsunori <foozy@lares.dti.ne.jp> |
---|---|
date | Sun, 05 Feb 2012 22:58:31 +0900 |
parents | d4c0fa71de01 |
children | 3e1efb458e8b |
comparison
equal
deleted
inserted
replaced
16064:7e5a281a082c | 16066:6a42846cf769 |
---|---|
301 # it repo-relative so lfadd() can pass it to repo_add(). So leave | 301 # it repo-relative so lfadd() can pass it to repo_add(). So leave |
302 # it up to the caller to use repo.wjoin() to get an absolute path. | 302 # it up to the caller to use repo.wjoin() to get an absolute path. |
303 # 2) Join with '/' because that's what dirstate always uses, even on | 303 # 2) Join with '/' because that's what dirstate always uses, even on |
304 # Windows. Change existing separator to '/' first in case we are | 304 # Windows. Change existing separator to '/' first in case we are |
305 # passed filenames from an external source (like the command line). | 305 # passed filenames from an external source (like the command line). |
306 return shortname + '/' + filename.replace(os.sep, '/') | 306 return shortname + '/' + util.pconvert(filename) |
307 | 307 |
308 def isstandin(filename): | 308 def isstandin(filename): |
309 '''Return true if filename is a big file standin. filename must be | 309 '''Return true if filename is a big file standin. filename must be |
310 in Mercurial's internal form (slash-separated).''' | 310 in Mercurial's internal form (slash-separated).''' |
311 return filename.startswith(shortname + '/') | 311 return filename.startswith(shortname + '/') |
312 | 312 |
313 def splitstandin(filename): | 313 def splitstandin(filename): |
314 # Split on / because that's what dirstate always uses, even on Windows. | 314 # Split on / because that's what dirstate always uses, even on Windows. |
315 # Change local separator to / first just in case we are passed filenames | 315 # Change local separator to / first just in case we are passed filenames |
316 # from an external source (like the command line). | 316 # from an external source (like the command line). |
317 bits = filename.replace(os.sep, '/').split('/', 1) | 317 bits = util.pconvert(filename).split('/', 1) |
318 if len(bits) == 2 and bits[0] == shortname: | 318 if len(bits) == 2 and bits[0] == shortname: |
319 return bits[1] | 319 return bits[1] |
320 else: | 320 else: |
321 return None | 321 return None |
322 | 322 |
431 def httpsendfile(ui, filename): | 431 def httpsendfile(ui, filename): |
432 return httpconnection.httpsendfile(ui, filename, 'rb') | 432 return httpconnection.httpsendfile(ui, filename, 'rb') |
433 | 433 |
434 def unixpath(path): | 434 def unixpath(path): |
435 '''Return a version of path normalized for use with the lfdirstate.''' | 435 '''Return a version of path normalized for use with the lfdirstate.''' |
436 return os.path.normpath(path).replace(os.sep, '/') | 436 return util.pconvert(os.path.normpath(path)) |
437 | 437 |
438 def islfilesrepo(repo): | 438 def islfilesrepo(repo): |
439 return ('largefiles' in repo.requirements and | 439 return ('largefiles' in repo.requirements and |
440 util.any(shortname + '/' in f[0] for f in repo.store.datafiles())) | 440 util.any(shortname + '/' in f[0] for f in repo.store.datafiles())) |
441 | 441 |