-
Notifications
You must be signed in to change notification settings - Fork 989
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[SCM] [SVN] auto feature behavior depends on how user has checked out local working copy #3831
Comments
Hi @ahauan4! You are right, and it is the expected behavior. SCM feature for SVN uses the root of the working copy to compute Some projects has its Nevertheless, you can explicitly write your scm = {
"type": "svn",
"url": "https://svn_repo/module1/trunk",
"revision": "auto",
} but here you will face a different problem: the I'm so sorry for this caveats, but IMHO opinion working with the root of the working copy is the best and most consistent compromise solution (without adding complexity and options to this feature). Please, let me know what you think, we would really appreciate feedback, suggestions and any comment to improve this feature. Thanks! |
Hello @jgsogo, in my opinion the default behaviour should be to use the current directory where the conanfile is located. The approach with detecting the base is a Git approach but with Subversion anybody can checkout the local working copy differently. So detecting the base is errorprone and inpredictible. Your suggestion to set the url explicitely does not work. But regardless of that, setting the url and/or revision to an explicit value is errorprone and makes the complete feature somewhat useless. I hope you can help us use the SVN SCM feature as expected, because it depends a lot if we can use Conan in our company at all. Thank You! |
Ok, let us finish version 1.9 during this week and we will come back afterward with this. Changing this behavior will affect everyone using SCM with SVN right now, we need to ask for their feedback too. |
I see that you may not want to change that behavior because it has already been released, although it's still stated as "Experimental". A possible way to support both methods:
would be to e. g. support an additional option like
... or a different option like
Problem here is that someone could mix the behaviour of url and revision retrieval. Maybe revision should be set automatically to the same method like url if revision is not set (if revision=None) There is also the It would be nice if you could have a look at this ideas and provide us some feedback. Thank You! |
Sorry for the delay. We've been traveling past weeks and preparing some events (like MeetingC++), and now we have to work on all the issues we left behind. The I still think that the best solution will be to have a fixed
And then there will be one problem left: in SVN the revision is computed taking into account the checkout root, so here we need a new paramater (I don't like having parameters specific for one SCM), or you could provide a function to retrive the revison using the desired root folder: (This is just a proposal, not tested, and it may require some changes) def get_svn_revision():
here = os.path.dirname(__file__)
svn = SVN(here)
revision = svn._show_item('revision', target=here)
return revision
class MyPackage(ConanFile):
scm = {"type": "svn",
"url": "path/to/package/",
"revision": get_svn_revision(),
} |
Hi @ahauan4, did you test what I suggested to you on my last comment? I think it is the best option: fixed URL and also an |
Hello @jgsogo, your suggestion seems promising, but I didn't have the time to test it yet. |
Hi! You can write a custom function, sure, but I cannot see the advantage between writing the URL or a function that will always retrieve the same URL... unless you want to reuse that function in other recipes through |
Hello, yes I was thinking about python_requires |
Hello @jgsogo, I tested your code and retrieving the |
If it is a working copy when working on the |
Here's my code: def get_scm():
here = os.path.dirname(__file__)
svn = conans.client.tools.scm.SVN(here)
return {
"type": "svn",
"url": svn._show_item('url', target=here),
"revision": svn._show_item('revision', target=here),
}
class ConanRecipe(conans.ConanFile):
scm = get_scm() |
Very interesting issue/bug indeed. I think I have reproduced the root cause in #4088, let me explain it a little bit more: We are evaluating the |
I got burned by this too! I had url set to the specific subdirectory relevant to the package, but revision = "auto" and it checked out a whole huge multi-GB repo. Also my build() instructions didn't work because assumed I was in the specific subdirectory. I tried the suggestion in #3831 (comment):
But get error:
|
This has been fixed by #4088. It will be released in conan 1.11, but if you want to give it a try using test.pypi.org repository to install development (non-stable) Conan versions: $ pip install --index-url https://test.pypi.org/simple/ conan It is in |
The workaround seems to work now with version Still the following error message is shown each time before building and after To get rid of it, we wrote the following function, which we import from an external package via def is_folder_a_svn_working_copy(folder="."):
return not(subprocess.check_output('svn info "%s"' % folder))
def get_scm(type="svn", url="auto", revision="auto", subfolder="."):
scm = {
"type": type,
"url": url,
"revision": revision,
"subfolder": subfolder
}
if type == "svn" and (url == "auto" or revision == "auto":) and is_folder_a_svn_working_copy():
svn = conans.client.tools.scm.SVN()
if url == "auto":
scm["url"] = svn._show_item('url')
if revision == "auto":
scm["revision"] = svn._show_item('revision')
return scm This is an acceptable workaround now and we are able to work with it. But it's not what we would expect from the |
Just a final comment on this issue. I'm investigating the Any idea on this will be welcome. Thanks. |
Maybe you could redirect the |
Here is a working function to suppress the output of svn info:
|
Thanks! 😀 I will create a PR with this snippet, but the credit is all yours |
Conan 1.8.2
Python 3.6.5
Windows 7
SVN 1.9.5
Our SVN repository structure is like this:
We have the following scm statement in our conanfile.py
The current behavior when calling
conan create
depends on whether someone has checked out all modules from SVN or only one module.Scenario A:
User A has checked out only module1 from SVN repository
https://svn_repo/module1/trunk
to a local folderC:\svn\module1\trunk
.Location of .svn hidden folder:
C:\svn\module1\trunk\.svn
Location of conan file:
C:\svn\module1\trunk\conanfile.py
Conan command:
conan create C:\svn\module1\trunk user/channel
In this case the conan SVN scm auto feature behaves like expected.
The conan cache source folder afterwards contains exactly the same content as the local SVN working copy folder for which conan create was called.
Scenario B:
User B has checked out all modules from SVN repository
https://svn_repo
to a local folderC:\svn
.Location of .svn hidden folder:
C:\svn\.svn
Location of conan file:
C:\svn\module1\trunk\conanfile.py
Conan command:
conan create C:\svn\module1\trunk user/channel
In this case the conan SVN scm auto feature behaves not like expected.
The conan cache source folder afterwards contains all modules (module1, module2, ...) instead of only module1 trunk, for which conan create was called.
So it contains the working copy of the SVN base folder 'https://svn_repo' instead of 'https://svn_repo/module1/trunk'
Expected behavior:
The source folder in the local conan cache should contain all subfolders of the local SVN folder where the conanfile.py is located for which conan create was called, not all root folders including other modules checked out locally by the user.
The behavior should not depend on the location of the hidden .svn directory which depends on how a user has checked out his/her local working copy.
Currently we cannot use the SVN scm auto feature, because a lot of users check out their SVN working copy like in scenario B.
Could you please give us a statement on this topic.
Thank You!
The text was updated successfully, but these errors were encountered: