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

Unified Diff: checkout.py

Issue 6993033: Do no delete file if they exist, even if p.is_new is True. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: checkout.py
diff --git a/checkout.py b/checkout.py
index 21c283e8cbd4e3860f8a52fbe01f2e7bcbc9ea1f..09ea9c3fabba116c7d25c571260ae198f98aedee 100644
--- a/checkout.py
+++ b/checkout.py
@@ -123,8 +123,10 @@ class RawCheckout(CheckoutBase):
full_dir = os.path.join(self.project_path, dirname)
if dirname and not os.path.isdir(full_dir):
os.makedirs(full_dir)
+
+ filepath = os.path.join(self.project_path, p.filename)
if p.is_binary:
- with open(os.path.join(filename), 'wb') as f:
+ with open(filepath, 'wb') as f:
f.write(p.get())
else:
if p.diff_hunks:
@@ -132,9 +134,9 @@ class RawCheckout(CheckoutBase):
['patch', '-p%s' % p.patchlevel],
stdin=p.get(),
cwd=self.project_path)
- elif p.is_new:
+ elif p.is_new and not os.path.exists(filepath):
# There is only a header. Just create the file.
- open(os.path.join(self.project_path, p.filename), 'w').close()
+ open(filepath, 'w').close()
for post in post_processor:
post(self, p)
except OSError, e:
@@ -276,17 +278,19 @@ class SvnCheckout(CheckoutBase, SvnMixIn):
stdout += self._check_output_svn(
['add', dir_to_create, '--force'], credentials=False)
+ filepath = os.path.join(self.project_path, p.filename)
if p.is_binary:
- with open(os.path.join(self.project_path, p.filename), 'wb') as f:
+ with open(filepath, 'wb') as f:
f.write(p.get())
else:
if p.diff_hunks:
cmd = ['patch', '-p%s' % p.patchlevel, '--forward', '--force']
stdout += subprocess2.check_output(
cmd, stdin=p.get(), cwd=self.project_path)
- elif p.is_new:
- # There is only a header. Just create the file.
- open(os.path.join(self.project_path, p.filename), 'w').close()
+ elif p.is_new and not os.path.exists(filepath):
+ # There is only a header. Just create the file if it doesn't
+ # exist.
+ open(filepath, 'w').close()
if p.is_new:
stdout += self._check_output_svn(
['add', p.filename, '--force'], credentials=False)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698