We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Confusing message or behavior in SCM when url can't be deduced
It raises:

```python
if not origin:
            raise ConanException("Repo origin cannot be deduced by 'auto', using source folder")
```

But it doesn't use the source folder, as execution is aborted. Maybe change the message? Or allow to proceed and create the package locally, even if the remote URL is not defined?



--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `conans/client/cmd/export.py`
Content:
```
1 """ manages the movement of conanfiles and associated files from the user space
2 to the local store, as an initial step before building or uploading to remotes
3 """
4 
5 import os
6 import shutil
7 
8 from conans.client.cmd.export_linter import conan_linter
9 from conans.client.file_copier import FileCopier
10 from conans.client.loader_parse import load_conanfile_class
11 from conans.client.output import ScopedOutput
12 from conans.client.source import get_scm
13 from conans.errors import ConanException
14 from conans.model.conan_file import create_exports, create_exports_sources
15 from conans.model.manifest import FileTreeManifest
16 from conans.model.ref import ConanFileReference
17 from conans.paths import CONAN_MANIFEST, CONANFILE
18 from conans.util.files import save, rmdir, is_dirty, set_dirty, mkdir
19 from conans.util.log import logger
20 from conans.search.search import search_recipes
21 
22 
23 def export_alias(reference, target_reference, client_cache):
24     conanfile = """
25 from conans import ConanFile
26 
27 class AliasConanfile(ConanFile):
28     alias = "%s"
29 """ % str(target_reference)
30 
31     export_path = client_cache.export(reference)
32     mkdir(export_path)
33     save(os.path.join(export_path, CONANFILE), conanfile)
34     mkdir(client_cache.export_sources(reference))
35     digest = FileTreeManifest.create(export_path)
36     digest.save(export_path)
37 
38 
39 def cmd_export(conanfile_path, name, version, user, channel, keep_source,
40                output, client_cache):
41     """ Export the recipe
42     param conanfile_path: the original source directory of the user containing a
43                        conanfile.py
44     param user: user under this package will be exported
45     param channel: string (stable, testing,...)
46     """
47     logger.debug("Exporting %s" % conanfile_path)
48 
49     conan_linter(conanfile_path, output)
50     conanfile = _load_export_conanfile(conanfile_path, output, name, version)
51     conan_ref = ConanFileReference(conanfile.name, conanfile.version, user, channel)
52     conan_ref_str = str(conan_ref)
53     # Maybe a platform check could be added, but depends on disk partition
54     refs = search_recipes(client_cache, conan_ref_str, ignorecase=True)
55     if refs and conan_ref not in refs:
56         raise ConanException("Cannot export package with same name but different case\n"
57                              "You exported '%s' but already existing '%s'"
58                              % (conan_ref_str, " ".join(str(s) for s in refs)))
59     output = ScopedOutput(str(conan_ref), output)
60     with client_cache.conanfile_write_lock(conan_ref):
61         _export_conanfile(conanfile_path, output, client_cache, conanfile, conan_ref, keep_source)
62 
63 
64 def _load_export_conanfile(conanfile_path, output, name, version):
65     conanfile = load_conanfile_class(conanfile_path)
66 
67     for field in ["url", "license", "description"]:
68         field_value = getattr(conanfile, field, None)
69         if not field_value:
70             output.warn("Conanfile doesn't have '%s'.\n"
71                         "It is recommended to add it as attribute" % field)
72 
73     try:
74         # Exports is the only object field, we need to do this, because conan export needs it
75         conanfile.exports = create_exports(conanfile)
76         conanfile.exports_sources = create_exports_sources(conanfile)
77     except Exception as e:  # re-raise with file name
78         raise ConanException("%s: %s" % (conanfile_path, str(e)))
79 
80     # check name and version were specified
81     if not conanfile.name:
82         if name:
83             conanfile.name = name
84         else:
85             raise ConanException("conanfile didn't specify name")
86     elif name and name != conanfile.name:
87         raise ConanException("Package recipe exported with name %s!=%s" % (name, conanfile.name))
88 
89     if not conanfile.version:
90         if version:
91             conanfile.version = version
92         else:
93             raise ConanException("conanfile didn't specify version")
94     elif version and version != conanfile.version:
95         raise ConanException("Package recipe exported with version %s!=%s"
96                              % (version, conanfile.version))
97 
98     return conanfile
99 
100 
101 def _capture_export_scm_data(conanfile, src_path, destination_folder, output, paths, conan_ref):
102 
103     scm_src_file = paths.scm_folder(conan_ref)
104     if os.path.exists(scm_src_file):
105         os.unlink(scm_src_file)
106 
107     scm = get_scm(conanfile, src_path)
108 
109     if not scm or not (scm.capture_origin or scm.capture_revision):
110         return
111 
112     if scm.url == "auto":
113         origin = scm.get_remote_url()
114         if not origin:
115             raise ConanException("Repo origin cannot be deduced by 'auto', using source folder")
116         output.success("Repo origin deduced by 'auto': %s" % origin)
117         scm.url = origin
118     if scm.revision == "auto":
119         scm.revision = scm.get_revision()
120         output.success("Revision deduced by 'auto': %s" % scm.revision)
121 
122     # Generate the scm_folder.txt file pointing to the src_path
123     save(scm_src_file, src_path.replace("\\", "/"))
124     scm.replace_in_file(os.path.join(destination_folder, "conanfile.py"))
125 
126 
127 def _export_conanfile(conanfile_path, output, paths, conanfile, conan_ref, keep_source):
128 
129     exports_folder = paths.export(conan_ref)
130     exports_source_folder = paths.export_sources(conan_ref, conanfile.short_paths)
131     previous_digest = _init_export_folder(exports_folder, exports_source_folder)
132     _execute_export(conanfile_path, conanfile, exports_folder, exports_source_folder, output)
133     shutil.copy2(conanfile_path, os.path.join(exports_folder, CONANFILE))
134 
135     _capture_export_scm_data(conanfile, os.path.dirname(conanfile_path), exports_folder,
136                              output, paths, conan_ref)
137 
138     digest = FileTreeManifest.create(exports_folder, exports_source_folder)
139 
140     if previous_digest and previous_digest == digest:
141         output.info("The stored package has not changed")
142         modified_recipe = False
143         digest = previous_digest  # Use the old one, keep old timestamp
144     else:
145         output.success('A new %s version was exported' % CONANFILE)
146         output.info('Folder: %s' % exports_folder)
147         modified_recipe = True
148     digest.save(exports_folder)
149 
150     source = paths.source(conan_ref, conanfile.short_paths)
151     remove = False
152     if is_dirty(source):
153         output.info("Source folder is corrupted, forcing removal")
154         remove = True
155     elif modified_recipe and not keep_source and os.path.exists(source):
156         output.info("Package recipe modified in export, forcing source folder removal")
157         output.info("Use the --keep-source, -k option to skip it")
158         remove = True
159     if remove:
160         output.info("Removing 'source' folder, this can take a while for big packages")
161         try:
162             # remove only the internal
163             rmdir(source)
164         except BaseException as e:
165             output.error("Unable to delete source folder. "
166                          "Will be marked as corrupted for deletion")
167             output.warn(str(e))
168             set_dirty(source)
169 
170 
171 def _init_export_folder(destination_folder, destination_src_folder):
172     previous_digest = None
173     try:
174         if os.path.exists(destination_folder):
175             if os.path.exists(os.path.join(destination_folder, CONAN_MANIFEST)):
176                 previous_digest = FileTreeManifest.load(destination_folder)
177             # Maybe here we want to invalidate cache
178             rmdir(destination_folder)
179         os.makedirs(destination_folder)
180     except Exception as e:
181         raise ConanException("Unable to create folder %s\n%s" % (destination_folder, str(e)))
182     try:
183         if os.path.exists(destination_src_folder):
184             rmdir(destination_src_folder)
185         os.makedirs(destination_src_folder)
186     except Exception as e:
187         raise ConanException("Unable to create folder %s\n%s" % (destination_src_folder, str(e)))
188     return previous_digest
189 
190 
191 def _execute_export(conanfile_path, conanfile, destination_folder, destination_source_folder,
192                     output):
193 
194     origin_folder = os.path.dirname(conanfile_path)
195 
196     def classify_patterns(patterns):
197         patterns = patterns or []
198         included, excluded = [], []
199         for p in patterns:
200             if p.startswith("!"):
201                 excluded.append(p[1:])
202             else:
203                 included.append(p)
204         return included, excluded
205 
206     included_exports, excluded_exports = classify_patterns(conanfile.exports)
207     included_sources, excluded_sources = classify_patterns(conanfile.exports_sources)
208 
209     try:
210         os.unlink(os.path.join(origin_folder, CONANFILE + 'c'))
211     except OSError:
212         pass
213 
214     copier = FileCopier(origin_folder, destination_folder)
215     for pattern in included_exports:
216         copier(pattern, links=True, excludes=excluded_exports)
217     copier = FileCopier(origin_folder, destination_source_folder)
218     for pattern in included_sources:
219         copier(pattern, links=True, excludes=excluded_sources)
220     package_output = ScopedOutput("%s export" % output.scope, output)
221     copier.report(package_output)
222
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/conans/client/cmd/export.py b/conans/client/cmd/export.py
--- a/conans/client/cmd/export.py
+++ b/conans/client/cmd/export.py
@@ -112,7 +112,7 @@
     if scm.url == "auto":
         origin = scm.get_remote_url()
         if not origin:
-            raise ConanException("Repo origin cannot be deduced by 'auto', using source folder")
+            raise ConanException("Repo origin cannot be deduced by 'auto'")
         output.success("Repo origin deduced by 'auto': %s" % origin)
         scm.url = origin
     if scm.revision == "auto":

{"golden_diff": "diff --git a/conans/client/cmd/export.py b/conans/client/cmd/export.py\n--- a/conans/client/cmd/export.py\n+++ b/conans/client/cmd/export.py\n@@ -112,7 +112,7 @@\n     if scm.url == \"auto\":\n         origin = scm.get_remote_url()\n         if not origin:\n-            raise ConanException(\"Repo origin cannot be deduced by 'auto', using source folder\")\n+            raise ConanException(\"Repo origin cannot be deduced by 'auto'\")\n         output.success(\"Repo origin deduced by 'auto': %s\" % origin)\n         scm.url = origin\n     if scm.revision == \"auto\":\n", "issue": "Confusing message or behavior in SCM when url can't be deduced\nIt raises:\r\n\r\n```python\r\nif not origin:\r\n            raise ConanException(\"Repo origin cannot be deduced by 'auto', using source folder\")\r\n```\r\n\r\nBut it doesn't use the source folder, as execution is aborted. Maybe change the message? Or allow to proceed and create the package locally, even if the remote URL is not defined?\r\n\r\n\n", "before_files": [{"content": "\"\"\" manages the movement of conanfiles and associated files from the user space\nto the local store, as an initial step before building or uploading to remotes\n\"\"\"\n\nimport os\nimport shutil\n\nfrom conans.client.cmd.export_linter import conan_linter\nfrom conans.client.file_copier import FileCopier\nfrom conans.client.loader_parse import load_conanfile_class\nfrom conans.client.output import ScopedOutput\nfrom conans.client.source import get_scm\nfrom conans.errors import ConanException\nfrom conans.model.conan_file import create_exports, create_exports_sources\nfrom conans.model.manifest import FileTreeManifest\nfrom conans.model.ref import ConanFileReference\nfrom conans.paths import CONAN_MANIFEST, CONANFILE\nfrom conans.util.files import save, rmdir, is_dirty, set_dirty, mkdir\nfrom conans.util.log import logger\nfrom conans.search.search import search_recipes\n\n\ndef export_alias(reference, target_reference, client_cache):\n    conanfile = \"\"\"\nfrom conans import ConanFile\n\nclass AliasConanfile(ConanFile):\n    alias = \"%s\"\n\"\"\" % str(target_reference)\n\n    export_path = client_cache.export(reference)\n    mkdir(export_path)\n    save(os.path.join(export_path, CONANFILE), conanfile)\n    mkdir(client_cache.export_sources(reference))\n    digest = FileTreeManifest.create(export_path)\n    digest.save(export_path)\n\n\ndef cmd_export(conanfile_path, name, version, user, channel, keep_source,\n               output, client_cache):\n    \"\"\" Export the recipe\n    param conanfile_path: the original source directory of the user containing a\n                       conanfile.py\n    param user: user under this package will be exported\n    param channel: string (stable, testing,...)\n    \"\"\"\n    logger.debug(\"Exporting %s\" % conanfile_path)\n\n    conan_linter(conanfile_path, output)\n    conanfile = _load_export_conanfile(conanfile_path, output, name, version)\n    conan_ref = ConanFileReference(conanfile.name, conanfile.version, user, channel)\n    conan_ref_str = str(conan_ref)\n    # Maybe a platform check could be added, but depends on disk partition\n    refs = search_recipes(client_cache, conan_ref_str, ignorecase=True)\n    if refs and conan_ref not in refs:\n        raise ConanException(\"Cannot export package with same name but different case\\n\"\n                             \"You exported '%s' but already existing '%s'\"\n                             % (conan_ref_str, \" \".join(str(s) for s in refs)))\n    output = ScopedOutput(str(conan_ref), output)\n    with client_cache.conanfile_write_lock(conan_ref):\n        _export_conanfile(conanfile_path, output, client_cache, conanfile, conan_ref, keep_source)\n\n\ndef _load_export_conanfile(conanfile_path, output, name, version):\n    conanfile = load_conanfile_class(conanfile_path)\n\n    for field in [\"url\", \"license\", \"description\"]:\n        field_value = getattr(conanfile, field, None)\n        if not field_value:\n            output.warn(\"Conanfile doesn't have '%s'.\\n\"\n                        \"It is recommended to add it as attribute\" % field)\n\n    try:\n        # Exports is the only object field, we need to do this, because conan export needs it\n        conanfile.exports = create_exports(conanfile)\n        conanfile.exports_sources = create_exports_sources(conanfile)\n    except Exception as e:  # re-raise with file name\n        raise ConanException(\"%s: %s\" % (conanfile_path, str(e)))\n\n    # check name and version were specified\n    if not conanfile.name:\n        if name:\n            conanfile.name = name\n        else:\n            raise ConanException(\"conanfile didn't specify name\")\n    elif name and name != conanfile.name:\n        raise ConanException(\"Package recipe exported with name %s!=%s\" % (name, conanfile.name))\n\n    if not conanfile.version:\n        if version:\n            conanfile.version = version\n        else:\n            raise ConanException(\"conanfile didn't specify version\")\n    elif version and version != conanfile.version:\n        raise ConanException(\"Package recipe exported with version %s!=%s\"\n                             % (version, conanfile.version))\n\n    return conanfile\n\n\ndef _capture_export_scm_data(conanfile, src_path, destination_folder, output, paths, conan_ref):\n\n    scm_src_file = paths.scm_folder(conan_ref)\n    if os.path.exists(scm_src_file):\n        os.unlink(scm_src_file)\n\n    scm = get_scm(conanfile, src_path)\n\n    if not scm or not (scm.capture_origin or scm.capture_revision):\n        return\n\n    if scm.url == \"auto\":\n        origin = scm.get_remote_url()\n        if not origin:\n            raise ConanException(\"Repo origin cannot be deduced by 'auto', using source folder\")\n        output.success(\"Repo origin deduced by 'auto': %s\" % origin)\n        scm.url = origin\n    if scm.revision == \"auto\":\n        scm.revision = scm.get_revision()\n        output.success(\"Revision deduced by 'auto': %s\" % scm.revision)\n\n    # Generate the scm_folder.txt file pointing to the src_path\n    save(scm_src_file, src_path.replace(\"\\\\\", \"/\"))\n    scm.replace_in_file(os.path.join(destination_folder, \"conanfile.py\"))\n\n\ndef _export_conanfile(conanfile_path, output, paths, conanfile, conan_ref, keep_source):\n\n    exports_folder = paths.export(conan_ref)\n    exports_source_folder = paths.export_sources(conan_ref, conanfile.short_paths)\n    previous_digest = _init_export_folder(exports_folder, exports_source_folder)\n    _execute_export(conanfile_path, conanfile, exports_folder, exports_source_folder, output)\n    shutil.copy2(conanfile_path, os.path.join(exports_folder, CONANFILE))\n\n    _capture_export_scm_data(conanfile, os.path.dirname(conanfile_path), exports_folder,\n                             output, paths, conan_ref)\n\n    digest = FileTreeManifest.create(exports_folder, exports_source_folder)\n\n    if previous_digest and previous_digest == digest:\n        output.info(\"The stored package has not changed\")\n        modified_recipe = False\n        digest = previous_digest  # Use the old one, keep old timestamp\n    else:\n        output.success('A new %s version was exported' % CONANFILE)\n        output.info('Folder: %s' % exports_folder)\n        modified_recipe = True\n    digest.save(exports_folder)\n\n    source = paths.source(conan_ref, conanfile.short_paths)\n    remove = False\n    if is_dirty(source):\n        output.info(\"Source folder is corrupted, forcing removal\")\n        remove = True\n    elif modified_recipe and not keep_source and os.path.exists(source):\n        output.info(\"Package recipe modified in export, forcing source folder removal\")\n        output.info(\"Use the --keep-source, -k option to skip it\")\n        remove = True\n    if remove:\n        output.info(\"Removing 'source' folder, this can take a while for big packages\")\n        try:\n            # remove only the internal\n            rmdir(source)\n        except BaseException as e:\n            output.error(\"Unable to delete source folder. \"\n                         \"Will be marked as corrupted for deletion\")\n            output.warn(str(e))\n            set_dirty(source)\n\n\ndef _init_export_folder(destination_folder, destination_src_folder):\n    previous_digest = None\n    try:\n        if os.path.exists(destination_folder):\n            if os.path.exists(os.path.join(destination_folder, CONAN_MANIFEST)):\n                previous_digest = FileTreeManifest.load(destination_folder)\n            # Maybe here we want to invalidate cache\n            rmdir(destination_folder)\n        os.makedirs(destination_folder)\n    except Exception as e:\n        raise ConanException(\"Unable to create folder %s\\n%s\" % (destination_folder, str(e)))\n    try:\n        if os.path.exists(destination_src_folder):\n            rmdir(destination_src_folder)\n        os.makedirs(destination_src_folder)\n    except Exception as e:\n        raise ConanException(\"Unable to create folder %s\\n%s\" % (destination_src_folder, str(e)))\n    return previous_digest\n\n\ndef _execute_export(conanfile_path, conanfile, destination_folder, destination_source_folder,\n                    output):\n\n    origin_folder = os.path.dirname(conanfile_path)\n\n    def classify_patterns(patterns):\n        patterns = patterns or []\n        included, excluded = [], []\n        for p in patterns:\n            if p.startswith(\"!\"):\n                excluded.append(p[1:])\n            else:\n                included.append(p)\n        return included, excluded\n\n    included_exports, excluded_exports = classify_patterns(conanfile.exports)\n    included_sources, excluded_sources = classify_patterns(conanfile.exports_sources)\n\n    try:\n        os.unlink(os.path.join(origin_folder, CONANFILE + 'c'))\n    except OSError:\n        pass\n\n    copier = FileCopier(origin_folder, destination_folder)\n    for pattern in included_exports:\n        copier(pattern, links=True, excludes=excluded_exports)\n    copier = FileCopier(origin_folder, destination_source_folder)\n    for pattern in included_sources:\n        copier(pattern, links=True, excludes=excluded_sources)\n    package_output = ScopedOutput(\"%s export\" % output.scope, output)\n    copier.report(package_output)\n", "path": "conans/client/cmd/export.py"}], "after_files": [{"content": "\"\"\" manages the movement of conanfiles and associated files from the user space\nto the local store, as an initial step before building or uploading to remotes\n\"\"\"\n\nimport os\nimport shutil\n\nfrom conans.client.cmd.export_linter import conan_linter\nfrom conans.client.file_copier import FileCopier\nfrom conans.client.loader_parse import load_conanfile_class\nfrom conans.client.output import ScopedOutput\nfrom conans.client.source import get_scm\nfrom conans.errors import ConanException\nfrom conans.model.conan_file import create_exports, create_exports_sources\nfrom conans.model.manifest import FileTreeManifest\nfrom conans.model.ref import ConanFileReference\nfrom conans.paths import CONAN_MANIFEST, CONANFILE\nfrom conans.util.files import save, rmdir, is_dirty, set_dirty, mkdir\nfrom conans.util.log import logger\nfrom conans.search.search import search_recipes\n\n\ndef export_alias(reference, target_reference, client_cache):\n    conanfile = \"\"\"\nfrom conans import ConanFile\n\nclass AliasConanfile(ConanFile):\n    alias = \"%s\"\n\"\"\" % str(target_reference)\n\n    export_path = client_cache.export(reference)\n    mkdir(export_path)\n    save(os.path.join(export_path, CONANFILE), conanfile)\n    mkdir(client_cache.export_sources(reference))\n    digest = FileTreeManifest.create(export_path)\n    digest.save(export_path)\n\n\ndef cmd_export(conanfile_path, name, version, user, channel, keep_source,\n               output, client_cache):\n    \"\"\" Export the recipe\n    param conanfile_path: the original source directory of the user containing a\n                       conanfile.py\n    param user: user under this package will be exported\n    param channel: string (stable, testing,...)\n    \"\"\"\n    logger.debug(\"Exporting %s\" % conanfile_path)\n\n    conan_linter(conanfile_path, output)\n    conanfile = _load_export_conanfile(conanfile_path, output, name, version)\n    conan_ref = ConanFileReference(conanfile.name, conanfile.version, user, channel)\n    conan_ref_str = str(conan_ref)\n    # Maybe a platform check could be added, but depends on disk partition\n    refs = search_recipes(client_cache, conan_ref_str, ignorecase=True)\n    if refs and conan_ref not in refs:\n        raise ConanException(\"Cannot export package with same name but different case\\n\"\n                             \"You exported '%s' but already existing '%s'\"\n                             % (conan_ref_str, \" \".join(str(s) for s in refs)))\n    output = ScopedOutput(str(conan_ref), output)\n    with client_cache.conanfile_write_lock(conan_ref):\n        _export_conanfile(conanfile_path, output, client_cache, conanfile, conan_ref, keep_source)\n\n\ndef _load_export_conanfile(conanfile_path, output, name, version):\n    conanfile = load_conanfile_class(conanfile_path)\n\n    for field in [\"url\", \"license\", \"description\"]:\n        field_value = getattr(conanfile, field, None)\n        if not field_value:\n            output.warn(\"Conanfile doesn't have '%s'.\\n\"\n                        \"It is recommended to add it as attribute\" % field)\n\n    try:\n        # Exports is the only object field, we need to do this, because conan export needs it\n        conanfile.exports = create_exports(conanfile)\n        conanfile.exports_sources = create_exports_sources(conanfile)\n    except Exception as e:  # re-raise with file name\n        raise ConanException(\"%s: %s\" % (conanfile_path, str(e)))\n\n    # check name and version were specified\n    if not conanfile.name:\n        if name:\n            conanfile.name = name\n        else:\n            raise ConanException(\"conanfile didn't specify name\")\n    elif name and name != conanfile.name:\n        raise ConanException(\"Package recipe exported with name %s!=%s\" % (name, conanfile.name))\n\n    if not conanfile.version:\n        if version:\n            conanfile.version = version\n        else:\n            raise ConanException(\"conanfile didn't specify version\")\n    elif version and version != conanfile.version:\n        raise ConanException(\"Package recipe exported with version %s!=%s\"\n                             % (version, conanfile.version))\n\n    return conanfile\n\n\ndef _capture_export_scm_data(conanfile, src_path, destination_folder, output, paths, conan_ref):\n\n    scm_src_file = paths.scm_folder(conan_ref)\n    if os.path.exists(scm_src_file):\n        os.unlink(scm_src_file)\n\n    scm = get_scm(conanfile, src_path)\n\n    if not scm or not (scm.capture_origin or scm.capture_revision):\n        return\n\n    if scm.url == \"auto\":\n        origin = scm.get_remote_url()\n        if not origin:\n            raise ConanException(\"Repo origin cannot be deduced by 'auto'\")\n        output.success(\"Repo origin deduced by 'auto': %s\" % origin)\n        scm.url = origin\n    if scm.revision == \"auto\":\n        scm.revision = scm.get_revision()\n        output.success(\"Revision deduced by 'auto': %s\" % scm.revision)\n\n    # Generate the scm_folder.txt file pointing to the src_path\n    save(scm_src_file, src_path.replace(\"\\\\\", \"/\"))\n    scm.replace_in_file(os.path.join(destination_folder, \"conanfile.py\"))\n\n\ndef _export_conanfile(conanfile_path, output, paths, conanfile, conan_ref, keep_source):\n\n    exports_folder = paths.export(conan_ref)\n    exports_source_folder = paths.export_sources(conan_ref, conanfile.short_paths)\n    previous_digest = _init_export_folder(exports_folder, exports_source_folder)\n    _execute_export(conanfile_path, conanfile, exports_folder, exports_source_folder, output)\n    shutil.copy2(conanfile_path, os.path.join(exports_folder, CONANFILE))\n\n    _capture_export_scm_data(conanfile, os.path.dirname(conanfile_path), exports_folder,\n                             output, paths, conan_ref)\n\n    digest = FileTreeManifest.create(exports_folder, exports_source_folder)\n\n    if previous_digest and previous_digest == digest:\n        output.info(\"The stored package has not changed\")\n        modified_recipe = False\n        digest = previous_digest  # Use the old one, keep old timestamp\n    else:\n        output.success('A new %s version was exported' % CONANFILE)\n        output.info('Folder: %s' % exports_folder)\n        modified_recipe = True\n    digest.save(exports_folder)\n\n    source = paths.source(conan_ref, conanfile.short_paths)\n    remove = False\n    if is_dirty(source):\n        output.info(\"Source folder is corrupted, forcing removal\")\n        remove = True\n    elif modified_recipe and not keep_source and os.path.exists(source):\n        output.info(\"Package recipe modified in export, forcing source folder removal\")\n        output.info(\"Use the --keep-source, -k option to skip it\")\n        remove = True\n    if remove:\n        output.info(\"Removing 'source' folder, this can take a while for big packages\")\n        try:\n            # remove only the internal\n            rmdir(source)\n        except BaseException as e:\n            output.error(\"Unable to delete source folder. \"\n                         \"Will be marked as corrupted for deletion\")\n            output.warn(str(e))\n            set_dirty(source)\n\n\ndef _init_export_folder(destination_folder, destination_src_folder):\n    previous_digest = None\n    try:\n        if os.path.exists(destination_folder):\n            if os.path.exists(os.path.join(destination_folder, CONAN_MANIFEST)):\n                previous_digest = FileTreeManifest.load(destination_folder)\n            # Maybe here we want to invalidate cache\n            rmdir(destination_folder)\n        os.makedirs(destination_folder)\n    except Exception as e:\n        raise ConanException(\"Unable to create folder %s\\n%s\" % (destination_folder, str(e)))\n    try:\n        if os.path.exists(destination_src_folder):\n            rmdir(destination_src_folder)\n        os.makedirs(destination_src_folder)\n    except Exception as e:\n        raise ConanException(\"Unable to create folder %s\\n%s\" % (destination_src_folder, str(e)))\n    return previous_digest\n\n\ndef _execute_export(conanfile_path, conanfile, destination_folder, destination_source_folder,\n                    output):\n\n    origin_folder = os.path.dirname(conanfile_path)\n\n    def classify_patterns(patterns):\n        patterns = patterns or []\n        included, excluded = [], []\n        for p in patterns:\n            if p.startswith(\"!\"):\n                excluded.append(p[1:])\n            else:\n                included.append(p)\n        return included, excluded\n\n    included_exports, excluded_exports = classify_patterns(conanfile.exports)\n    included_sources, excluded_sources = classify_patterns(conanfile.exports_sources)\n\n    try:\n        os.unlink(os.path.join(origin_folder, CONANFILE + 'c'))\n    except OSError:\n        pass\n\n    copier = FileCopier(origin_folder, destination_folder)\n    for pattern in included_exports:\n        copier(pattern, links=True, excludes=excluded_exports)\n    copier = FileCopier(origin_folder, destination_source_folder)\n    for pattern in included_sources:\n        copier(pattern, links=True, excludes=excluded_sources)\n    package_output = ScopedOutput(\"%s export\" % output.scope, output)\n    copier.report(package_output)\n", "path": "conans/client/cmd/export.py"}]}