[PATCH 1 of 5] Use util.normpath() instead of direct path string operation

Shun-ichi Goto shunichi.goto at gmail.com
Wed Jan 9 07:44:02 CST 2008


# HG changeset patch
# User Shun-ichi GOTO <shunichi.goto at gmail.com>
# Date 1199881813 -32400
# Node ID 4534d9217d8d14b87ba66b6887f3eb5d91a9a072
# Parent  a780d3db1f238a083d33a4adbd811e0b87fa8151
Use util.normpath() instead of direct path string operation.

This change is intended to allow hooking normpath() by win32mbcs
extension for MBCS support.

diff -r a780d3db1f23 -r 4534d9217d8d hgext/convert/subversion.py
--- a/hgext/convert/subversion.py	Wed Jan 09 19:03:28 2008 +0900
+++ b/hgext/convert/subversion.py	Wed Jan 09 21:30:13 2008 +0900
@@ -53,7 +53,7 @@ def geturl(path):
     if os.path.isdir(path):
         path = os.path.normpath(os.path.abspath(path))
         if os.name == 'nt':
-            path = '/' + path.replace('\\', '/')
+            path = '/' + util.normpath(path)
         return 'file://%s' % path
     return path
 
@@ -770,7 +770,7 @@ class svn_sink(converter_sink, commandli
                               os.path.basename(path))
                     commandline(ui, 'svnadmin').run0('create', path)
                     created = path
-                path = path.replace('\\', '/')
+                path = util.normpath(path)
                 if not path.startswith('/'):
                     path = '/' + path
                 path = 'file://' + path
diff -r a780d3db1f23 -r 4534d9217d8d mercurial/archival.py
--- a/mercurial/archival.py	Wed Jan 09 19:03:28 2008 +0900
+++ b/mercurial/archival.py	Wed Jan 09 21:30:13 2008 +0900
@@ -15,7 +15,7 @@ def tidyprefix(dest, prefix, suffixes):
     safe for consumers.'''
 
     if prefix:
-        prefix = prefix.replace('\\', '/')
+        prefix = util.normpath(prefix)
     else:
         if not isinstance(dest, str):
             raise ValueError('dest must be string if no prefix')
diff -r a780d3db1f23 -r 4534d9217d8d mercurial/dirstate.py
--- a/mercurial/dirstate.py	Wed Jan 09 19:03:28 2008 +0900
+++ b/mercurial/dirstate.py	Wed Jan 09 21:30:13 2008 +0900
@@ -87,7 +87,7 @@ class dirstate(object):
             cwd = self.getcwd()
         path = util.pathto(self._root, cwd, f)
         if self._slash:
-            return path.replace(os.sep, '/')
+            return util.normpath(path)
         return path
 
     def __getitem__(self, key):


More information about the Mercurial-devel mailing list