Repository: conan-io/conan

Issue:
upload --no-overwrite option doesn't work if the package doesn't exists remotely
While the new `--no-overwrite` option to upload is great in theory it doesn't work as expected when the package is not available in the remote:

```
conan search -r test zlib/1.2.8-5@plex/stable
ERROR: Recipe not found: plex/zlib/1.2.8-5/stable. [Remote: test]

conan upload --no all zlib/1.2.8-5@plex/stable -r test
Uploading zlib/1.2.8-5@plex/stable
ERROR: Local recipe is different from the remote recipe. Forbbiden overwrite. [Remote: test]

conan upload zlib/1.2.8-5@plex/stable -r test
Uploading zlib/1.2.8-5@plex/stable
Uploading conanmanifest.txt                                           
[==================================================] 58B/58B          
Uploading conanfile.py                                                
[==================================================] 3.2KB/3.2KB      
Uploaded conan recipe 'zlib/1.2.8-5@plex/stable' to 'test': https://artifactory.plex.bz/artifactory/api/conan/conan-test

conan upload zlib/1.2.8-5@plex/stable -r test -no all
Uploading zlib/1.2.8-5@plex/stable
Recipe is up to date, upload skipped
```

I'll argue that `upload --no-overwrite all` should work with a package that is not available in the remote.

Our remote is a artifactory server running 5.10.3 and I am running conan 1.2.3 locally.



Discussion:

Resolving patch:
diff --git a/conans/client/rest/rest_client.py b/conans/client/rest/rest_client.py
--- a/conans/client/rest/rest_client.py
+++ b/conans/client/rest/rest_client.py
@@ -169,7 +169,7 @@ def upload_recipe(self, conan_reference, the_files, retry, retry_wait, ignore_de
         if not new and not deleted and modified in (["conanmanifest.txt"], []):
             return False
 
-        if no_overwrite:
+        if no_overwrite and remote_snapshot:
             if no_overwrite in ("all", "recipe"):
                 raise ConanException("Local recipe is different from the remote recipe. "
                                      "Forbbiden overwrite")
@@ -205,7 +205,7 @@ def upload_package(self, package_reference, the_files, retry, retry_wait, no_ove
         if not new and not deleted and modified in (["conanmanifest.txt"], []):
             return False
 
-        if no_overwrite:
+        if no_overwrite and remote_snapshot:
             if no_overwrite in ("all"):
                 raise ConanException("Local package is different from the remote package. "
                                      "Forbbiden overwrite")


Test patch:
diff --git a/conans/test/command/upload_test.py b/conans/test/command/upload_test.py
--- a/conans/test/command/upload_test.py
+++ b/conans/test/command/upload_test.py
@@ -225,7 +225,11 @@ def package(self):
                      "hello.h": "",
                      "hello.cpp": ""})
         client.run("create . frodo/stable")
-        client.run("upload Hello0/1.2.1@frodo/stable --all")
+
+        # First time upload
+        client.run("upload Hello0/1.2.1@frodo/stable --all --no-overwrite")
+        self.assertNotIn("Forbbiden overwrite", client.out)
+        self.assertIn("Uploading Hello0/1.2.1@frodo/stable", client.out)
 
         # CASE: Upload again
         client.run("upload Hello0/1.2.1@frodo/stable --all --no-overwrite")
@@ -287,7 +291,11 @@ def package(self):
                      "hello.h": "",
                      "hello.cpp": ""})
         client.run("create . frodo/stable")
-        client.run("upload Hello0/1.2.1@frodo/stable --all")
+
+        # First time upload
+        client.run("upload Hello0/1.2.1@frodo/stable --all --no-overwrite recipe")
+        self.assertNotIn("Forbbiden overwrite", client.out)
+        self.assertIn("Uploading Hello0/1.2.1@frodo/stable", client.out)
 
         # Upload again
         client.run("upload Hello0/1.2.1@frodo/stable --all --no-overwrite recipe")