Repository: iterative/dvc

Issue:
dvc list --rev: fails on local repo
# Bug Report

## Description

When doing `dvc list . . --rev HEAD` or similar commands with `--rev` on a local repo, command fails.

### Reproduce

1. Start in an existing dvc repo
2. Run `dvc list -v . . --rev HEAD`

Output:
```console
2021-04-22 16:54:41,169 ERROR: unexpected error
------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/dave/Code/dvc/dvc/main.py", line 55, in main
    ret = cmd.run()
  File "/Users/dave/Code/dvc/dvc/command/ls/__init__.py", line 30, in run
    entries = Repo.ls(
  File "/Users/dave/Code/dvc/dvc/repo/ls.py", line 33, in ls
    with Repo.open(url, rev, subrepos=True, uninitialized=True) as repo:
  File "/Users/dave/miniconda3/envs/example-get-started/lib/python3.8/contextlib.py", line 113, in __enter__
    return next(self.gen)
  File "/Users/dave/Code/dvc/dvc/repo/__init__.py", line 219, in open
    yield Repo(url, *args, **kwargs)
  File "/Users/dave/Code/dvc/dvc/repo/__init__.py", line 156, in __init__
    self.root_dir, self.dvc_dir, self.tmp_dir = self._get_repo_dirs(
  File "/Users/dave/Code/dvc/dvc/repo/__init__.py", line 92, in _get_repo_dirs
    assert bool(scm) == bool(rev)
AssertionError
------------------------------------------------------------
2021-04-22 16:54:42,272 DEBUG: Version info for developers:
DVC version: 2.0.18+17d7b0
---------------------------------
Platform: Python 3.8.5 on macOS-10.16-x86_64-i386-64bit
Supports: azure, gdrive, hdfs, webhdfs, http, https, s3, ssh, oss, webdav, webdavs
Cache types: reflink, hardlink, symlink
Cache directory: apfs on /dev/disk3s1s1
Caches: local
Remotes: https, s3, local
Workspace directory: apfs on /dev/disk3s1s1
Repo: dvc, git

Having any troubles? Hit us up at https://dvc.org/support, we are always happy to help!
2021-04-22 16:54:42,273 DEBUG: Analytics is enabled.
2021-04-22 16:54:42,367 DEBUG: Trying to spawn '['daemon', '-q', 'analytics', '/var/folders/24/99_tf1xj3vx8k1k_jkdmnhq00000gn/T/tmpu3h0uu25']'
2021-04-22 16:54:42,372 DEBUG: Spawned '['daemon', '-q', 'analytics', '/var/folders/24/99_tf1xj3vx8k1k_jkdmnhq00000gn/T/tmpu3h0uu25']'
```

### Expected

Under discussion 🤣 

### Environment information

**Output of `dvc doctor`:**

```console
$ dvc doctor
DVC version: 2.0.18+17d7b0
---------------------------------
Platform: Python 3.8.5 on macOS-10.16-x86_64-i386-64bit
Supports: azure, gdrive, hdfs, webhdfs, http, https, s3, ssh, oss, webdav, webdavs
Cache types: reflink, hardlink, symlink
Cache directory: apfs on /dev/disk3s1s1
Caches: local
Remotes: https, s3, local
Workspace directory: apfs on /dev/disk3s1s1
Repo: dvc, git
```


Discussion:
Good thing I checked because I just ran into the exact same problem (probably even doing the same test).
Note that this was supposed to be fixed by https://github.com/iterative/dvc/pull/5822, but looks like it's not (@dberenbaum's commit is ahead of 853d304ce2c18fb59a80f4eeb086d020d476a014).

Resolving patch:
diff --git a/dvc/repo/ls.py b/dvc/repo/ls.py
--- a/dvc/repo/ls.py
+++ b/dvc/repo/ls.py
@@ -28,7 +28,7 @@ def ls(url, path=None, rev=None, recursive=None, dvc_only=False):
     """
     from . import Repo
 
-    with Repo.open(url, rev, subrepos=True, uninitialized=True) as repo:
+    with Repo.open(url, rev=rev, subrepos=True, uninitialized=True) as repo:
         path_info = PathInfo(repo.root_dir)
         if path:
             path_info /= path


Test patch:
diff --git a/tests/func/test_ls.py b/tests/func/test_ls.py
--- a/tests/func/test_ls.py
+++ b/tests/func/test_ls.py
@@ -273,6 +273,24 @@ def test_ls_repo_with_removed_dvc_dir_with_path_file(tmp_dir, dvc, scm):
     match_files(files, ((("file",), True),))
 
 
+def test_ls_repo_with_rev(erepo_dir):
+    with erepo_dir.chdir():
+        erepo_dir.scm_gen(FS_STRUCTURE, commit="init")
+        erepo_dir.dvc_gen(DVC_STRUCTURE, commit="dvc")
+
+    rev = erepo_dir.scm.list_all_commits()[1]
+    files = Repo.ls(os.fspath(erepo_dir), rev=rev)
+    match_files(
+        files,
+        (
+            ((".dvcignore",), False),
+            ((".gitignore",), False),
+            (("README.md",), False),
+            (("model",), False),
+        ),
+    )
+
+
 def test_ls_remote_repo(erepo_dir):
     with erepo_dir.chdir():
         erepo_dir.scm_gen(FS_STRUCTURE, commit="init")