[英]How do I set a property to a file on the svn directory using the sharpsvn clinet class?
我正在使用Sharpsvn客戶端類在svn目錄中的文件上設置屬性。 我想用新的時間戳不斷重置屬性,並且這樣做會在存儲庫歷史記錄中更新帶有新日志消息的新修訂。 我不想做的是對文件進行更改,然后將其提交回目錄。 現在,我堅持嘗試找出如何連接到目錄上的文件。 這是我目前擁有的代碼:
System.Uri uri = new System.Uri("url link");
using (SvnClient client = new SvnClient())
{
try
{
// Get new timestamp
DateTime dt = DateTime.Now;
string time = String.Format("{0:G}", dt);
// Set property to file in the svn directory
client.RemoteSetProperty(uri, "svn:time", time);
}
catch (Svnexception ex)
{
MessageBox.show(ex.Message + "Check out error!");
}
}
我也嘗試使用client.SetProperty方法,但是當我在本地工作副本和直接到url上都嘗試它時,該方法不起作用。 幫助會很棒!
更改了代碼的某些部分以使其按要求工作。 請看一下:
System.Uri uri = new System.Uri("url link");
using (SvnClient client = new SvnClient())
{
try
{
// Get new timestamp
DateTime date = DateTime.Now;
string time = String.Format("{0:G}", date);
// To Get the Latest Revision on the Required SVN Folder
SvnInfoEventArgs info;
client.GetInfo(uri, out info);
// Prepare a PropertyArgs object with latest revision and a commit message;
SvnSetPropertyArgs args = new SvnSetPropertyArgs() { BaseRevision = info.Revision, LogMessage = "Sample msg for SVN commit" };
// Set property to file in the svn directory
client.RemoteSetProperty(uri, "svn:time", time, args);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + "Check out error!");
}
}
希望這可以幫助;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.