Fix gclient revert for external, switched and conflicted directories.

TEST=gclient revert more stuff but stops reverting external directories
BUG=none

Review URL: http://codereview.chromium.org/208025


git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@26672 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
maruel@chromium.org 16 years ago
parent 5e73b0cfa1
commit 754960e99b

@ -69,6 +69,7 @@ __author__ = "darinf@gmail.com (Darin Fisher)"
__version__ = "0.3.3" __version__ = "0.3.3"
import errno import errno
import logging
import optparse import optparse
import os import os
import re import re
@ -1168,6 +1169,9 @@ def Main(argv):
option_parser.print_help() option_parser.print_help()
return 0 return 0
if options.verbose:
logging.basicConfig(level=logging.DEBUG)
# Files used for configuration and state saving. # Files used for configuration and state saving.
options.config_filename = os.environ.get("GCLIENT_FILE", ".gclient") options.config_filename = os.environ.get("GCLIENT_FILE", ".gclient")
options.entries_filename = ".gclient_entries" options.entries_filename = ".gclient_entries"

@ -13,6 +13,7 @@
# limitations under the License. # limitations under the License.
import logging
import os import os
import re import re
import subprocess import subprocess
@ -218,20 +219,25 @@ class SCMWrapper(object):
# Don't reuse the args. # Don't reuse the args.
return self.update(options, [], file_list) return self.update(options, [], file_list)
files = CaptureSVNStatus(path)
# Batch the command. # Batch the command.
files_to_revert = [] files_to_revert = []
for file in files: for file in CaptureSVNStatus(path):
file_path = os.path.join(path, file[1]) file_path = os.path.join(path, file[1])
if file_path[0][0] == 'X':
# Ignore externals.
continue
print(file_path) print(file_path)
# Unversioned file or unexpected unversioned file. # Unversioned file, unexpected unversioned files, switched directories
if file[0][0] in ('?', '~'): # or conflicted trees.
# Remove extraneous file. Also remove unexpected unversioned if file[0][0] in ('?', '~') or file[0][4] == 'S' or file[0][6] == 'C':
# directories. svn won't touch them but we want to delete these. # Remove then since svn revert won't touch them.
file_list.append(file_path)
try: try:
# TODO(maruel): Look if it is a file or a directory.
logging.info('os.remove(%s)' % file_path)
os.remove(file_path) os.remove(file_path)
except EnvironmentError: except EnvironmentError:
logging.info('gclient_utils.RemoveDirectory(%s)' % file_path)
gclient_utils.RemoveDirectory(file_path) gclient_utils.RemoveDirectory(file_path)
if file[0][0] != '?': if file[0][0] != '?':

Loading…
Cancel
Save