How to make git-svn use specific version of SVN?

此生再无相见时 提交于 2019-12-11 08:47:14

问题


On my Linux machine I use both SVN and Git.

To make my life easier I added source /opt/svn/linux64/ix86/svn_1.8.5/interface/startup/svn_1.8.5_64.env to my .bashrc and thus writing svn –version shows 1.8.5 as expected.

But when having this git-svn fails upon checkout. This happens in Git 1.7.10.1 and is an already known incompatibility (see for example here).

I can easily work around it by sourceing SVN version 1.7.9. But that requires me to restart SSH connection. And then after performing git-svn operation restarting again. (In both cases .bashrc has to be edited!)

I could also just switch to SVN 1.7.9 but that would require me to downgrade all SVN tools I use including TortoiseSVN which I have on my Windows machine (and which I use from time to time on checkouts made on shared network drives).

So is there a “non-intrusive” way (so I can do it only for myself – the Linux is on a shared server!) to make git-svn use the 1.7.9 version while command line will still use 1.8.5?


/opt/svn/linux64/ix86/svn_1.8.5/interface/startup/svn_1.8.5_64.env contains following:

add_to_env()
{
old_value=`eval echo '$'${1}`
eval ${1}=`echo ${old_value}|awk '{ n=split($1,parts,":"); printf "%s", toadd ;
for (i = 1; i <= n; ++i) if ( toadd != parts[i]  ) printf ":%s", parts[i]; }' toadd=${2}`
}

if [ -n "$SVN_STARTUP" ]; then
  SVN_TMP=$SVN_STARTUP
  unset SVN_STARTUP
  . $SVN_TMP
else
  # setum and setmake can overrule SVN_VERSION
  if [ -z "$SVN_VERSION" ]; then
    export SVN_VERSION=svn_1.8.5
  fi
  export SVN_HOME=/opt/svn/linux64/ix86/$SVN_VERSION
  add_to_env PATH $SVN_HOME/bin
  export PATH
  add_to_env MANPATH $SVN_HOME/share/man
  export MANPATH
  add_to_env LD_LIBRARY_PATH $SVN_HOME/lib
  export LD_LIBRARY_PATH
fi

As to Perl:

  • perl --version shows 5.8.8,
  • which perl shows /usr/bin/perl which is not a link, /usr/bin contains also perl5.8.8 which seems (by diff) to be the same,
  • find / -name Ra.pm finds (so far…) /usr/lib64/perl5/vendor_perl/5.8.8/x86_64-linux-thread-multi/SVN/Ra.pm.

回答1:


First of all that environment script isn't really changing your bindings to Subversion fully. In fact it's actually mixing bindings with some other version of the libraries. In general this is likely to work because Subversion makes a lot of effort to keep our APIs compatible and you should end up with the same version of the various Subversion libraries (which is important).

In order to correctly use the Subversion Perl bindings that go with the libraries you'll need to add the path to where the Perl bindings are at. Perl handles this with the PERL5LIB environment. Which works similarly to your PATH or LD_LIBRARY_PATH environment variables. Other languages would need similar things (but git-svn only uses Perl so that's not important in this case).

Beyond that you should just be able to source the script in your shell to change the libraries because it adds the libraries to the start of the values (which will be searched in the order given). So you should just be able to run source envfile or . envfile.

If you wanted you could simply wrap git with something like this and put it on your path (you could alias it as well but scripts wouldn't see it).

#!/bin/bash

. /opt/svn/linux64/ix86/svn_1.7.9/interface/startup/svn_1.7.9_64.env
export PERL5LIB="$SOMEPATHTOPERLLIBS:$PERL5LIB"

git "$@"

Where $SOMEPATHTOPERLLIS is replaced with whatever the actual path to the Perl5 files are in your install. I can't tell you what this it varies from system to system. If you search for a file named Ra.pm you can usually find the general area. You should only need to point that at where you found that file a few levels up.



来源:https://stackoverflow.com/questions/21922770/how-to-make-git-svn-use-specific-version-of-svn

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!