Repository: iterative/dvc

Issue:
`dvc commit` fails with files imported via `dvc import`
## Bug Report
Hello! I am importing some files in my main repo from another repo using the command `dvc import`.
Upon running `dvc commit` afterward, I get the following error (output of `dvc commit -v`):

```
2020-07-14 18:50:54,511 ERROR: unexpected error - 'NoneType' object has no attribute 'scheme'
------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/main.py", line 53, in main
    ret = cmd.run()
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/command/commit.py", line 18, in run
    self.repo.commit(
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/repo/__init__.py", line 36, in wrapper
    ret = f(repo, *args, **kwargs)
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/repo/commit.py", line 42, in commit
    changes = stage.changed_entries()
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/stage/__init__.py", line 405, in changed_entries
    changed_deps = self._changed_entries(self.deps)
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/stage/__init__.py", line 399, in _changed_entries
    return [str(entry) for entry in entries if entry.changed_checksum()]
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/stage/__init__.py", line 399, in <listcomp>
    return [str(entry) for entry in entries if entry.changed_checksum()]
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/output/base.py", line 195, in changed_checksum
    return self.checksum != self.get_checksum()
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/output/base.py", line 181, in get_checksum
    return self.remote.get_hash(self.path_info)
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/remote/base.py", line 735, in get_hash
    return self.tree.get_hash(path_info, **kwargs)
  File "/usr/local/Cellar/dvc/1.1.10/libexec/lib/python3.8/site-packages/dvc/remote/base.py", line 276, in get_hash
    assert isinstance(path_info, str) or path_info.scheme == self.scheme
AttributeError: 'NoneType' object has no attribute 'scheme'
------------------------------------------------------------
```
If I perform `dvc add` on the files imported (effectively "pinning" them to the main repo) the error disappears and the command executes successfully.

As a workaround, adding the following lines before the `assert` statement in the function `get_hash()` in  `dvc/remote/base.py` gets rid of the error even for files imported via `dvc import`:
```
    def get_hash(self, path_info, tree=None, **kwargs):
        if not path_info:
            return None

        assert isinstance(path_info, str) or path_info.scheme == self.scheme
```
I never had any problem with DVC<1.0.0
My setup:
```
DVC version: 1.1.10
Python version: 3.8.3
Platform: macOS-10.14.6-x86_64-i386-64bit
Binary: False
Package: brew
Supported remotes: azure, gdrive, gs, http, https, s3, ssh, oss
Cache: reflink - supported, hardlink - supported, symlink - supported
Repo: dvc, git
```



Discussion:
reproduction script:
```
#!/bin/bash

set -ex

rm -rf repo other storage
mkdir repo other

main=$(pwd)

pushd other
git init --quiet
dvc init --quiet

echo data >> data
dvc add data
dvc remote add -d str $main/storage

dvc push

git add -A
git commit -am "init"

popd
pushd repo

git init --quiet
dvc init --quiet

git add -A
git commit -am "init"

dvc import $main/other data
dvc -v commit
```

Resolving patch:
diff --git a/dvc/dependency/repo.py b/dvc/dependency/repo.py
--- a/dvc/dependency/repo.py
+++ b/dvc/dependency/repo.py
@@ -98,3 +98,9 @@ def update(self, rev=None):
 
         with self._make_repo(locked=False) as repo:
             self.def_repo[self.PARAM_REV_LOCK] = repo.get_rev()
+
+    def changed_checksum(self):
+        # From current repo point of view what describes RepoDependency is its
+        # origin project url and rev_lock, and it makes RepoDependency
+        # immutable, hence its impossible for checksum to change.
+        return False
diff --git a/dvc/tree/base.py b/dvc/tree/base.py
--- a/dvc/tree/base.py
+++ b/dvc/tree/base.py
@@ -245,7 +245,9 @@ def is_dir_hash(cls, hash_):
         return hash_.endswith(cls.CHECKSUM_DIR_SUFFIX)
 
     def get_hash(self, path_info, tree=None, **kwargs):
-        assert isinstance(path_info, str) or path_info.scheme == self.scheme
+        assert path_info and (
+            isinstance(path_info, str) or path_info.scheme == self.scheme
+        )
 
         if not tree:
             tree = self


Test patch:
diff --git a/tests/func/test_commit.py b/tests/func/test_commit.py
--- a/tests/func/test_commit.py
+++ b/tests/func/test_commit.py
@@ -1,3 +1,5 @@
+from os import fspath
+
 import pytest
 
 from dvc.dvcfile import PIPELINE_FILE
@@ -95,3 +97,13 @@ def test_commit_pipeline_stage(tmp_dir, dvc, run_copy):
     assert dvc.commit(f":{stage.addressing}") == [stage]
     assert dvc.commit(f"{PIPELINE_FILE}:{stage.addressing}") == [stage]
     assert dvc.commit(PIPELINE_FILE) == [stage]
+
+
+def test_imported_entries_unchanged(tmp_dir, dvc, erepo_dir):
+    with erepo_dir.chdir():
+        erepo_dir.dvc_gen("file", "file content", "initial commit")
+
+    stage = dvc.imp(fspath(erepo_dir), "file")
+
+    with dvc.state:
+        assert stage.changed_entries() == ([], [], None)