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

Unified Diff: client/isolate.py

Issue 2844063005: Add option to collapse symlinks in isolate.py (Closed)
Patch Set: fix space Created 3 years, 8 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 | client/isolated_format.py » ('j') | client/isolated_format.py » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/isolate.py
diff --git a/client/isolate.py b/client/isolate.py
index a3c4c0cdfc3a5771d4d8b586810ee2f24c281898..0bd738b8708cc9f02e0d44bc88a156c02839a984 100755
--- a/client/isolate.py
+++ b/client/isolate.py
@@ -479,7 +479,7 @@ class CompleteState(object):
def load_isolate(
self, cwd, isolate_file, path_variables, config_variables,
- extra_variables, blacklist, ignore_broken_items):
+ extra_variables, blacklist, ignore_broken_items, collapse_symlinks=False):
M-A Ruel 2017/04/27 17:44:02 would you mind not making it a default arg?
kjlubick 2017/04/27 17:55:37 Done.
"""Updates self.isolated and self.saved_state with information loaded from a
.isolate file.
@@ -489,9 +489,9 @@ class CompleteState(object):
assert os.path.isabs(isolate_file), isolate_file
isolate_file = file_path.get_native_path_case(isolate_file)
logging.info(
- 'CompleteState.load_isolate(%s, %s, %s, %s, %s, %s)',
+ 'CompleteState.load_isolate(%s, %s, %s, %s, %s, %s, %s)',
cwd, isolate_file, path_variables, config_variables, extra_variables,
- ignore_broken_items)
+ ignore_broken_items, collapse_symlinks)
# Config variables are not affected by the paths and must be used to
# retrieve the paths, so update them first.
@@ -550,7 +550,9 @@ class CompleteState(object):
self.saved_state.root_dir)
for f in infiles
]
- follow_symlinks = sys.platform != 'win32'
+ follow_symlinks = False
+ if not collapse_symlinks:
+ follow_symlinks = sys.platform != 'win32'
# Expand the directories by listing each file inside. Up to now, trailing
# os.path.sep must be kept.
infiles = isolated_format.expand_directories_and_symlinks(
@@ -565,7 +567,7 @@ class CompleteState(object):
self.saved_state.update_isolated(command, infiles, read_only, relative_cwd)
logging.debug(self)
- def files_to_metadata(self, subdir):
+ def files_to_metadata(self, subdir, collapse_symlinks=False):
"""Updates self.saved_state.files with the files' mode and hash.
If |subdir| is specified, filters to a subdirectory. The resulting .isolated
@@ -582,7 +584,8 @@ class CompleteState(object):
filepath,
self.saved_state.files[infile],
self.saved_state.read_only,
- self.saved_state.algo)
+ self.saved_state.algo,
+ collapse_symlinks)
def save_files(self):
"""Saves self.saved_state and creates a .isolated file."""
@@ -674,7 +677,8 @@ def load_complete_state(options, cwd, subdir, skip_update):
# Then load the .isolate and expands directories.
complete_state.load_isolate(
cwd, isolate, options.path_variables, options.config_variables,
- options.extra_variables, options.blacklist, options.ignore_broken_items)
+ options.extra_variables, options.blacklist, options.ignore_broken_items,
+ options.collapse_symlinks)
# Regenerate complete_state.saved_state.files.
if subdir:
@@ -691,7 +695,7 @@ def load_complete_state(options, cwd, subdir, skip_update):
subdir = subdir.replace('/', os.path.sep)
if not skip_update:
- complete_state.files_to_metadata(subdir)
+ complete_state.files_to_metadata(subdir, options.collapse_symlinks)
return complete_state
@@ -1122,6 +1126,10 @@ def add_isolate_options(parser):
help='Indicates that invalid entries in the isolated file to be '
'only be logged and not stop processing. Defaults to True if '
'env var ISOLATE_IGNORE_BROKEN_ITEMS is set')
+ group.add_option(
+ '--collapse_symlinks', action='store_true',
+ default=False,
M-A Ruel 2017/04/27 17:44:02 not needed
kjlubick 2017/04/27 17:55:37 Done.
+ help='Treat any symlinks as if they were the normal underlying file.')
parser.add_option_group(group)
« no previous file with comments | « no previous file | client/isolated_format.py » ('j') | client/isolated_format.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698