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

Unified Diff: scm.py

Issue 6613025: Improve SVN.Revert() to catch more corner cases. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 10 months 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 | « no previous file | tests/gclient_scm_test.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scm.py
diff --git a/scm.py b/scm.py
index 2690f1f9bb4fa3f83d3ef0bfc4c544668ec63064..471b9d7475e333fae4dcf1a4b608729fcb1d2d39 100644
--- a/scm.py
+++ b/scm.py
@@ -878,21 +878,26 @@ class SVN(object):
# svn revert is really stupid. It fails on inconsistent line-endings,
# on switched directories, etc. So take no chance and delete everything!
- if file_status[0][0] == 'D':
- # Deleted file requires manual intervention and require calling
+ if file_status[0][0] in ('D', 'A') or file_status[0][2] != ' ':
+ # Added, deleted file requires manual intervention and require calling
# revert, like for properties.
- gclient_utils.CheckCall(
- ['svn', 'revert', file_status[1]], cwd=repo_root)
+ try:
+ SVN.Capture(['revert', file_status[1]], cwd=repo_root)
+ except gclient_utils.CheckCallError:
+ if not os.path.exists(file_path):
+ continue
+ raise
+
+ if not os.path.exists(file_path):
+ continue
+
+ if 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:
- 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.critical(
- ('No idea what is %s.\nYou just found a bug in gclient'
- ', please ping maruel@chromium.org ASAP!') % file_path)
+ logging.critical(
+ ('No idea what is %s.\nYou just found a bug in gclient'
+ ', please ping maruel@chromium.org ASAP!') % file_path)
« no previous file with comments | « no previous file | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698