diff --git a/dvc/repo/push.py b/dvc/repo/push.py index a76c9d9e2b..d911e51def 100644 --- a/dvc/repo/push.py +++ b/dvc/repo/push.py @@ -8,6 +8,31 @@ from dvc_objects.db import ObjectDB +def _update_meta(index): + from dvc.repo.index import build_data_index + from dvc.repo.worktree import _merge_push_meta, worktree_view_by_remotes + + stages = set() + for remote_name, idx in worktree_view_by_remotes(index): + remote = index.repo.cloud.get_remote(remote_name) + + new = build_data_index(idx, remote.path, remote.fs) + + for out in idx.outs: + if ( + not idx.data["repo"] + .storage_map[out.index_key[1]] + .remote.fs.version_aware + ): + continue + + _merge_push_meta(out, new) + stages.add(out.stage) + + for stage in stages: + stage.dump(with_files=True, update_pipeline=False) + + @locked def push( # noqa: C901, PLR0913 self, @@ -71,8 +96,6 @@ def push( # noqa: C901, PLR0913 cache_key=cache_key, callback=cb, ) - # data, unversioned_count = _log_unversioned(data) - # failed_count += unversioned_count with Callback.as_tqdm_callback( desc="Pushing", @@ -87,30 +110,11 @@ def push( # noqa: C901, PLR0913 finally: ws_idx = indexes.get("workspace") if ws_idx is not None: - from dvc.repo.worktree import _merge_push_meta - - stages = set() - for out in ws_idx.outs: - if ( - not ws_idx.data["repo"] - .storage_map[out.index_key[1]] - .remote.fs.version_aware - ): - continue - - _merge_push_meta(out, ws_idx.data["repo"]) - stages.add(out.stage) - - for stage in stages: - stage.dump(with_files=True, update_pipeline=False) + _update_meta(self.index) # fixme this should be targets_view for fs_index in data: fs_index.close() - # if fetch_transferred: - # # NOTE: dropping cached index to force reloading from newly saved cache - # self.drop_data_index() - transferred_count += push_transferred failed_count += push_failed if failed_count: