Check for mercurial checkouts in addition to svn and git.

Patch by Florian Loitsch <floitsch@google.com>
This commit is contained in:
erg@google.com 2010-01-28 20:17:01 +00:00
parent 9ec7bd6269
commit 5e1696994b

10
cpplint/cpplint.py vendored
View File

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