mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-11-13 15:28:27 +01:00
repo: fix macros placement from dvc/scm to dvc/repo/diff
This commit is contained in:
+27
-27
@@ -8,7 +8,7 @@ import dvc.logger as logger
|
||||
from dvc.exceptions import DvcException
|
||||
from dvc.command.base import CmdBase
|
||||
from dvc.utils.collections import compact
|
||||
import dvc.scm.base as git
|
||||
import dvc.repo.diff as diff
|
||||
|
||||
|
||||
class CmdDiff(CmdBase):
|
||||
@@ -25,61 +25,61 @@ class CmdDiff(CmdBase):
|
||||
def _show(self, diff_dct):
|
||||
engine = inflect.engine()
|
||||
msg = "dvc diff from {} to {}".format(
|
||||
diff_dct[git.DIFF_A_REF], diff_dct[git.DIFF_B_REF]
|
||||
diff_dct[diff.DIFF_A_REF], diff_dct[diff.DIFF_B_REF]
|
||||
)
|
||||
if diff_dct.get(git.DIFF_EQUAL):
|
||||
if diff_dct.get(diff.DIFF_EQUAL):
|
||||
logger.info(msg)
|
||||
return
|
||||
for dct in diff_dct[git.DIFF_LIST]:
|
||||
msg += "\n\ndiff for '{}' \n".format(dct[git.DIFF_TARGET])
|
||||
if dct.get(git.DIFF_OLD_FILE):
|
||||
for dct in diff_dct[diff.DIFF_LIST]:
|
||||
msg += "\n\ndiff for '{}' \n".format(dct[diff.DIFF_TARGET])
|
||||
if dct.get(diff.DIFF_OLD_FILE):
|
||||
msg += "-{} with md5 {}\n".format(
|
||||
dct[git.DIFF_OLD_FILE], dct[git.DIFF_OLD_CHECKSUM]
|
||||
dct[diff.DIFF_OLD_FILE], dct[diff.DIFF_OLD_CHECKSUM]
|
||||
)
|
||||
if dct.get(git.DIFF_NEW_FILE):
|
||||
if dct.get(diff.DIFF_NEW_FILE):
|
||||
msg += "+{} with md5 {}\n".format(
|
||||
dct[git.DIFF_NEW_FILE], dct[git.DIFF_NEW_CHECKSUM]
|
||||
dct[diff.DIFF_NEW_FILE], dct[diff.DIFF_NEW_CHECKSUM]
|
||||
)
|
||||
msg += "\n"
|
||||
if dct[git.DIFF_SIZE] != git.DIFF_SIZE_UNKNOWN:
|
||||
if dct[diff.DIFF_SIZE] != diff.DIFF_SIZE_UNKNOWN:
|
||||
if dct.get("is_dir"):
|
||||
msg += "{} {} not changed, ".format(
|
||||
dct[git.DIFF_IDENT],
|
||||
engine.plural("file", dct[git.DIFF_IDENT]),
|
||||
dct[diff.DIFF_IDENT],
|
||||
engine.plural("file", dct[diff.DIFF_IDENT]),
|
||||
)
|
||||
msg += "{} {} modified, ".format(
|
||||
dct[git.DIFF_CHANGE],
|
||||
engine.plural("file", dct[git.DIFF_CHANGE]),
|
||||
dct[diff.DIFF_CHANGE],
|
||||
engine.plural("file", dct[diff.DIFF_CHANGE]),
|
||||
)
|
||||
msg += "{} {} added, ".format(
|
||||
dct[git.DIFF_NEW],
|
||||
engine.plural("file", dct[git.DIFF_NEW]),
|
||||
dct[diff.DIFF_NEW],
|
||||
engine.plural("file", dct[diff.DIFF_NEW]),
|
||||
)
|
||||
msg += "{} {} deleted, ".format(
|
||||
dct[git.DIFF_DEL],
|
||||
engine.plural("file", dct[git.DIFF_DEL]),
|
||||
dct[diff.DIFF_DEL],
|
||||
engine.plural("file", dct[diff.DIFF_DEL]),
|
||||
)
|
||||
msg += "size was {}".format(
|
||||
self._print_size(dct[git.DIFF_SIZE])
|
||||
self._print_size(dct[diff.DIFF_SIZE])
|
||||
)
|
||||
else:
|
||||
if (
|
||||
dct.get(git.DIFF_OLD_FILE)
|
||||
and dct.get(git.DIFF_NEW_FILE)
|
||||
and dct[git.DIFF_SIZE] == 0
|
||||
dct.get(diff.DIFF_OLD_FILE)
|
||||
and dct.get(diff.DIFF_NEW_FILE)
|
||||
and dct[diff.DIFF_SIZE] == 0
|
||||
):
|
||||
msg += "file size was not changed"
|
||||
elif dct.get(git.DIFF_NEW_FILE):
|
||||
elif dct.get(diff.DIFF_NEW_FILE):
|
||||
msg += "added file with size {}".format(
|
||||
humanize.naturalsize(dct[git.DIFF_SIZE])
|
||||
humanize.naturalsize(dct[diff.DIFF_SIZE])
|
||||
)
|
||||
elif dct.get(git.DIFF_OLD_FILE):
|
||||
elif dct.get(diff.DIFF_OLD_FILE):
|
||||
msg += "deleted file with size {}".format(
|
||||
humanize.naturalsize(abs(dct[git.DIFF_SIZE]))
|
||||
humanize.naturalsize(abs(dct[diff.DIFF_SIZE]))
|
||||
)
|
||||
else:
|
||||
msg += "file was modified, file size {}".format(
|
||||
self._print_size(dct[git.DIFF_SIZE])
|
||||
self._print_size(dct[diff.DIFF_SIZE])
|
||||
)
|
||||
else:
|
||||
msg += "size is ?"
|
||||
|
||||
Reference in New Issue
Block a user