Chromium Code Reviews| Index: drover.py |
| diff --git a/drover.py b/drover.py |
| index bb4de0f01a9a71c01b2a256461267c3779ad261b..704611106243dd591dca15c99418f704a7260f34 100755 |
| --- a/drover.py |
| +++ b/drover.py |
| @@ -9,6 +9,7 @@ import re |
| import string |
| import sys |
| import urllib2 |
| +import urlparse |
| import breakpad # pylint: disable=W0611 |
| @@ -421,6 +422,43 @@ def getBranchForMilestone(milestone): |
| return None |
| +def getSVNAuthInfo(folder=None): |
| + """Fetches SVN authorization information in the subversion auth folder and |
| + returns it as a dictionary of dictionaries.""" |
| + if not folder: |
| + if sys.platform == 'win32': |
| + folder = '%%APPDATA%\\Subversion\\auth' |
| + else: |
| + folder = '~/.subversion/auth' |
| + folder = os.path.expandvars(os.path.expanduser(folder)) |
| + svn_simple_folder = os.path.join(folder, 'svn.simple') |
| + results = {} |
| + try: |
| + for auth_file in os.listdir(svn_simple_folder): |
| + # Read the SVN auth file, convert it into a dictionary, and store it. |
| + results[auth_file] = dict(re.findall(r'K [0-9]+\n(.*)\nV [0-9]+\n(.*)\n', |
| + open(os.path.join(svn_simple_folder, auth_file)).read())) |
| + except Exception as _: |
| + pass |
| + return results |
| + |
| + |
| +def getCurrentSVNUsers(url): |
| + """Tries to fetch the current SVN in the current checkout by scanning the |
| + SVN authorization folder for a match with the current SVN URL.""" |
| + netloc = urlparse.urlparse(url)[1] |
| + auth_infos = getSVNAuthInfo() |
| + results = [] |
| + for _, auth_info in auth_infos.iteritems(): |
| + if ('svn:realmstring' in auth_info |
| + and netloc in urlparse.urlparse(auth_info['svn:realmstring'])[1]): |
| + username = auth_info['username'] |
| + results.append(username) |
| + if 'google.com' in username: |
| + results.append(username.replace('google.com', 'chromium.org')) |
| + return results |
| + |
| + |
| def prompt(question): |
| while True: |
| print question + " [y|n]:", |
| @@ -537,10 +575,18 @@ def drover(options, args): |
| if not author: |
| author = getAuthor(TRUNK_URL, revision) |
| + # Check that the author of the CL is different than the user making |
| + # the revert. If they're the same, then we'll want to prompt the user |
| + # for a different reviewer to TBR. |
| + current_users = getCurrentSVNUsers(BASE_URL) |
| + if options.revert and author in current_users: |
| + PROMPT_FOR_AUTHOR = True |
|
cmp
2012/11/30 21:08:57
PROMPT_FOR_AUTHOR is a constant, and it's incorrec
|
| + |
| filename = str(revision)+".txt" |
| out = open(filename,"w") |
| - out.write(action +" " + str(revision) + " - ") |
| - out.write(getRevisionLog(url, revision)) |
| + out.write(action +" " + str(revision) + "\n") |
| + for line in getRevisionLog(url, revision).splitlines(): |
| + out.write('> %s\n' % line) |
| if (author): |
| out.write("\nTBR=" + author) |
| out.close() |