Make revert more resilient to partial sync failure.
Improve revert to skip over non managed directory and to clobber invalid
checkouts.
R=dpranke@chromium.org
BUG=
TEST=
Review URL: http://codereview.chromium.org/8227033
git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@105103 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/gclient_scm.py b/gclient_scm.py
index c33793c..8519fa9 100644
--- a/gclient_scm.py
+++ b/gclient_scm.py
@@ -920,12 +920,30 @@
doesn't know about them.
"""
if not os.path.isdir(self.checkout_path):
+ if os.path.exists(self.checkout_path):
+ gclient_utils.rmtree(self.checkout_path)
# svn revert won't work if the directory doesn't exist. It needs to
# checkout instead.
print('\n_____ %s is missing, synching instead' % self.relpath)
# Don't reuse the args.
return self.update(options, [], file_list)
+ if not os.path.isdir(os.path.join(self.checkout_path, '.svn')):
+ if os.path.isdir(os.path.join(self.checkout_path, '.git')):
+ print('________ found .git directory; skipping %s' % self.relpath)
+ return
+ if os.path.isdir(os.path.join(self.checkout_path, '.hg')):
+ print('________ found .hg directory; skipping %s' % self.relpath)
+ return
+ if not options.force:
+ raise gclient_utils.Error('Invalid checkout path, aborting')
+ print(
+ '\n_____ %s is not a valid svn checkout, synching instead' %
+ self.relpath)
+ gclient_utils.rmtree(self.checkout_path)
+ # Don't reuse the args.
+ return self.update(options, [], file_list)
+
def printcb(file_status):
file_list.append(file_status[1])
if logging.getLogger().isEnabledFor(logging.INFO):