diff --git a/cpplint/cpplint.py b/cpplint/cpplint.py index 807da6b..4972f9d 100755 --- a/cpplint/cpplint.py +++ b/cpplint/cpplint.py @@ -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:]