Repository: iterative/dvc

Issue:
move: meta field is not preserved after moving a file
# Bug Report

## Description
When moving/renaming a file with `dvc move` the `meta` field in the .dvc file is not moved

### Reproduce
add meta field to the .dvc file. Then move/rename the file with `dvc move`. The .dvc file for the new file doesn't contain the `meta` field.
This is a regression between versions 2.1.0 and 2.2.0. (also happens in 2.3.0)

1. dvc init
2. Copy dataset.zip to the directory
3. dvc add dataset.zip
4. edit dataset.zip.dvc and add meta field
5. dvc move dataset.zip dataset2.zip
6. cat dataset.zip.dvc -> meta field does not exist

### Expected
the new .dvc file should contain the meta field

### Environment information


**Output of `dvc doctor`:**

```console
$ dvc doctor

DVC version: 2.2.0 (pip)
---------------------------------
Platform: Python 3.7.9 on Darwin-20.5.0-x86_64-i386-64bit
Supports: http, https
Cache types: reflink, hardlink, symlink
Cache directory: apfs on /dev/disk1s1s1
Caches: local
Remotes: None
Workspace directory: apfs on /dev/disk1s1s1
Repo: dvc, git

```

**Additional Information (if any):**

move: meta field is not preserved after moving a file
# Bug Report

## Description
When moving/renaming a file with `dvc move` the `meta` field in the .dvc file is not moved

### Reproduce
add meta field to the .dvc file. Then move/rename the file with `dvc move`. The .dvc file for the new file doesn't contain the `meta` field.
This is a regression between versions 2.1.0 and 2.2.0. (also happens in 2.3.0)

1. dvc init
2. Copy dataset.zip to the directory
3. dvc add dataset.zip
4. edit dataset.zip.dvc and add meta field
5. dvc move dataset.zip dataset2.zip
6. cat dataset.zip.dvc -> meta field does not exist

### Expected
the new .dvc file should contain the meta field

### Environment information


**Output of `dvc doctor`:**

```console
$ dvc doctor

DVC version: 2.2.0 (pip)
---------------------------------
Platform: Python 3.7.9 on Darwin-20.5.0-x86_64-i386-64bit
Supports: http, https
Cache types: reflink, hardlink, symlink
Cache directory: apfs on /dev/disk1s1s1
Caches: local
Remotes: None
Workspace directory: apfs on /dev/disk1s1s1
Repo: dvc, git

```

**Additional Information (if any):**



Discussion:

Resolving patch:
diff --git a/dvc/repo/move.py b/dvc/repo/move.py
--- a/dvc/repo/move.py
+++ b/dvc/repo/move.py
@@ -62,7 +62,11 @@ def move(self, from_path, to_path):
         )
         to_path = os.path.relpath(to_path, new_wdir)
         new_stage = self.stage.create(
-            single_stage=True, fname=new_fname, wdir=new_wdir, outs=[to_path]
+            single_stage=True,
+            fname=new_fname,
+            wdir=new_wdir,
+            outs=[to_path],
+            meta=stage.meta,
         )
 
         os.unlink(stage.path)


Test patch:
diff --git a/tests/func/test_move.py b/tests/func/test_move.py
--- a/tests/func/test_move.py
+++ b/tests/func/test_move.py
@@ -1,11 +1,12 @@
 import os
+import textwrap
 
 import pytest
 
 from dvc.dvcfile import DVC_FILE_SUFFIX
 from dvc.exceptions import DvcException, MoveNotDataSourceError
 from dvc.main import main
-from dvc.utils.serialize import load_yaml
+from dvc.utils.serialize import dump_yaml, load_yaml
 from tests.basic_env import TestDvc, TestDvcGit
 from tests.func.test_repro import TestRepro
 from tests.utils import cd
@@ -244,3 +245,24 @@ def test_move_output_overlap(tmp_dir, dvc):
     assert (tmp_dir / "foo.dvc").exists()
     assert not (tmp_dir / "dir" / "foo").exists()
     assert not (tmp_dir / "dir" / "foo.dvc").exists()
+
+
+def test_move_meta(tmp_dir, dvc):
+    (stage,) = tmp_dir.dvc_gen("foo", "foo")
+    data = load_yaml(stage.path)
+    data["meta"] = {"custom_key": 42}
+    dump_yaml(stage.path, data)
+
+    dvc.move("foo", "bar")
+    res = (tmp_dir / "bar.dvc").read_text()
+    print(res)
+    assert res == textwrap.dedent(
+        """\
+        outs:
+        - md5: acbd18db4cc2f85cedef654fccc4a4d8
+          size: 3
+          path: bar
+        meta:
+          custom_key: 42
+    """
+    )