Repository: conan-io/conan

Issue:
[feature] scm to conandata helper
### What is your suggestion?

In Conan 1.X there was the possibility via the ``scm`` feature to add something to conandata like 
```python
conandata_yml['.conan'] = {'scm': scm_data_copied}
```
Now it is possible with just 3 lines:
```python
def export(self):
                git = Git(self, self.recipe_folder)
                scm_url, scm_commit = git.get_url_and_commit()
                update_conandata(self, {"scm": {"commit": scm_commit, "url": scm_url}})
```
but it would be nice to have some one liner with one standard convention for this.

### Have you read the CONTRIBUTING guide?

- [ ] I've read the CONTRIBUTING guide


Discussion:
To take into account: the ``trim_conandata`` possible interactions



Patch:
diff --git a/conan/tools/files/conandata.py b/conan/tools/files/conandata.py
index c6925450826..0b01824bbc5 100644
--- a/conan/tools/files/conandata.py
+++ b/conan/tools/files/conandata.py
@@ -58,7 +58,7 @@ def trim_conandata(conanfile):
     version = str(conanfile.version)
     result = {}
     for k, v in conandata.items():
-        if not isinstance(v, dict):
+        if k == "scm" or not isinstance(v, dict):
             result[k] = v
             continue  # to allow user extra conandata, common to all versions
         version_data = v.get(version)
diff --git a/conan/tools/scm/git.py b/conan/tools/scm/git.py
index 77d0e6dbbfd..b4944a1b3a2 100644
--- a/conan/tools/scm/git.py
+++ b/conan/tools/scm/git.py
@@ -1,7 +1,7 @@
 import fnmatch
 import os
 
-from conan.tools.files import chdir
+from conan.tools.files import chdir, update_conandata
 from conan.errors import ConanException
 from conans.model.conf import ConfDefinition
 from conans.util.files import mkdir
@@ -237,3 +237,12 @@ def included_files(self):
         files = self.run("ls-files --full-name --others --cached --exclude-standard")
         files = files.splitlines()
         return files
+
+    def coordinates_to_conandata(self):
+        scm_url, scm_commit = self.get_url_and_commit()
+        update_conandata(self._conanfile, {"scm": {"commit": scm_commit, "url": scm_url}})
+
+    def checkout_from_conandata_coordinates(self):
+        sources = self._conanfile.conan_data["scm"]
+        self.clone(url=sources["url"], target=".")
+        self.checkout(commit=sources["commit"])


Test patch:
diff --git a/conans/test/functional/tools/scm/test_git.py b/conans/test/functional/tools/scm/test_git.py
index af096464243..3a47bd31b21 100644
--- a/conans/test/functional/tools/scm/test_git.py
+++ b/conans/test/functional/tools/scm/test_git.py
@@ -481,7 +481,7 @@ class TestGitBasicSCMFlow:
     - export() stores it in conandata.yml
     - source() recovers the info from conandata.yml and clones it
     """
-    conanfile = textwrap.dedent("""
+    conanfile_full = textwrap.dedent("""
         import os
         from conan import ConanFile
         from conan.tools.scm import Git
@@ -513,10 +513,40 @@ def build(self):
                 self.output.info("MYCMAKE-BUILD: {}".format(load(self, cmake)))
                 self.output.info("MYFILE-BUILD: {}".format(load(self, file_h)))
         """)
+    conanfile_scm = textwrap.dedent("""
+        import os
+        from conan import ConanFile
+        from conan.tools.scm import Git
+        from conan.tools.files import load, trim_conandata
 
-    def test_full_scm(self):
+        class Pkg(ConanFile):
+            name = "pkg"
+            version = "0.1"
+
+            def export(self):
+                Git(self).coordinates_to_conandata()
+                trim_conandata(self)  # to test it does not affect
+
+            def layout(self):
+                self.folders.source = "."
+
+            def source(self):
+                Git(self).checkout_from_conandata_coordinates()
+                self.output.info("MYCMAKE: {}".format(load(self, "CMakeLists.txt")))
+                self.output.info("MYFILE: {}".format(load(self, "src/myfile.h")))
+
+            def build(self):
+                cmake = os.path.join(self.source_folder, "CMakeLists.txt")
+                file_h = os.path.join(self.source_folder, "src/myfile.h")
+                self.output.info("MYCMAKE-BUILD: {}".format(load(self, cmake)))
+                self.output.info("MYFILE-BUILD: {}".format(load(self, file_h)))
+        """)
+
+    @pytest.mark.parametrize("conanfile_scm", [False, True])
+    def test_full_scm(self, conanfile_scm):
+        conanfile = self.conanfile_scm if conanfile_scm else self.conanfile_full
         folder = os.path.join(temp_folder(), "myrepo")
-        url, commit = create_local_git_repo(files={"conanfile.py": self.conanfile,
+        url, commit = create_local_git_repo(files={"conanfile.py": conanfile,
                                                    "src/myfile.h": "myheader!",
                                                    "CMakeLists.txt": "mycmake"}, folder=folder)
 
@@ -543,15 +573,17 @@ def test_full_scm(self):
         assert "conanfile.py (pkg/0.1): MYCMAKE-BUILD: mycmake" in c.out
         assert "conanfile.py (pkg/0.1): MYFILE-BUILD: myheader!" in c.out
 
-    def test_branch_flow(self):
+    @pytest.mark.parametrize("conanfile_scm", [False, True])
+    def test_branch_flow(self, conanfile_scm):
         """ Testing that when a user creates a branch, and pushes a commit,
         the package can still be built from sources, and get_url_and_commit() captures the
         remote URL and not the local
         """
+        conanfile = self.conanfile_scm if conanfile_scm else self.conanfile_full
         url = git_create_bare_repo()
         c = TestClient(default_server_user=True)
         c.run_command('git clone "{}" .'.format(url))
-        c.save({"conanfile.py": self.conanfile,
+        c.save({"conanfile.py": conanfile,
                 "src/myfile.h": "myheader!",
                 "CMakeLists.txt": "mycmake"})
         c.run_command("git checkout -b mybranch")