Skip to content

Commit

Permalink
Reset the workdir without using pdal
Browse files Browse the repository at this point in the history
  • Loading branch information
olsen232 committed Aug 25, 2022
1 parent a94afa1 commit 03ca159
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
13 changes: 12 additions & 1 deletion kart/point_cloud/v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,17 @@ def diff_to_working_copy(
ds_filter=DatasetKeyFilter.MATCH_ALL,
*,
convert_to_dataset_format=False,
skip_pdal=False,
):
"""Returns a diff of all changes made to this dataset in the working copy."""
"""
Returns a diff of all changes made to this dataset in the working copy.
convert_to_dataset_format - user wants this converted to dataset's format as it is
committed, and wants to see diffs of what this would look like.
skip_pdal - if set, don't run PDAL to check the tile contents. The resulting diffs
are missing almost all of the info about the new tiles, but this is faster and more
reliable if this information is not needed.
"""
tile_filter = ds_filter.get("tile", ds_filter.child_type())

current_metadata = self.tile_metadata
Expand Down Expand Up @@ -266,6 +275,8 @@ def diff_to_working_copy(
wc_path = self._workdir_path(tile_path)
if not wc_path.is_file():
new_half_delta = None
elif skip_pdal:
new_half_delta = tilename, {"name": wc_path.name}
else:
tile_metadata = extract_pc_tile_metadata(wc_path)
tilename_to_metadata[wc_path.name] = tile_metadata
Expand Down
27 changes: 15 additions & 12 deletions kart/workdir.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from kart.cli_util import tool_environment
from kart import diff_util
from kart.diff_structs import Delta
from kart.diff_structs import Delta, DatasetDiff
from kart.exceptions import (
NotFound,
SubprocessError,
Expand Down Expand Up @@ -375,18 +375,21 @@ def _diff_to_reset(
"""
Get the diff-to-apply needed to reset a particular dataset - currently based on base_datasets[ds_path] -
to the target state at target_datasets[ds_path]."""
# The diffing code can diff from any arbitrary commit, but not from the working copy -
# it can only diff *to* the working copy.
# So, we need to diff from=target to=working copy then take the inverse.
# TODO: Make this less confusing.
ds_diff = ~diff_util.get_dataset_diff(
ds_path,
target_datasets,
base_datasets,
include_wc_diff=True,
workdir_diff_cache=workdir_diff_cache,
ds_filter=ds_filter,
ds_diff = ~base_datasets[ds_path].diff_to_working_copy(
workdir_diff_cache, ds_filter=ds_filter, skip_pdal=True
)
if base_datasets != target_datasets:
ds_diff = DatasetDiff.concatenated(
ds_diff,
diff_util.get_dataset_diff(
ds_path,
base_datasets,
target_datasets,
ds_filter=ds_filter,
),
overwrite_original=True,
)

tile_diff = ds_diff.get("tile")
# Remove new values that don't match the spatial filter - we don't want them in the working copy.
if tile_diff and not self.repo.spatial_filter.match_all:
Expand Down

0 comments on commit 03ca159

Please sign in to comment.