Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(224)

Unified Diff: scm.py

Issue 538009: Fix case sensitivity issues and svn move patches for --sub_rep on Windows.... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: '' Created 10 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/scm_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scm.py
===================================================================
--- scm.py (revision 35830)
+++ scm.py (working copy)
@@ -4,6 +4,7 @@
"""SCM-specific utility classes."""
+import glob
import os
import re
import shutil
@@ -19,6 +20,26 @@
is not None)
+def GetCasedPath(path):
+ """Elcheapos way to get the real path case on Windows."""
+ if sys.platform.startswith('win') and os.path.exists(path):
+ # Reconstruct the path.
+ path = os.path.abspath(path)
+ paths = path.split('\\')
bradn 2010/01/08 23:09:23 \\ -> os.pathsep eh, whatever
+ for i in range(len(paths)):
+ if i == 0:
+ # Skip drive letter.
+ continue
+ subpath = '\\'.join(paths[:i+1])
+ prev = len('\\'.join(paths[:i]))
+ # glob.glob will return the cased path for the last item only. This is why
+ # we are calling it in a loop. Extract the data we want and put it back
+ # into the list.
+ paths[i] = glob.glob(subpath + '*')[0][prev+1:len(subpath)]
bradn 2010/01/08 23:09:23 Can you drop the '*' come to think of it, glob sho
bradn 2010/01/08 23:09:23 actually what happens if its the shortname? oh yuc
+ path = '\\'.join(paths)
+ return path
+
+
class GIT(object):
COMMAND = "git"
@@ -587,7 +608,6 @@
file_content = ['+' + i for i in file_content.splitlines(True)]
nb_lines = len(file_content)
# We need to use / since patch on unix will fail otherwise.
- filename = filename.replace('\\', '/')
data = "Index: %s\n" % filename
data += '=' * 67 + '\n'
# Note: Should we use /dev/null instead?
@@ -616,10 +636,11 @@
The diff will always use relative paths.
"""
previous_cwd = os.getcwd()
- root = os.path.join(root or SVN.GetCheckoutRoot(previous_cwd), '')
+ root = root or SVN.GetCheckoutRoot(previous_cwd)
+ root = os.path.normcase(os.path.join(root, ''))
def RelativePath(path, root):
"""We must use relative paths."""
- if path.startswith(root):
+ if os.path.normcase(path).startswith(root):
return path[len(root):]
return path
try:
@@ -707,4 +728,4 @@
"Repository Root") != cur_dir_repo_root):
break
directory = parent
- return directory
+ return GetCasedPath(directory)
« no previous file with comments | « no previous file | tests/scm_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698