Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1133)

Unified Diff: svn_utils.py

Issue 6020010: Destroy svn_utils.py. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/commit-queue
Patch Set: Rebase against trunk and include a fix to import checkout directly Created 10 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « checkout.py ('k') | tests/checkout_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: svn_utils.py
diff --git a/svn_utils.py b/svn_utils.py
deleted file mode 100644
index e588481ae56ef9fcdb57ec57589aae869f30f7a3..0000000000000000000000000000000000000000
--- a/svn_utils.py
+++ /dev/null
@@ -1,111 +0,0 @@
-# Copyright (c) 2010 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-"""Utility functions to call subversion, apply and revert patches."""
-
-import logging
-import os
-
-import find_depot_tools # pylint: disable=W0611
-import gclient_utils
-import scm
-
-import subprocess2
-
-
-def svn(args, **kwargs):
- """Runs svn and throws an exception if the command failed."""
- return subprocess2.check_call(
- ['svn'] + args + ['--no-auth-cache', '--non-interactive'], **kwargs)
-
-
-def capture_svn(args, **kwargs):
- """Runs svn and throws an exception if the command failed. Returns the output.
- """
- cmd = ['svn'] + args + ['--no-auth-cache', '--non-interactive']
- return subprocess2.check_capture(cmd, **kwargs)
-
-
-def parse_svn_info(output, key):
- """Returns value for key from svn info output.
-
- Case insensitive.
- """
- values = {}
- for line in output.splitlines(False):
- if not line:
- continue
- k, v = line.split(':', 1)
- k = k.strip().lower()
- v = v.strip()
- assert not k in values
- values[k] = v
- return values.get(key, None)
-
-
-def revert(url, directory, user, pwd):
- """Reverts local modifications or checks out if the directory is not present.
- """
- assert url
- assert bool(user) == bool(pwd)
- flags = ['--ignore-externals']
- if user:
- flags.extend(['--username', user, '--password', pwd])
-
- if not os.path.isdir(directory):
- logging.info('Directory %s is not present, checking it out.' % directory)
- svn(['checkout', url, directory] + flags)
- else:
- for file_status in scm.SVN.CaptureStatus(directory):
- file_path = os.path.join(directory, file_status[1])
- if file_status[0][0] == 'X':
- # Ignore externals.
- logging.info('Ignoring external %s' % file_path)
- continue
-
- logging.info('%s%s' % (file_status[0], file_status[1]))
-
- if file_status[0].isspace():
- raise EnvironmentError(
- 'No idea what is the status of %s.\n'
- 'You just found a bug in gclient, please ping '
- 'maruel@chromium.org ASAP!' % file_path)
-
- # svn revert is really stupid. It fails on inconsistent line-endings,
- # on switched directories, etc. So take no chance and delete everything!
- try:
- if not os.path.exists(file_path):
- pass
- elif os.path.isfile(file_path) or os.path.islink(file_path):
- logging.info('os.remove(%s)' % file_path)
- os.remove(file_path)
- elif os.path.isdir(file_path):
- logging.info('gclient_utils.RemoveDirectory(%s)' % file_path)
- gclient_utils.RemoveDirectory(file_path)
- else:
- logging.error('no idea what is %s.\nYou just found a bug in gclient'
- ', please ping maruel@chromium.org ASAP!' % file_path)
- except EnvironmentError:
- logging.error('Failed to remove %s.' % file_path)
-
- # Revive files that were deleted above.
- svn(['update', '--force'] + flags, cwd=directory)
-
- out = subprocess2.check_capture(['svn', 'info', '.'], cwd=directory)
- return int(parse_svn_info(out, 'revision'))
-
-
-def update_committer(url, revision, committer, password, new_author, cwd):
- """Changes the author of a commit a posteriori.
-
- This is necessary since the actual commit is done with a "commit-bot"
- credential but the original patch author needs to be assigned authorship
- of the revision.
- """
- svn(['propset', '--revprop', 'svn:author',
- '-r', revision,
- new_author,
- '--username', committer,
- '--password', password,
- url],
- cwd=cwd)
« no previous file with comments | « checkout.py ('k') | tests/checkout_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698