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

Side by Side Diff: checkout.py

Issue 10310034: Implement proper svn copy when a file is copied, moved or renamed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: remove git unit test Created 8 years, 7 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 | « no previous file | tests/checkout_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 # coding=utf8 1 # coding=utf8
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 """Manages a project checkout. 5 """Manages a project checkout.
6 6
7 Includes support for svn, git-svn and git. 7 Includes support for svn, git-svn and git.
8 """ 8 """
9 9
10 import ConfigParser 10 import ConfigParser
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
306 else: 306 else:
307 if p.source_filename: 307 if p.source_filename:
308 if not p.is_new: 308 if not p.is_new:
309 raise PatchApplicationFailed( 309 raise PatchApplicationFailed(
310 p.filename, 310 p.filename,
311 'File has a source filename specified but is not new') 311 'File has a source filename specified but is not new')
312 # Copy the file first. 312 # Copy the file first.
313 if os.path.isfile(filepath): 313 if os.path.isfile(filepath):
314 raise PatchApplicationFailed( 314 raise PatchApplicationFailed(
315 p.filename, 'File exist but was about to be overwriten') 315 p.filename, 'File exist but was about to be overwriten')
316 shutil.copy2( 316 self._check_output_svn(
317 os.path.join(self.project_path, p.source_filename), filepath) 317 [
318 'copy',
319 os.path.join(self.project_path, p.source_filename),
320 filepath
321 ])
318 if p.diff_hunks: 322 if p.diff_hunks:
319 cmd = ['patch', '-p%s' % p.patchlevel, '--forward', '--force'] 323 cmd = ['patch', '-p%s' % p.patchlevel, '--forward', '--force']
320 stdout += subprocess2.check_output( 324 stdout += subprocess2.check_output(
321 cmd, stdin=p.get(False), cwd=self.project_path) 325 cmd, stdin=p.get(False), cwd=self.project_path)
322 elif p.is_new and not os.path.exists(filepath): 326 elif p.is_new and not os.path.exists(filepath):
323 # There is only a header. Just create the file if it doesn't 327 # There is only a header. Just create the file if it doesn't
324 # exist. 328 # exist.
325 open(filepath, 'w').close() 329 open(filepath, 'w').close()
326 if p.is_new: 330 if p.is_new and not p.source_filename:
331 # Do not run it if p.source_filename is defined, since svn copy was
332 # using above.
327 stdout += self._check_output_svn( 333 stdout += self._check_output_svn(
328 ['add', p.filename, '--force'], credentials=False) 334 ['add', p.filename, '--force'], credentials=False)
329 for prop in p.svn_properties: 335 for prop in p.svn_properties:
330 stdout += self._check_output_svn( 336 stdout += self._check_output_svn(
331 ['propset', prop[0], prop[1], p.filename], credentials=False) 337 ['propset', prop[0], prop[1], p.filename], credentials=False)
332 for prop, values in self.svn_config.auto_props.iteritems(): 338 for prop, values in self.svn_config.auto_props.iteritems():
333 if fnmatch.fnmatch(p.filename, prop): 339 if fnmatch.fnmatch(p.filename, prop):
334 for value in values.split(';'): 340 for value in values.split(';'):
335 if '=' not in value: 341 if '=' not in value:
336 params = [value, '*'] 342 params = [value, '*']
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after
747 user, message)) 753 user, message))
748 return 'FAKE' 754 return 'FAKE'
749 755
750 @property 756 @property
751 def project_name(self): 757 def project_name(self):
752 return self.checkout.project_name 758 return self.checkout.project_name
753 759
754 @property 760 @property
755 def project_path(self): 761 def project_path(self):
756 return self.checkout.project_path 762 return self.checkout.project_path
OLDNEW
« no previous file with comments | « no previous file | tests/checkout_test.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698