Repository: iterative/dvc

Issue:
dvc: provide granularity for commands that could target specific tracked files
> This can be seen as revisiting feature request #1026

UPDATE: Please scroll down to https://github.com/iterative/dvc/issues/2458#issuecomment-566649020 for most recent, summarized requirement.
Here is the original context also (still relevant):

---

There's different scenarios in which _being able to manipulate files granularly independently of how they were committed/pushed to DVC_ could be useful. The problem with using `dvc add -R` now is that it can generate lots of `.dvc` files, but what if a directory could be added without `-R` (producing a single DVC-file) and yet other commands (lock, update, get, etc) could be applied to individual files inside the added directory tree?

**Example** (from https://github.com/iterative/dataset-registry/commit/7476a858f6200864b5755863c729bff41d0fb045)

Project 1:
```console
$ tree
.
└── tutorial
    └── nlp
        ├── Posts.xml.zip
        └── pipeline.zip
$ dvc add tutorial
...
$ dvc push
...
```

Project 2:
```console
$ dvc import {project-1-url} tutorial/nlp/pipeline.zip
...
$ tree
.
├── tutorial
│   └── nlp
│       └── pipeline.zip
└── tutorial.dvc
```
> Not sure about where the `.dvc` would have to be placed in this example though.

And also this is how Git works, I believe. Files are tracked individually (in fact it doesn't even recognize empty dirs).

Discussion:

Patch:
diff --git a/dvc/command/update.py b/dvc/command/update.py
index 47df68dd6..73f4d097d 100644
--- a/dvc/command/update.py
+++ b/dvc/command/update.py
@@ -14,7 +14,7 @@ class CmdUpdate(CmdBase):
         ret = 0
         for target in self.args.targets:
             try:
-                self.repo.update(target)
+                self.repo.update(target, self.args.rev)
             except DvcException:
                 logger.exception("failed to update '{}'.".format(target))
                 ret = 1
@@ -33,4 +33,7 @@ def add_parser(subparsers, parent_parser):
     update_parser.add_argument(
         "targets", nargs="+", help="DVC-files to update."
     )
+    update_parser.add_argument(
+        "--rev", nargs="?", help="Git revision (e.g. SHA, branch, tag)"
+    )
     update_parser.set_defaults(func=CmdUpdate)
diff --git a/dvc/dependency/base.py b/dvc/dependency/base.py
index 270fdbba7..08fce73a9 100644
--- a/dvc/dependency/base.py
+++ b/dvc/dependency/base.py
@@ -27,5 +27,5 @@ class DependencyBase(object):
     IsNotFileOrDirError = DependencyIsNotFileOrDirError
     IsStageFileError = DependencyIsStageFileError
 
-    def update(self):
+    def update(self, rev=None):
         pass
diff --git a/dvc/dependency/repo.py b/dvc/dependency/repo.py
index 26d58d609..53edac176 100644
--- a/dvc/dependency/repo.py
+++ b/dvc/dependency/repo.py
@@ -80,6 +80,9 @@ class DependencyREPO(DependencyLOCAL):
 
             repo.pull_to(self.def_path, to.path_info)
 
-    def update(self):
+    def update(self, rev=None):
+        if rev:
+            self.def_repo[self.PARAM_REV] = rev
+
         with self._make_repo(locked=False) as repo:
             self.def_repo[self.PARAM_REV_LOCK] = repo.scm.get_rev()
diff --git a/dvc/external_repo.py b/dvc/external_repo.py
index 6bb34f4b5..7dd6afc52 100644
--- a/dvc/external_repo.py
+++ b/dvc/external_repo.py
@@ -7,13 +7,15 @@ import threading
 
 from funcy import retry, suppress, wrap_with, cached_property
 
+from dvc.path_info import PathInfo
 from dvc.compat import fspath
 from dvc.repo import Repo
 from dvc.config import NoRemoteError, NotDvcRepoError
 from dvc.exceptions import NoRemoteInExternalRepoError
 from dvc.exceptions import OutputNotFoundError, NoOutputInExternalRepoError
 from dvc.exceptions import FileMissingError, PathMissingError
-from dvc.utils.fs import remove, fs_copy
+from dvc.utils.fs import remove, fs_copy, move
+from dvc.utils import tmp_fname
 from dvc.scm.git import Git
 
 
@@ -67,32 +69,49 @@ class ExternalRepo(Repo):
         self._set_upstream()
 
     def pull_to(self, path, to_info):
-        try:
-            out = None
-            with suppress(OutputNotFoundError):
-                out = self.find_out_by_relpath(path)
+        """
+        Pull the corresponding file or directory specified by `path` and
+        checkout it into `to_info`.
+
+        It works with files tracked by Git and DVC, and also local files
+        outside the repository.
+        """
+        out = None
+        path_info = PathInfo(self.root_dir) / path
+
+        with suppress(OutputNotFoundError):
+            (out,) = self.find_outs_by_path(fspath(path_info), strict=False)
 
+        try:
             if out and out.use_cache:
-                self._pull_cached(out, to_info)
+                self._pull_cached(out, path, to_info)
                 return
 
-            # Git handled files can't have absolute path
+            # Check if it is handled by Git (it can't have an absolute path)
             if os.path.isabs(path):
                 raise FileNotFoundError
 
-            fs_copy(os.path.join(self.root_dir, path), fspath(to_info))
+            fs_copy(fspath(path_info), fspath(to_info))
         except FileNotFoundError:
             raise PathMissingError(path, self.url)
 
-    def _pull_cached(self, out, to_info):
+    def _pull_cached(self, out, src, dest):
         with self.state:
+            tmp = PathInfo(tmp_fname(dest))
+            target = (out.path_info.parent / src).relative_to(out.path_info)
+            src = tmp / target
+
+            out.path_info = tmp
+
             # Only pull unless all needed cache is present
-            if out.changed_cache():
-                self.cloud.pull(out.get_used_cache())
+            if out.changed_cache(filter_info=src):
+                self.cloud.pull(out.get_used_cache(filter_info=src))
+
+            failed = out.checkout(filter_info=src)
+
+            move(src, dest)
+            remove(tmp)
 
-            out.path_info = to_info
-            failed = out.checkout()
-            # This might happen when pull haven't really pulled all the files
             if failed:
                 raise FileNotFoundError
 
diff --git a/dvc/logger.py b/dvc/logger.py
index ce4a46c04..ecd115a7c 100644
--- a/dvc/logger.py
+++ b/dvc/logger.py
@@ -1,6 +1,5 @@
 """Manages logging configuration for DVC repo."""
 
-import traceback
 import logging.config
 import logging.handlers
 
@@ -37,16 +36,15 @@ class ExcludeInfoFilter(logging.Filter):
 
 
 class ColorFormatter(logging.Formatter):
-    """Enable color support when logging to a terminal that supports it.
+    """Spit out colored text in supported terminals.
 
-    Color support on Windows versions that do not support ANSI color codes is
-    enabled by use of the colorama__ library.
+    colorama__ makes ANSI escape character sequences work under Windows.
     See the colorama documentation for details.
 
     __ https://pypi.python.org/pypi/colorama
 
-    For records containing `exc_info`, it will use a custom `_walk_exc` to
-    retrieve the whole traceback.
+    If record has an extra `tb_only` attribute, it will not show the
+    exception cause, just the message and the traceback.
     """
 
     color_code = {
@@ -58,93 +56,45 @@ class ColorFormatter(logging.Formatter):
 
     def format(self, record):
         msg = record.msg.format(*record.args) if record.args else record.msg
-        exception, stack_trace = self._parse_exc(record)
-        return ("{asctime}{prefix}{description}{stack_trace}").format(
+
+        if record.levelname == "INFO":
+            return msg
+
+        if record.exc_info:
+            if getattr(record, "tb_only", False):
+                cause = ""
+            else:
+                cause = ": ".join(_iter_causes(record.exc_info[1]))
+
+            msg = "{message}{separator}{cause}".format(
+                message=msg or "",
+                separator=" - " if msg and cause else "",
+                cause=cause,
+            )
+
+            if _is_verbose():
+                msg += _stack_trace(record.exc_info)
+
+        return "{asctime}{color}{levelname}{nc}: {msg}".format(
             asctime=self.formatTime(record, self.datefmt),
-            prefix=self._prefix(record),
-            description=self._description(msg, exception),
-            stack_trace=stack_trace,
+            color=self.color_code[record.levelname],
+            nc=colorama.Fore.RESET,
+            levelname=record.levelname,
+            msg=msg,
         )
 
     def formatTime(self, record, datefmt=None):
         # only show if current level is set to DEBUG
         # also, skip INFO as it is used for UI
-        if (
-            self._current_level() != logging.DEBUG
-            or record.levelno == logging.INFO
-        ):
+        if not _is_verbose() or record.levelno == logging.INFO:
             return ""
 
-        return "{color}{date}{nc} ".format(
-            color=colorama.Fore.GREEN,
+        return "{green}{date}{nc} ".format(
+            green=colorama.Fore.GREEN,
             date=super().formatTime(record, datefmt),
             nc=colorama.Fore.RESET,
         )
 
-    def _prefix(self, record):
-        if record.levelname == "INFO":
-            return ""
-
-        return "{color}{levelname}{nc}: ".format(
-            color=self.color_code.get(record.levelname, ""),
-            levelname=record.levelname,
-            nc=colorama.Fore.RESET,
-        )
-
-    def _current_level(self):
-        return logging.getLogger("dvc").getEffectiveLevel()
-
-    def _is_visible(self, record):
-        return record.levelno >= self._current_level()
-
-    def _description(self, message, exception):
-        description = ""
-
-        if exception and message:
-            description = "{message} - {exception}"
-        elif exception:
-            description = "{exception}"
-        elif message:
-            description = "{message}"
-
-        return description.format(message=message, exception=exception)
-
-    def _walk_exc(self, exc_info):
-        exc = exc_info[1]
-
-        exc_list = [str(exc)]
-
-        while hasattr(exc, "__cause__") and exc.__cause__:
-            exc_list.append(str(exc.__cause__))
-            exc = exc.__cause__
-
-        return exc_list
-
-    def _parse_exc(self, record):
-        tb_only = getattr(record, "tb_only", False)
-
-        if not record.exc_info:
-            return (None, "")
-
-        exc_list = self._walk_exc(record.exc_info)
-        tb = traceback.format_exception(*record.exc_info)
-
-        exception = None if tb_only else ": ".join(exc_list)
-
-        if self._current_level() == logging.DEBUG:
-            stack_trace = (
-                "\n" "{red}{line}{nc}\n" "{stack_trace}" "{red}{line}{nc}"
-            ).format(
-                red=colorama.Fore.RED,
-                nc=colorama.Fore.RESET,
-                line="-" * 60,
-                stack_trace="".join(tb),
-            )
-        else:
-            stack_trace = ""
-
-        return (exception, stack_trace)
-
 
 class LoggerHandler(logging.StreamHandler):
     def handleError(self, record):
@@ -165,6 +115,32 @@ class LoggerHandler(logging.StreamHandler):
             self.handleError(record)
 
 
+def _is_verbose():
+    return logging.getLogger("dvc").getEffectiveLevel() == logging.DEBUG
+
+
+def _iter_causes(exc):
+    while exc:
+        yield str(exc)
+        exc = exc.__cause__
+
+
+def _stack_trace(exc_info):
+    import traceback
+
+    return (
+        "\n"
+        "{red}{line}{nc}\n"
+        "{trace}"
+        "{red}{line}{nc}".format(
+            red=colorama.Fore.RED,
+            line="-" * 60,
+            trace="".join(traceback.format_exception(*exc_info)),
+            nc=colorama.Fore.RESET,
+        )
+    )
+
+
 def setup(level=logging.INFO):
     colorama.init()
 
diff --git a/dvc/output/__init__.py b/dvc/output/__init__.py
index abcf68191..e86deeba5 100644
--- a/dvc/output/__init__.py
+++ b/dvc/output/__init__.py
@@ -1,5 +1,5 @@
 from urllib.parse import urlparse
-from voluptuous import Any, Required
+from voluptuous import Any, Required, Lower, Length, Coerce, And, SetTo
 
 from dvc.output.base import OutputBase
 from dvc.output.gs import OutputGS
@@ -29,6 +29,12 @@ OUTS_MAP = {
     Schemes.LOCAL: OutputLOCAL,
 }
 
+CHECKSUM_SCHEMA = Any(
+    None,
+    And(str, Length(max=0), SetTo(None)),
+    And(Any(str, And(int, Coerce(str))), Length(min=3), Lower),
+)
+
 # NOTE: currently there are only 3 possible checksum names:
 #
 #    1) md5 (LOCAL, SSH, GS);
@@ -37,15 +43,15 @@ OUTS_MAP = {
 #
 # so when a few types of outputs share the same name, we only need
 # specify it once.
-CHECKSUM_SCHEMA = {
-    RemoteLOCAL.PARAM_CHECKSUM: Any(str, None),
-    RemoteS3.PARAM_CHECKSUM: Any(str, None),
-    RemoteHDFS.PARAM_CHECKSUM: Any(str, None),
+CHECKSUMS_SCHEMA = {
+    RemoteLOCAL.PARAM_CHECKSUM: CHECKSUM_SCHEMA,
+    RemoteS3.PARAM_CHECKSUM: CHECKSUM_SCHEMA,
+    RemoteHDFS.PARAM_CHECKSUM: CHECKSUM_SCHEMA,
 }
 
-TAGS_SCHEMA = {str: CHECKSUM_SCHEMA}
+TAGS_SCHEMA = {str: CHECKSUMS_SCHEMA}
 
-SCHEMA = CHECKSUM_SCHEMA.copy()
+SCHEMA = CHECKSUMS_SCHEMA.copy()
 SCHEMA[Required(OutputBase.PARAM_PATH)] = str
 SCHEMA[OutputBase.PARAM_CACHE] = bool
 SCHEMA[OutputBase.PARAM_METRIC] = OutputBase.METRIC_SCHEMA
diff --git a/dvc/output/base.py b/dvc/output/base.py
index 7770c30cc..d59276da7 100644
--- a/dvc/output/base.py
+++ b/dvc/output/base.py
@@ -162,11 +162,11 @@ class OutputBase(object):
     def changed_checksum(self):
         return self.checksum != self.remote.get_checksum(self.path_info)
 
-    def changed_cache(self):
+    def changed_cache(self, filter_info=None):
         if not self.use_cache or not self.checksum:
             return True
 
-        return self.cache.changed_cache(self.checksum)
+        return self.cache.changed_cache(self.checksum, filter_info=filter_info)
 
     def status(self):
         if self.checksum and self.use_cache and self.changed_cache():
diff --git a/dvc/progress.py b/dvc/progress.py
index d03b037c0..a8ab61951 100644
--- a/dvc/progress.py
+++ b/dvc/progress.py
@@ -55,7 +55,8 @@ class Tqdm(tqdm):
         desc  : persists after `close()`
         level  : effective logging level for determining `disable`;
             used only if `disable` is unspecified
-        disable  : If (default: None), will be determined by logging level.
+        disable  : If (default: None) or False,
+            will be determined by logging level.
             May be overridden to `True` due to non-TTY status.
             Skip override by specifying env var `DVC_IGNORE_ISATTY`.
         kwargs  : anything accepted by `tqdm.tqdm()`
@@ -69,7 +70,7 @@ class Tqdm(tqdm):
             file = sys.stderr
         self.desc_persist = desc
         # auto-disable based on `logger.level`
-        if disable is None:
+        if not disable:
             disable = logger.getEffectiveLevel() > level
         # auto-disable based on TTY
         if (
diff --git a/dvc/repo/add.py b/dvc/repo/add.py
index fbbf7ed91..f216d6dde 100644
--- a/dvc/repo/add.py
+++ b/dvc/repo/add.py
@@ -73,7 +73,7 @@ def add(repo, targets, recursive=False, no_commit=False, fname=None):
                 total=len(stages),
                 desc="Processing",
                 unit="file",
-                disable=True if len(stages) == 1 else None,
+                disable=len(stages) == 1,
             ) as pbar_stages:
                 for stage in stages:
                     try:
@@ -120,7 +120,7 @@ def _create_stages(repo, targets, fname, pbar=None):
     for out in Tqdm(
         targets,
         desc="Creating DVC-files",
-        disable=True if len(targets) < LARGE_DIR_SIZE else None,
+        disable=len(targets) < LARGE_DIR_SIZE,
         unit="file",
     ):
         stage = Stage.create(
diff --git a/dvc/repo/update.py b/dvc/repo/update.py
index 9533bb6d3..44252d005 100644
--- a/dvc/repo/update.py
+++ b/dvc/repo/update.py
@@ -2,10 +2,12 @@ from . import locked
 
 
 @locked
-def update(self, target):
+def update(self, target, rev=None):
     from dvc.stage import Stage
 
     stage = Stage.load(self, target)
-    stage.update()
+    stage.update(rev)
 
     stage.dump()
+
+    return stage
diff --git a/dvc/stage.py b/dvc/stage.py
index 954be11ba..79e52add9 100644
--- a/dvc/stage.py
+++ b/dvc/stage.py
@@ -191,7 +191,7 @@ class Stage(object):
     PARAM_ALWAYS_CHANGED = "always_changed"
 
     SCHEMA = {
-        PARAM_MD5: Any(str, None),
+        PARAM_MD5: output.CHECKSUM_SCHEMA,
         PARAM_CMD: Any(str, None),
         PARAM_WDIR: Any(str, None),
         PARAM_DEPS: Any([dependency.SCHEMA], None),
@@ -405,11 +405,11 @@ class Stage(object):
 
         return self
 
-    def update(self):
+    def update(self, rev=None):
         if not self.is_repo_import and not self.is_import:
             raise StageUpdateError(self.relpath)
 
-        self.deps[0].update()
+        self.deps[0].update(rev=rev)
         locked = self.locked
         self.locked = False
         try:
diff --git a/dvc/utils/fs.py b/dvc/utils/fs.py
index aef055235..7e17a8d01 100644
--- a/dvc/utils/fs.py
+++ b/dvc/utils/fs.py
@@ -97,8 +97,8 @@ def move(src, dst, mode=None):
     of data is happening.
     """
 
-    src = fspath_py35(src)
-    dst = fspath_py35(dst)
+    src = fspath(src)
+    dst = fspath(dst)
 
     dst = os.path.abspath(dst)
     tmp = "{}.{}".format(dst, uuid())
diff --git a/dvc/version.py b/dvc/version.py
index fd366ff62..3c6d64779 100644
--- a/dvc/version.py
+++ b/dvc/version.py
@@ -7,7 +7,7 @@ import os
 import subprocess
 
 
-_BASE_VERSION = "0.84.0"
+_BASE_VERSION = "0.85.0"
 
 
 def _generate_version(base_version):
diff --git a/scripts/completion/dvc.bash b/scripts/completion/dvc.bash
index f84efcf83..0727aa8ce 100644
--- a/scripts/completion/dvc.bash
+++ b/scripts/completion/dvc.bash
@@ -58,7 +58,7 @@ _dvc_run='--no-exec -f --file -c --cwd -d --deps -o --outs -O --outs-no-cache --
 _dvc_status='-j --jobs -r --remote -a --all-branches -T --all-tags -d --with-deps -c --cloud $(compgen -G *.dvc)'
 _dvc_unlock='$(compgen -G *.dvc)'
 _dvc_unprotect='$(compgen -G *)'
-_dvc_update='$(compgen -G *.dvc)'
+_dvc_update='--rev $(compgen -G *.dvc)'
 _dvc_version=''
 
 # Params
diff --git a/scripts/completion/dvc.zsh b/scripts/completion/dvc.zsh
index 7ee7386b2..4549306ac 100644
--- a/scripts/completion/dvc.zsh
+++ b/scripts/completion/dvc.zsh
@@ -273,6 +273,7 @@ _dvc_unprotect=(
 )
 
 _dvc_update=(
+  "--rev[Git revision (e.g. SHA, branch, tag)]:Revision:"
   "*:Stages:_files -g '(*.dvc|Dvcfile)'"
 )
 


Test patch:
diff --git a/tests/func/test_get.py b/tests/func/test_get.py
index 4c31aad93..e7e928ab4 100644
--- a/tests/func/test_get.py
+++ b/tests/func/test_get.py
@@ -168,6 +168,33 @@ def test_get_from_non_dvc_master(tmp_dir, git_dir, caplog):
     assert (tmp_dir / "some_dst").read_text() == "some text"
 
 
+def test_get_file_from_dir(tmp_dir, erepo_dir):
+    with erepo_dir.chdir():
+        erepo_dir.dvc_gen(
+            {
+                "dir": {
+                    "1": "1",
+                    "2": "2",
+                    "subdir": {"foo": "foo", "bar": "bar"},
+                }
+            },
+            commit="create dir",
+        )
+
+    Repo.get(fspath(erepo_dir), os.path.join("dir", "1"))
+    assert (tmp_dir / "1").read_text() == "1"
+
+    Repo.get(fspath(erepo_dir), os.path.join("dir", "2"), out="file")
+    assert (tmp_dir / "file").read_text() == "2"
+
+    Repo.get(fspath(erepo_dir), os.path.join("dir", "subdir"))
+    assert (tmp_dir / "subdir" / "foo").read_text() == "foo"
+    assert (tmp_dir / "subdir" / "bar").read_text() == "bar"
+
+    Repo.get(fspath(erepo_dir), os.path.join("dir", "subdir", "foo"), out="X")
+    assert (tmp_dir / "X").read_text() == "foo"
+
+
 def test_get_url_positive(tmp_dir, erepo_dir, caplog):
     with erepo_dir.chdir():
         erepo_dir.dvc_gen("foo", "foo")
diff --git a/tests/func/test_import.py b/tests/func/test_import.py
index 17145bafa..23ede6236 100644
--- a/tests/func/test_import.py
+++ b/tests/func/test_import.py
@@ -101,6 +101,42 @@ def test_import_dir(tmp_dir, scm, dvc, erepo_dir):
     }
 
 
+def test_import_file_from_dir(tmp_dir, scm, dvc, erepo_dir):
+    with erepo_dir.chdir():
+        erepo_dir.dvc_gen(
+            {
+                "dir": {
+                    "1": "1",
+                    "2": "2",
+                    "subdir": {"foo": "foo", "bar": "bar"},
+                }
+            },
+            commit="create dir",
+        )
+
+    stage = dvc.imp(fspath(erepo_dir), os.path.join("dir", "1"))
+
+    assert (tmp_dir / "1").read_text() == "1"
+    assert scm.repo.git.check_ignore("1")
+    assert stage.deps[0].def_repo == {
+        "url": fspath(erepo_dir),
+        "rev_lock": erepo_dir.scm.get_rev(),
+    }
+
+    dvc.imp(fspath(erepo_dir), os.path.join("dir", "2"), out="file")
+    assert (tmp_dir / "file").read_text() == "2"
+    assert (tmp_dir / "file.dvc").exists()
+
+    dvc.imp(fspath(erepo_dir), os.path.join("dir", "subdir"))
+    assert (tmp_dir / "subdir" / "foo").read_text() == "foo"
+    assert (tmp_dir / "subdir" / "bar").read_text() == "bar"
+    assert (tmp_dir / "subdir.dvc").exists()
+
+    dvc.imp(fspath(erepo_dir), os.path.join("dir", "subdir", "foo"), out="X")
+    assert (tmp_dir / "X").read_text() == "foo"
+    assert (tmp_dir / "X.dvc").exists()
+
+
 def test_import_non_cached(erepo_dir, tmp_dir, dvc, scm):
     src = "non_cached_output"
     dst = src + "_imported"
diff --git a/tests/func/test_update.py b/tests/func/test_update.py
index 54a5bacbf..ca69a0430 100644
--- a/tests/func/test_update.py
+++ b/tests/func/test_update.py
@@ -2,7 +2,7 @@ import pytest
 import os
 
 from dvc.stage import Stage
-from dvc.compat import fspath
+from dvc.compat import fspath, fspath_py35
 
 
 @pytest.mark.parametrize("cached", [True, False])
@@ -131,3 +131,37 @@ def test_update_import_url(tmp_dir, dvc, tmp_path_factory):
 
     assert dst.is_file()
     assert dst.read_text() == "updated file content"
+
+
+def test_update_rev(tmp_dir, dvc, scm, git_dir):
+    with git_dir.chdir():
+        git_dir.scm_gen({"foo": "foo"}, commit="first")
+
+    dvc.imp(fspath(git_dir), "foo")
+    assert (tmp_dir / "foo.dvc").exists()
+
+    with git_dir.chdir(), git_dir.branch("branch1", new=True):
+        git_dir.scm_gen({"foo": "foobar"}, commit="branch1 commit")
+        branch1_head = git_dir.scm.get_rev()
+
+    with git_dir.chdir(), git_dir.branch("branch2", new=True):
+        git_dir.scm_gen({"foo": "foobar foo"}, commit="branch2 commit")
+        branch2_head = git_dir.scm.get_rev()
+
+    stage = dvc.update("foo.dvc", rev="branch1")
+    assert stage.deps[0].def_repo == {
+        "url": fspath(git_dir),
+        "rev": "branch1",
+        "rev_lock": branch1_head,
+    }
+    with open(fspath_py35(tmp_dir / "foo")) as f:
+        assert "foobar" == f.read()
+
+    stage = dvc.update("foo.dvc", rev="branch2")
+    assert stage.deps[0].def_repo == {
+        "url": fspath(git_dir),
+        "rev": "branch2",
+        "rev_lock": branch2_head,
+    }
+    with open(fspath_py35(tmp_dir / "foo")) as f:
+        assert "foobar foo" == f.read()
diff --git a/tests/unit/command/test_update.py b/tests/unit/command/test_update.py
index 677b24a5a..468c73136 100644
--- a/tests/unit/command/test_update.py
+++ b/tests/unit/command/test_update.py
@@ -1,15 +1,19 @@
+import pytest
 from dvc.cli import parse_args
 from dvc.command.update import CmdUpdate
 
 
-def test_update(dvc, mocker):
+@pytest.mark.parametrize(
+    "command,rev", [(["update"], None), (["update", "--rev", "REV"], "REV")]
+)
+def test_update(dvc, mocker, command, rev):
     targets = ["target1", "target2", "target3"]
-    cli_args = parse_args(["update"] + targets)
+    cli_args = parse_args(command + targets)
     assert cli_args.func == CmdUpdate
     cmd = cli_args.func(cli_args)
     m = mocker.patch("dvc.repo.Repo.update")
 
     assert cmd.run() == 0
 
-    calls = [mocker.call(target) for target in targets]
+    calls = [mocker.call(target, rev) for target in targets]
     m.assert_has_calls(calls)
diff --git a/tests/unit/output/test_output.py b/tests/unit/output/test_output.py
new file mode 100644
index 000000000..2cf30e968
--- /dev/null
+++ b/tests/unit/output/test_output.py
@@ -0,0 +1,42 @@
+import pytest
+
+from voluptuous import Schema, MultipleInvalid
+
+from dvc.output import CHECKSUM_SCHEMA
+
+
+@pytest.mark.parametrize(
+    "value,expected",
+    [
+        ("", None),
+        (None, None),
+        (11111, "11111"),
+        ("11111", "11111"),
+        ("aAaBa", "aaaba"),
+        (
+            "3cc286c534a71504476da009ed174423",
+            "3cc286c534a71504476da009ed174423",
+        ),  # md5
+        (
+            "d41d8cd98f00b204e9800998ecf8427e-38",
+            "d41d8cd98f00b204e9800998ecf8427e-38",
+        ),  # etag
+        (
+            "000002000000000000000000c16859d1d071c6b1ffc9c8557d4909f1",
+            "000002000000000000000000c16859d1d071c6b1ffc9c8557d4909f1",
+        ),  # hdfs checksum
+        # Not much we can do about hex and oct values without writing our own
+        # parser. So listing these test cases just to acknowledge this.
+        # See https://github.com/iterative/dvc/issues/3331.
+        (0x3451, "13393"),
+        (0o1244, "676"),
+    ],
+)
+def test_checksum_schema(value, expected):
+    assert Schema(CHECKSUM_SCHEMA)(value) == expected
+
+
+@pytest.mark.parametrize("value", ["1", "11", {}, {"a": "b"}, [], [1, 2]])
+def test_checksum_schema_fail(value):
+    with pytest.raises(MultipleInvalid):
+        Schema(CHECKSUM_SCHEMA)(value)["md5"]
diff --git a/tests/unit/test_logger.py b/tests/unit/test_logger.py
index 83f3c7d43..e16323eaa 100644
--- a/tests/unit/test_logger.py
+++ b/tests/unit/test_logger.py
@@ -113,7 +113,30 @@ class TestColorFormatter:
                     line="-" * 60,
                     stack_trace=stack_trace,
                     **colors,
-                    datetime=dt
+                    datetime=dt,
+                )
+            )
+
+            assert expected == formatter.format(caplog.records[0])
+
+    def test_exc_info_on_other_record_types(self, caplog, dt):
+        with caplog.at_level(logging.DEBUG, logger="dvc"):
+            try:
+                raise Exception("description")
+            except Exception:
+                stack_trace = traceback.format_exc()
+                logger.debug("", exc_info=True)
+
+            expected = (
+                "{green}{datetime}{nc} "
+                "{blue}DEBUG{nc}: description\n"
+                "{red}{line}{nc}\n"
+                "{stack_trace}"
+                "{red}{line}{nc}".format(
+                    line="-" * 60,
+                    stack_trace=stack_trace,
+                    datetime=dt,
+                    **colors,
                 )
             )
 
@@ -136,7 +159,7 @@ class TestColorFormatter:
                     line="-" * 60,
                     stack_trace=stack_trace,
                     **colors,
-                    datetime=dt
+                    datetime=dt,
                 )
             )
 
@@ -162,7 +185,7 @@ class TestColorFormatter:
                     line="-" * 60,
                     stack_trace=stack_trace,
                     **colors,
-                    datetime=dt
+                    datetime=dt,
                 )
             )
             assert expected == formatter.format(caplog.records[0])
diff --git a/tests/unit/test_progress.py b/tests/unit/test_progress.py
index 72005f65c..30dd7e662 100644
--- a/tests/unit/test_progress.py
+++ b/tests/unit/test_progress.py
@@ -16,6 +16,17 @@ def test_quiet_logging(caplog, capsys):
         assert out_err.err == ""
 
 
+def test_quiet_logging_disable_false(caplog, capsys):
+    with caplog.at_level(logging.CRITICAL, logger="dvc"):
+        # simulate interactive terminal
+        with mock.patch.object(sys.stderr, "isatty", return_value=True):
+            for _ in Tqdm(range(10), disable=False):
+                pass
+            out_err = capsys.readouterr()
+            assert out_err.out == ""
+            assert out_err.err == ""
+
+
 def test_quiet_notty(caplog, capsys):
     with caplog.at_level(logging.INFO, logger="dvc"):
         for _ in Tqdm(range(10)):