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

Unified Diff: tools/export_tarball/export_tarball.py

Issue 661182: Merge 39238 - Fix removing unnecessary files in export_tarball.py... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/307/src/
Patch Set: Created 10 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 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: tools/export_tarball/export_tarball.py
===================================================================
--- tools/export_tarball/export_tarball.py (revision 40118)
+++ tools/export_tarball/export_tarball.py (working copy)
@@ -41,9 +41,20 @@
# Workaround lack of the exclude parameter in add method in python-2.4.
# TODO(phajdan.jr): remove the workaround when it's not needed on the bot.
class MyTarFile(tarfile.TarFile):
+ def set_remove_nonessential_files(self, remove):
+ self.__remove_nonessential_files = remove
+
def add(self, name, arcname=None, recursive=True, exclude=None):
- if exclude is not None and exclude(name):
+ head, tail = os.path.split(name)
+ if tail in ('.svn', '.git'):
return
+
+ if self.__remove_nonessential_files:
+ for nonessential_dir in NONESSENTIAL_DIRS:
+ dir_path = os.path.join(GetSourceDirectory(), nonessential_dir)
+ if name.startswith(dir_path):
+ return
+
tarfile.TarFile.add(self, name, arcname=arcname, recursive=recursive)
def main(argv):
@@ -66,23 +77,10 @@
output_fullname = args[0] + '.tar.bz2'
output_basename = os.path.basename(args[0])
- def ShouldExcludePath(path):
- head, tail = os.path.split(path)
- if tail in ('.svn', '.git'):
- return True
-
- if not options.remove_nonessential_files:
- return False
- for nonessential_dir in NONESSENTIAL_DIRS:
- if path.startswith(os.path.join(GetSourceDirectory(), nonessential_dir)):
- return True
-
- return False
-
archive = MyTarFile.open(output_fullname, 'w:bz2')
+ archive.set_remove_nonessential_files(options.remove_nonessential_files)
try:
- archive.add(GetSourceDirectory(), arcname=output_basename,
- exclude=ShouldExcludePath)
+ archive.add(GetSourceDirectory(), arcname=output_basename)
finally:
archive.close()
« 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