SharpSvn Local File Rename Commit
-
29-04-2021 - |
문제
I'm using SharpSVN
to do an "Commit" after a file rename in my local copy
instead of doing Svn.Delete(Src) -> Svn.Add(Dst)
.
i want to use a different method To keep tracing revision info of my file
The rename function move the info in Server-Side
,
from the old target to the new target by using Svn.RemoteMove()
function.
How can I copy the "svn-infos" in the Local-Side
?
I've tried to do cl.Move(src,dst)
on my local file,
but I am getting message that the source file not found.
Here is my code :
private string SvnRepository = "http://svnserver/svn/repo/trunk/";
public void Start() {
System.IO.File.Move("c:\\LocalSvn\\1.txt", "c:\\LocalSvn\\2.txt");
SvnRename("c:\\LocalSvn\\1.txt", "c:\\LocalSvn\\2.txt");
}
private Uri RelativePath(string sFullPath) {
return new Uri(SvnRepository + sFullPath.Replace(Path, "").Replace('\\', '/').Substring(1));
}
public void SvnRename(string sPath, string sOldPath) {
using (SvnClient cl = new SvnClient()) {
Uri UriFrom = RelativePath(sOldPath);
Uri UriTo = RelativePath(sPath);
cl.RemoteMove(UriFrom,UriTo
, new SvnMoveArgs { LogMessage = "Rename From:" + sOldPath + " To:"
+ sPath });
//Local
}
}
해결책 3
i've just found out that cl.Delete() cl.Add() keeping the history of the file so i dont need the cl.RemoteMove() to help me to keep tracking on the file !
다른 팁
Beware from using:
cl.Delete(file)
cl.Add(file)
It may not work just out of the box. If for example a file was renamed from:
file = "asdf"
to:
file = "Asdf"
you have to keep the local file:
cl.Delete(file, new new SvnDeleteArgs() { KeepLocal = true })
otherwise the subsequent add will fail because the local file is no longer available and it can no longer be added.
SvnClient.Move()
should just work for that use-case. Are you sure the exact on-disk casing is used for your invocation of Move()
.
Subversion is case sensitive. SvnTools.GetNormalizedFullPath()
and SvnTools.GetTruePath()
might help when you are not sure.