@@ -1073,40 +1073,10 @@ def RepositoryName(self):
10731073 locations won't see bogus errors.
10741074 """
10751075 fullname = self .FullName ()
1076-
1077- if os .path .exists (fullname ):
1078- project_dir = os .path .dirname (fullname )
1079-
1080- if os .path .exists (os .path .join (project_dir , ".svn" )):
1081- # If there's a .svn file in the current directory, we recursively look
1082- # up the directory tree for the top of the SVN checkout
1083- root_dir = project_dir
1084- one_up_dir = os .path .dirname (root_dir )
1085- while os .path .exists (os .path .join (one_up_dir , ".svn" )):
1086- root_dir = os .path .dirname (root_dir )
1087- one_up_dir = os .path .dirname (one_up_dir )
1088-
1089- prefix = os .path .commonprefix ([root_dir , project_dir ])
1090- return fullname [len (prefix ) + 1 :]
1091-
1092- # Not SVN <= 1.6? Try to find a git, hg, or svn top level directory by
1093- # searching up from the current path.
1094- root_dir = current_dir = os .path .dirname (fullname )
1095- while current_dir != os .path .dirname (current_dir ):
1096- if (os .path .exists (os .path .join (current_dir , ".git" )) or
1097- os .path .exists (os .path .join (current_dir , ".hg" )) or
1098- os .path .exists (os .path .join (current_dir , ".svn" ))):
1099- root_dir = current_dir
1100- current_dir = os .path .dirname (current_dir )
1101-
1102- if (os .path .exists (os .path .join (root_dir , ".git" )) or
1103- os .path .exists (os .path .join (root_dir , ".hg" )) or
1104- os .path .exists (os .path .join (root_dir , ".svn" ))):
1105- prefix = os .path .commonprefix ([root_dir , project_dir ])
1106- return fullname [len (prefix ) + 1 :]
1107-
1108- # Don't know what to do; header guard warnings may be wrong...
1109- return fullname
1076+ # XXX(bnoordhuis) Expects that cpplint.py lives in the tools/ directory.
1077+ toplevel = os .path .abspath (os .path .join (os .path .dirname (__file__ ), '..' ))
1078+ prefix = os .path .commonprefix ([fullname , toplevel ])
1079+ return fullname [len (prefix ) + 1 :]
11101080
11111081 def Split (self ):
11121082 """Splits the file into the directory, basename, and extension.
0 commit comments