# HG changeset patch # User Shun-ichi GOTO # Date 1199881835 -32400 # Node ID 83c354c4d5296aa8e47b2d9d54270dcd27b2e7a0 # Parent 111ed8c871bffc3b7d8a65b397aed3cc689ee8f4 Add endswithsep() and use it instead of using os.sep and os.altsep directly. This change is intended to allow hooking endswithsep() by win32mbcs extension for MBCS support. diff -r 111ed8c871bf -r 83c354c4d529 mercurial/cmdutil.py --- a/mercurial/cmdutil.py Wed Jan 09 21:30:13 2008 +0900 +++ b/mercurial/cmdutil.py Wed Jan 09 21:30:35 2008 +0900 @@ -462,7 +462,7 @@ if len(pats) > 1 or util.patkind(pats[0], None)[0]: raise util.Abort(_('with multiple sources, destination must be an ' 'existing directory')) - if dest.endswith(os.sep) or os.altsep and dest.endswith(os.altsep): + if util.endswithsep(dest): raise util.Abort(_('destination %s is not a directory') % dest) tfn = targetpathfn diff -r 111ed8c871bf -r 83c354c4d529 mercurial/dirstate.py --- a/mercurial/dirstate.py Wed Jan 09 21:30:13 2008 +0900 +++ b/mercurial/dirstate.py Wed Jan 09 21:30:35 2008 +0900 @@ -74,7 +74,7 @@ if cwd == self._root: return '' # self._root ends with a path separator if self._root is '/' or 'C:\' rootsep = self._root - if not rootsep.endswith(os.sep): + if not util.endswithsep(rootsep): rootsep += os.sep if cwd.startswith(rootsep): return cwd[len(rootsep):] @@ -410,7 +410,7 @@ # self._root may end with a path separator when self._root == '/' common_prefix_len = len(self._root) - if not self._root.endswith(os.sep): + if not util.endswithsep(self._root): common_prefix_len += 1 normpath = util.normpath diff -r 111ed8c871bf -r 83c354c4d529 mercurial/util.py --- a/mercurial/util.py Wed Jan 09 21:30:13 2008 +0900 +++ b/mercurial/util.py Wed Jan 09 21:30:35 2008 +0900 @@ -341,7 +341,7 @@ """return the canonical path of myname, given cwd and root""" if root == os.sep: rootsep = os.sep - elif root.endswith(os.sep): + elif endswithsep(root): rootsep = root else: rootsep = root + os.sep @@ -882,6 +882,10 @@ """return True if patches should be applied in binary mode by default.""" return os.name == 'nt' +def endswithsep(path): + '''Check path ends with os.sep or os.altsep.''' + return path.endswith(os.sep) or os.altsep and path.endswith(os.altsep) + # Platform specific variants if os.name == 'nt': import msvcrt