# Buggy code
def brancher(  # noqa: E302
    self, revs=None, all_branches=False, all_tags=False, all_commits=False
):
    """Generator that iterates over specified revisions.

    Args:
        revs (list): a list of revisions to iterate over.
        all_branches (bool): iterate over all available branches.
        all_commits (bool): iterate over all commits.
        all_tags (bool): iterate over all available tags.

    Yields:
        str: the display name for the currently selected tree, it could be:
            - a git revision identifier
            - empty string it there is no branches to iterate over
            - "workspace" if there are uncommitted changes in the SCM repo
    """
    if not any([revs, all_branches, all_tags, all_commits]):
        yield ""
        return

    saved_tree = self.tree
    revs = revs.copy() if revs else []

    scm = self.scm

    self.tree = LocalTree(self, {"url": self.root_dir}, use_dvcignore=True)
    yield "workspace"

    if revs and "workspace" in revs:
        revs.remove("workspace")

    if all_commits:
        revs = scm.list_all_commits()
    else:
        if all_branches:
            revs.extend(scm.list_branches())

        if all_tags:
            revs.extend(scm.list_tags())

    try:
        if revs:
            for sha, names in group_by(scm.resolve_rev, revs).items():
                self.tree = scm.get_tree(
                    sha, use_dvcignore=True, dvcignore_root=self.root_dir
                )
                # ignore revs that don't contain repo root
                # (i.e. revs from before a subdir=True repo was init'ed)
                if self.tree.exists(self.root_dir):
                    yield ", ".join(names)
    finally:
        self.tree = saved_tree


# Traceback (dvc.scm.base.RevError)
dvc exp show -T -v
2020-09-21 17:33:07,541 DEBUG: Check for update is enabled.
2020-09-21 17:33:07,570 DEBUG: fetched: [(3,)]
2020-09-21 17:33:08,049 DEBUG: fetched: [(75,)]
2020-09-21 17:33:08,058 ERROR: failed to show experiments - unknown Git revision 'f97e3cca64d10c299f7e9e54dd22889c6ee7a1b4, decouple/base'
------------------------------------------------------------
Traceback (most recent call last):
File "/home/roman/miniconda3/envs/tensorflow/lib/python3.6/site-packages/dvc/command/experiments.py", line 258, in run
sha_only=self.args.sha,
File "/home/roman/miniconda3/envs/tensorflow/lib/python3.6/site-packages/dvc/repo/experiments/__init__.py", line 616, in show
return show(self.repo, *args, **kwargs)
File "/home/roman/miniconda3/envs/tensorflow/lib/python3.6/site-packages/dvc/repo/__init__.py", line 51, in wrapper
return f(repo, *args, **kwargs)
File "/home/roman/miniconda3/envs/tensorflow/lib/python3.6/site-packages/dvc/repo/experiments/show.py", line 73, in show
repo, rev, sha_only=sha_only
File "/home/roman/miniconda3/envs/tensorflow/lib/python3.6/site-packages/dvc/repo/experiments/show.py", line 16, in _collect_experiment
for rev in repo.brancher(revs=[branch]):
File "/home/roman/miniconda3/envs/tensorflow/lib/python3.6/site-packages/dvc/repo/brancher.py", line 49, in brancher
for sha, names in group_by(scm.resolve_rev, revs).items():
File "/home/roman/miniconda3/envs/tensorflow/lib/python3.6/site-packages/funcy/seqs.py", line 317, in group_by
result[f(item)].append(item)
File "/home/roman/miniconda3/envs/tensorflow/lib/python3.6/site-packages/dvc/scm/git.py", line 432, in resolve_rev
raise RevError(f"unknown Git revision '{rev}'")
dvc.scm.base.RevError: unknown Git revision 'f97e3cca64d10c299f7e9e54dd22889c6ee7a1b4, decouple/base'

# Fixed code
def brancher(  # noqa: E302
    self,
    revs=None,
    all_branches=False,
    all_tags=False,
    all_commits=False,
    sha_only=False,
):
    """Generator that iterates over specified revisions.

    Args:
        revs (list): a list of revisions to iterate over.
        all_branches (bool): iterate over all available branches.
        all_commits (bool): iterate over all commits.
        all_tags (bool): iterate over all available tags.
        sha_only (bool): only return git SHA for a revision.

    Yields:
        str: the display name for the currently selected tree, it could be:
            - a git revision identifier
            - empty string it there is no branches to iterate over
            - "workspace" if there are uncommitted changes in the SCM repo
    """
    if not any([revs, all_branches, all_tags, all_commits]):
        yield ""
        return

    saved_tree = self.tree
    revs = revs.copy() if revs else []

    scm = self.scm

    self.tree = LocalTree(self, {"url": self.root_dir}, use_dvcignore=True)
    yield "workspace"

    if revs and "workspace" in revs:
        revs.remove("workspace")

    if all_commits:
        revs = scm.list_all_commits()
    else:
        if all_branches:
            revs.extend(scm.list_branches())

        if all_tags:
            revs.extend(scm.list_tags())

    try:
        if revs:
            for sha, names in group_by(scm.resolve_rev, revs).items():
                self.tree = scm.get_tree(
                    sha, use_dvcignore=True, dvcignore_root=self.root_dir
                )
                # ignore revs that don't contain repo root
                # (i.e. revs from before a subdir=True repo was init'ed)
                if self.tree.exists(self.root_dir):
                    if sha_only:
                        yield sha
                    else:
                        yield ", ".join(names)
    finally:
        self.tree = saved_tree