From 5e1696994bc688d9fae1deae344a1c7770b2d0a8 Mon Sep 17 00:00:00 2001 From: "erg@google.com" Date: Thu, 28 Jan 2010 20:17:01 +0000 Subject: [PATCH] Check for mercurial checkouts in addition to svn and git. Patch by Florian Loitsch --- cpplint/cpplint.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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:]