Skip to content

Commit

Permalink
revert addition of narrow_relative_paths()
Browse files Browse the repository at this point in the history
  • Loading branch information
cosmicexplorer committed Jun 12, 2018
1 parent 3be53f3 commit 97787f5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
14 changes: 9 additions & 5 deletions src/python/pants/build_graph/target.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
from pants.source.payload_fields import SourcesField
from pants.source.wrapped_globs import Files, FilesetWithSpec, Globs
from pants.subsystem.subsystem import Subsystem
from pants.util.dirutil import narrow_relative_paths
from pants.util.memo import memoized_property


Expand Down Expand Up @@ -502,15 +501,20 @@ def sources_relative_to_buildroot(self):
"""
:API: public
"""
return self._sources_field.relative_to_buildroot()
if self.has_sources():
return self._sources_field.relative_to_buildroot()
else:
return []

def sources_relative_to_source_root(self):
"""
:API: public
"""
buildroot = get_buildroot()
abs_source_root = os.path.join(get_buildroot(), self.target_base)
return narrow_relative_paths(buildroot, abs_source_root, self.sources_relative_to_buildroot())
if self.has_sources():
abs_source_root = os.path.join(get_buildroot(), self.target_base)
for source in self.sources_relative_to_buildroot():
abs_source = os.path.join(get_buildroot(), source)
yield os.path.relpath(abs_source, abs_source_root)

def globs_relative_to_buildroot(self):
"""
Expand Down
7 changes: 0 additions & 7 deletions src/python/pants/util/dirutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -500,10 +500,3 @@ def split_basename_and_dirname(path):
if not os.path.isfile(path):
raise ValueError("{} does not exist or is not a regular file.".format(path))
return (os.path.dirname(path), os.path.basename(path))


def narrow_relative_paths(cur_root_dir, new_root_subdir, rel_paths):
"""If `cur_root_dir` contains `new_root_subdir`, relativize `rel_paths` to `new_root_subdir`."""
for rel_file in rel_paths:
file_abs = os.path.join(cur_root_dir, rel_file)
yield os.path.relpath(file_abs, new_root_subdir)

0 comments on commit 97787f5

Please sign in to comment.