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

Side by Side Diff: gclient_scm.py

Issue 9401011: Revert r121986 "If both -f and -D are specified when updating, remove all untracked directories" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « gclient.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Gclient-specific SCM-specific operations.""" 5 """Gclient-specific SCM-specific operations."""
6 6
7 import logging 7 import logging
8 import os 8 import os
9 import posixpath 9 import posixpath
10 import re 10 import re
11 import sys 11 import sys
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
435 if self._IsRebasing(): 435 if self._IsRebasing():
436 raise gclient_utils.Error('\n____ %s%s\n' 436 raise gclient_utils.Error('\n____ %s%s\n'
437 '\nConflict while rebasing this branch.\n' 437 '\nConflict while rebasing this branch.\n'
438 'Fix the conflict and run gclient again.\n' 438 'Fix the conflict and run gclient again.\n'
439 'See man git-rebase for details.\n' 439 'See man git-rebase for details.\n'
440 % (self.relpath, rev_str)) 440 % (self.relpath, rev_str))
441 441
442 if verbose: 442 if verbose:
443 print('Checked out revision %s' % self.revinfo(options, (), None)) 443 print('Checked out revision %s' % self.revinfo(options, (), None))
444 444
445 # If --force and --delete_unversioned_trees are specified, remove any
446 # untracked directories.
447 if options.force and options.delete_unversioned_trees:
448 # GIT.CaptureStatus() uses 'dit diff' to compare to a specific SHA1 (the
449 # merge-base by default), so doesn't include untracked files. So we use
450 # 'git ls-files --directory --others --exclude-standard' here directly.
451 paths = scm.GIT.Capture(
452 ['ls-files', '--directory', '--others', '--exclude-standard'],
453 self.checkout_path)
454 for path in (p for p in paths.splitlines() if p.endswith('/')):
455 print('\n_____ removing unversioned directory %s' % path)
456 gclient_utils.RemoveDirectory(os.path.join(self.checkout_path, path))
457
458
459 def revert(self, options, args, file_list): 445 def revert(self, options, args, file_list):
460 """Reverts local modifications. 446 """Reverts local modifications.
461 447
462 All reverted files will be appended to file_list. 448 All reverted files will be appended to file_list.
463 """ 449 """
464 if not os.path.isdir(self.checkout_path): 450 if not os.path.isdir(self.checkout_path):
465 # revert won't work if the directory doesn't exist. It needs to 451 # revert won't work if the directory doesn't exist. It needs to
466 # checkout instead. 452 # checkout instead.
467 print('\n_____ %s is missing, synching instead' % self.relpath) 453 print('\n_____ %s is missing, synching instead' % self.relpath)
468 # Don't reuse the args. 454 # Don't reuse the args.
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
929 to_info['Repository Root'], 915 to_info['Repository Root'],
930 self.relpath] 916 self.relpath]
931 self._Run(command, options, cwd=self._root_dir) 917 self._Run(command, options, cwd=self._root_dir)
932 from_info['URL'] = from_info['URL'].replace( 918 from_info['URL'] = from_info['URL'].replace(
933 from_info['Repository Root'], 919 from_info['Repository Root'],
934 to_info['Repository Root']) 920 to_info['Repository Root'])
935 else: 921 else:
936 if not options.force and not options.reset: 922 if not options.force and not options.reset:
937 # Look for local modifications but ignore unversioned files. 923 # Look for local modifications but ignore unversioned files.
938 for status in scm.SVN.CaptureStatus(None, self.checkout_path): 924 for status in scm.SVN.CaptureStatus(None, self.checkout_path):
939 if status[0][0] != '?': 925 if status[0] != '?':
940 raise gclient_utils.Error( 926 raise gclient_utils.Error(
941 ('Can\'t switch the checkout to %s; UUID don\'t match and ' 927 ('Can\'t switch the checkout to %s; UUID don\'t match and '
942 'there is local changes in %s. Delete the directory and ' 928 'there is local changes in %s. Delete the directory and '
943 'try again.') % (url, self.checkout_path)) 929 'try again.') % (url, self.checkout_path))
944 # Ok delete it. 930 # Ok delete it.
945 print('\n_____ switching %s to a new checkout' % self.relpath) 931 print('\n_____ switching %s to a new checkout' % self.relpath)
946 gclient_utils.RemoveDirectory(self.checkout_path) 932 gclient_utils.RemoveDirectory(self.checkout_path)
947 # We need to checkout. 933 # We need to checkout.
948 command = ['checkout', url, self.checkout_path] 934 command = ['checkout', url, self.checkout_path]
949 command = self._AddAdditionalUpdateFlags(command, options, revision) 935 command = self._AddAdditionalUpdateFlags(command, options, revision)
950 self._RunAndGetFileList(command, options, file_list, self._root_dir) 936 self._RunAndGetFileList(command, options, file_list, self._root_dir)
951 return 937 return
952 938
953 # If the provided url has a revision number that matches the revision 939 # If the provided url has a revision number that matches the revision
954 # number of the existing directory, then we don't need to bother updating. 940 # number of the existing directory, then we don't need to bother updating.
955 if not options.force and str(from_info['Revision']) == revision: 941 if not options.force and str(from_info['Revision']) == revision:
956 if options.verbose or not forced_revision: 942 if options.verbose or not forced_revision:
957 print('\n_____ %s%s' % (self.relpath, rev_str)) 943 print('\n_____ %s%s' % (self.relpath, rev_str))
958 return 944 return
959 945
960 command = ['update', self.checkout_path] 946 command = ['update', self.checkout_path]
961 command = self._AddAdditionalUpdateFlags(command, options, revision) 947 command = self._AddAdditionalUpdateFlags(command, options, revision)
962 self._RunAndGetFileList(command, options, file_list, self._root_dir) 948 self._RunAndGetFileList(command, options, file_list, self._root_dir)
963 949
964 # If --force and --delete_unversioned_trees are specified, remove any
965 # untracked files and directories.
966 if options.force and options.delete_unversioned_trees:
967 for status in scm.SVN.CaptureStatus(None, self.checkout_path):
968 path = os.path.join(self.checkout_path, status[1])
969 if (status[0][0] == '?' and os.path.isdir(path)):
970 print('\n_____ removing unversioned directory %s' % status[1])
971 gclient_utils.RemoveDirectory(os.path.join(path))
972
973 def updatesingle(self, options, args, file_list): 950 def updatesingle(self, options, args, file_list):
974 filename = args.pop() 951 filename = args.pop()
975 if scm.SVN.AssertVersion("1.5")[0]: 952 if scm.SVN.AssertVersion("1.5")[0]:
976 if not os.path.exists(os.path.join(self.checkout_path, '.svn')): 953 if not os.path.exists(os.path.join(self.checkout_path, '.svn')):
977 # Create an empty checkout and then update the one file we want. Future 954 # Create an empty checkout and then update the one file we want. Future
978 # operations will only apply to the one file we checked out. 955 # operations will only apply to the one file we checked out.
979 command = ["checkout", "--depth", "empty", self.url, self.checkout_path] 956 command = ["checkout", "--depth", "empty", self.url, self.checkout_path]
980 self._Run(command, options, cwd=self._root_dir) 957 self._Run(command, options, cwd=self._root_dir)
981 if os.path.exists(os.path.join(self.checkout_path, filename)): 958 if os.path.exists(os.path.join(self.checkout_path, filename)):
982 os.remove(os.path.join(self.checkout_path, filename)) 959 os.remove(os.path.join(self.checkout_path, filename))
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
1124 new_command.append('--force') 1101 new_command.append('--force')
1125 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1102 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1126 new_command.extend(('--accept', 'theirs-conflict')) 1103 new_command.extend(('--accept', 'theirs-conflict'))
1127 elif options.manually_grab_svn_rev: 1104 elif options.manually_grab_svn_rev:
1128 new_command.append('--force') 1105 new_command.append('--force')
1129 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1106 if command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1130 new_command.extend(('--accept', 'postpone')) 1107 new_command.extend(('--accept', 'postpone'))
1131 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]: 1108 elif command[0] != 'checkout' and scm.SVN.AssertVersion('1.6')[0]:
1132 new_command.extend(('--accept', 'postpone')) 1109 new_command.extend(('--accept', 'postpone'))
1133 return new_command 1110 return new_command
OLDNEW
« no previous file with comments | « gclient.py ('k') | tests/gclient_scm_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698