2012-07-31 31 views
0

我是SharpSVN的新手。我發現很多互聯網上與SharpSVN相關的例子。此外,我做了一些成功的情況下,像結帳SharpSVN無法提交(...不是工作副本)

但問題是,我不能調用commit和添加功能:

,我想要做的就是選擇從我的電腦文件的操作,然後添加到指定的SVN文件夾,如果該文件存在,則應將其複製爲新版本。

這裏是我的代碼:

private void button1_Click(object sender, EventArgs e) 
{ 
    // FileUpload1.SaveAs("C:\\Users\\user\\Desktop\\crazycodeee\\" + FileUpload1.FileName); 
    SvnClient client = new SvnClient(); 
    client.Authentication.Clear(); 
    client.Authentication.DefaultCredentials = new NetworkCredential("crazyufuk", "123456"); 
    SvnCheckOutArgs coArgs = new SvnCheckOutArgs(); 
    coArgs.Depth = SvnDepth.Infinity; 
    // client.CheckOut(new Uri("http://localhost:8080/svn/crazycode/branches/"), "C:\\Users\\TTVERCIN\\Desktop\\crazycodeee"); 
    Add("C:\\Users\\user\\Desktop\\test_folderl\\"); 
    Commit("C:\\Users\\user\\Desktop\\crazycodeee", "AS"); 
} 

public bool Add(string path) 
{ 
    using (SvnClient client = new SvnClient()) 
    { 
     SvnAddArgs args = new SvnAddArgs(); 
     args.Depth = SvnDepth.Empty; 
     args.AddParents = true; 
     return client.Add(path, args); 
    } 
} 

public bool Commit(string path, string message) //second 
{ 
    using (SvnClient client = new SvnClient()) 
    { 
     SvnCommitArgs args = new SvnCommitArgs(); 
     args.LogMessage = message; 
     args.ThrowOnError = true; 
     args.ThrowOnCancel = true; 

     try 
     { 
      return client.Commit(path, args); 
     } 
     catch (Exception e) 
     { 
      if (e.InnerException != null) 
       throw new Exception(e.InnerException.Message, e); 
      throw e; 
     } 
    } 
} 

回答

1

爲文件添加或提交到SVN倉庫,你必須在當地檢查了相關資料庫。

// client.CheckOut(new Uri("http://localhost:8080/svn/crazycode/branches/"), "C:\\Users\\TTVERCIN\\Desktop\\crazycodeee"); 

註釋掉的代碼檢查出來的代碼存儲庫來這根"C:\\Users\\TTVERCIN\\Desktop\\crazycodeee",但你添加文件需要的這個孩子。

在你行

Add("C:\\Users\\TTVERCIN\\Desktop\\CSI_headerFooterMenu_prepaid_kurumsal\\"); 

如果CSI_headerFootermenu_prepaid_kurumsal其中在crazycodeee文件夾(你註釋掉收銀臺),那麼我懷疑這是可行的。

+2

除非需要,否則推薦的Subversion API格式不會將最終的'\'添加到路徑中。但是,如果您添加它,SharpSvn會爲您刪除它。 (但是通過通知,列表等獲得的路徑不會有) – 2012-09-06 17:11:40

相關問題