Support svn 1.7 directory structure.

Committing on behalf of Reid Kleckner <rnk@google.com>.
BUG=chromium:102890
This commit is contained in:
erg@google.com 2011-11-30 01:12:00 +00:00
parent 7f8919375d
commit 3dc7426aed

10
cpplint/cpplint.py vendored
View File

@ -713,16 +713,18 @@ class FileInfo:
prefix = os.path.commonprefix([root_dir, project_dir]) prefix = os.path.commonprefix([root_dir, project_dir])
return fullname[len(prefix) + 1:] return fullname[len(prefix) + 1:]
# Not SVN? Try to find a git or hg top level directory by searching up # Not SVN <= 1.6? Try to find a git, hg, or svn top level directory by
# from the current path. # searching up from the current path.
root_dir = os.path.dirname(fullname) root_dir = os.path.dirname(fullname)
while (root_dir != os.path.dirname(root_dir) and while (root_dir != os.path.dirname(root_dir) and
not os.path.exists(os.path.join(root_dir, ".git")) and not os.path.exists(os.path.join(root_dir, ".git")) and
not os.path.exists(os.path.join(root_dir, ".hg"))): not os.path.exists(os.path.join(root_dir, ".hg")) and
not os.path.exists(os.path.join(root_dir, ".svn"))):
root_dir = os.path.dirname(root_dir) root_dir = os.path.dirname(root_dir)
if (os.path.exists(os.path.join(root_dir, ".git")) or if (os.path.exists(os.path.join(root_dir, ".git")) or
os.path.exists(os.path.join(root_dir, ".hg"))): os.path.exists(os.path.join(root_dir, ".hg")) or
os.path.exists(os.path.join(root_dir, ".svn"))):
prefix = os.path.commonprefix([root_dir, project_dir]) prefix = os.path.commonprefix([root_dir, project_dir])
return fullname[len(prefix) + 1:] return fullname[len(prefix) + 1:]