Skip to content

Commit

Permalink
Remove svn code in checkperms.py after the git migration.
Browse files Browse the repository at this point in the history
Review URL: https://codereview.chromium.org/503853002

Cr-Commit-Position: refs/heads/master@{#292001}
  • Loading branch information
leizleiz authored and Commit bot committed Aug 26, 2014
1 parent ea8fe7d commit 51c6b19
Showing 1 changed file with 1 addition and 64 deletions.
65 changes: 1 addition & 64 deletions tools/checkperms/checkperms.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

"""Makes sure files have the right permissions.
Some developers have broken SCM configurations that flip the svn:executable
Some developers have broken SCM configurations that flip the executable
permission on for no good reason. Unix developers who run ls --color will then
see .cc files in green and get confused.
Expand Down Expand Up @@ -230,34 +230,6 @@ def capture(cmd, cwd):
return p.communicate()[0]


def get_svn_info(dir_path):
"""Returns svn meta-data for a svn checkout."""
if not os.path.isdir(dir_path):
return {}
out = capture(['svn', 'info', '.', '--non-interactive'], dir_path)
return dict(l.split(': ', 1) for l in out.splitlines() if l)


def get_svn_url(dir_path):
return get_svn_info(dir_path).get('URL')


def get_svn_root(dir_path):
"""Returns the svn checkout root or None."""
svn_url = get_svn_url(dir_path)
if not svn_url:
return None
logging.info('svn url: %s' % svn_url)
while True:
parent = os.path.dirname(dir_path)
if parent == dir_path:
return None
svn_url = svn_url.rsplit('/', 1)[0]
if svn_url != get_svn_url(parent):
return dir_path
dir_path = parent


def get_git_root(dir_path):
"""Returns the git checkout root or None."""
root = capture(['git', 'rev-parse', '--show-toplevel'], dir_path).strip()
Expand Down Expand Up @@ -402,24 +374,6 @@ def list_dir(self, start_dir):
)


class ApiSvnQuick(ApiBase):
"""Returns all files in svn-versioned directories, independent of the fact if
they are versionned.
Uses svn info in each directory to determine which directories should be
crawled.
"""
def __init__(self, *args):
super(ApiSvnQuick, self).__init__(*args)
self.url = get_svn_url(self.root_dir)

def check_dir(self, rel_path):
url = self.url + '/' + rel_path
if get_svn_url(os.path.join(self.root_dir, rel_path)) != url:
return []
return super(ApiSvnQuick, self).check_dir(rel_path)


class ApiAllFilesAtOnceBase(ApiBase):
_files = None

Expand All @@ -439,18 +393,6 @@ def _get_all_files(self):
raise NotImplementedError()


class ApiSvn(ApiAllFilesAtOnceBase):
"""Returns all the subversion controlled files.
Warning: svn ls is abnormally slow.
"""
def _get_all_files(self):
cmd = ['svn', 'ls', '--non-interactive', '--recursive']
return (
x for x in capture(cmd, self.root_dir).splitlines()
if not x.endswith(os.path.sep))


class ApiGit(ApiAllFilesAtOnceBase):
def _get_all_files(self):
return capture(['git', 'ls-files'], cwd=self.root_dir).splitlines()
Expand All @@ -459,11 +401,6 @@ def _get_all_files(self):
def get_scm(dir_path, bare):
"""Returns a properly configured ApiBase instance."""
cwd = os.getcwd()
root = get_svn_root(dir_path or cwd)
if root:
if not bare:
print('Found subversion checkout at %s' % root)
return ApiSvnQuick(dir_path or root, bare)
root = get_git_root(dir_path or cwd)
if root:
if not bare:
Expand Down

0 comments on commit 51c6b19

Please sign in to comment.