MCPcopy
hub / github.com/treeverse/dvc / commit

Method commit

dvc/output.py:752–800  ·  view source on GitHub ↗
(self, filter_info=None, relink=True)

Source from the content-addressed store, hash-verified

750 raise CheckoutError(exc.paths, {}) # noqa: B904
751
752 def commit(self, filter_info=None, relink=True) -> None:
753 if not self.exists:
754 raise self.DoesNotExistError(self)
755
756 assert self.hash_info
757
758 if self.use_cache:
759 granular = (
760 self.is_dir_checksum and filter_info and filter_info != self.fs_path
761 )
762 hardlink = relink and next(iter(self.cache.cache_types), None) == "hardlink"
763 if granular:
764 obj = self._commit_granular_dir(filter_info, hardlink=hardlink)
765 else:
766 staging, _, obj = self._build(
767 self.cache,
768 filter_info or self.fs_path,
769 self.fs,
770 self.hash_name,
771 ignore=self.dvcignore,
772 )
773 with TqdmCallback(
774 desc=f"Committing {self} to cache",
775 unit="file",
776 ) as cb:
777 otransfer(
778 staging,
779 self.cache,
780 {obj.hash_info},
781 shallow=False,
782 hardlink=hardlink,
783 callback=cb,
784 )
785 if relink:
786 assert self.repo
787 rel = self.fs.relpath(filter_info or self.fs_path)
788 with CheckoutCallback(desc=f"Checking out {rel}", unit="files") as cb:
789 self._checkout(
790 filter_info or self.fs_path,
791 self.fs,
792 obj,
793 self.cache,
794 relink=True,
795 state=self.repo.state,
796 prompt=prompt.confirm,
797 progress_callback=cb,
798 old=obj,
799 )
800 self.set_exec()
801
802 def _commit_granular_dir(self, filter_info, hardlink) -> Optional["HashFile"]:
803 prefix = self.fs.parts(self.fs.relpath(filter_info, self.fs_path))

Callers 15

moveMethod · 0.95
git_dirFunction · 0.45
runFunction · 0.45
makeFunction · 0.45
test_commit_recursiveFunction · 0.45
test_commit_forceFunction · 0.45
test_commit_with_depsFunction · 0.45

Calls 7

_commit_granular_dirMethod · 0.95
_buildMethod · 0.95
_checkoutMethod · 0.95
set_execMethod · 0.95
TqdmCallbackClass · 0.85
CheckoutCallbackClass · 0.85
relpathMethod · 0.45

Tested by 15

runFunction · 0.36
makeFunction · 0.36
test_commit_recursiveFunction · 0.36
test_commit_forceFunction · 0.36
test_commit_with_depsFunction · 0.36
test_commit_changed_md5Function · 0.36
test_commit_no_execFunction · 0.36