protected override void ExecuteSVNTask(SvnClient client) { if (Dir == null) { Dir = new DirectoryInfo(Project.BaseDirectory); } if (!Dir.Exists) { throw new BuildException(string.Format(Resources.MissingDirectory, Dir.FullName), Location); } string sourcesFolder = string.Concat(Dir.FullName, @"\Sources"); if (Directory.Exists(sourcesFolder)) { Log(Level.Info, Resources.SVNAdding, Dir.FullName); SvnAddArgs addArgs = new SvnAddArgs(); addArgs.Depth = SvnDepth.Infinity; addArgs.Force = true; client.Add(sourcesFolder, addArgs); } else { Log(Level.Info, Resources.SVNSourcesFolderNotFound, sourcesFolder); } Log(Level.Info, Resources.SVNCommitCommitting, Dir.FullName, Message); SvnCommitArgs args = new SvnCommitArgs(); args.LogMessage = Message; args.ThrowOnError = true; SvnCommitResult result; client.Commit(Dir.FullName, args, out result); if (result != null) { Log(Level.Info, Resources.SVNCommitResult, Dir.FullName, result.Revision, result.Author); } }
public void Move_MultiMove() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.Empty); string WcPath = sbox.Wc; using (SvnClient client = NewSvnClient(true, false)) { string ren1 = Path.Combine(WcPath, "ren-1"); using (StreamWriter sw = File.CreateText(ren1)) { sw.WriteLine("ToRename"); } client.Add(ren1); client.Commit(WcPath); client.Update(WcPath); using (StreamWriter sw = File.AppendText(ren1)) { sw.WriteLine("AddedLine"); } client.Move(ren1, ren1 + ".ren1"); client.Commit(WcPath); client.Move(ren1 + ".ren1", ren1 + ".ren2"); SvnMoveArgs ma = new SvnMoveArgs(); ma.Force = true; client.Move(ren1 + ".ren2", ren1 + ".ren3", ma); client.Commit(WcPath); } }
public int AddFolder(string localPath) { Trace.TraceInformation("SVNTCAdapter AddFolder {0}", localPath); Directory.CreateDirectory(localPath); m_client.Add(localPath); m_client.Commit(localPath, new SvnCommitArgs() { LogMessage = AddComment }); return(0); }
public override void CommitChanges(string Comments) { //Commit Changes SvnCommitArgs ca = new SvnCommitArgs(); ca.LogMessage = Comments; try { client.Commit(App.UserProfile.Solution.Folder); } catch (Exception e) { Reporter.ToUser(eUserMsgKeys.GeneralErrorOccured, e.Message + Environment.NewLine + e.InnerException); } }
public static bool Commit(String path, out SvnCommitResult result) { result = null; try { return(m_Client.Commit(path, out result)); } catch (SvnException ex) { MessageBox.Show("提交失败 : " + ex.Message, "系统提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Exclamation); } return(false); }
public void Commit(string localPath) { using (SvnClient client = new SvnClient()) { client.Commit(localPath); } }
public void CreateDirectory_CreateTrunk() { SvnSandBox sbox = new SvnSandBox(this); Uri ReposUrl = sbox.CreateRepository(SandBoxRepository.Empty); using (SvnClient client = NewSvnClient(true, false)) { Uri trunkUri = new Uri(ReposUrl, "trunk/"); client.RemoteCreateDirectory(trunkUri); string trunkPath = sbox.Wc; client.CheckOut(trunkUri, trunkPath); TouchFile(Path.Combine(trunkPath, "test.txt")); Assert.That(SvnTools.IsManagedPath(trunkPath)); Assert.That(SvnTools.IsBelowManagedPath(trunkPath)); Assert.That(SvnTools.IsBelowManagedPath(Path.Combine(trunkPath, "q/r/s/t/u/v/test.txt"))); client.Add(Path.Combine(trunkPath, "test.txt")); Directory.CreateDirectory(Path.Combine(trunkPath, "dir")); TouchFile(Path.Combine(trunkPath, "dir/test.txt")); SvnAddArgs aa = new SvnAddArgs(); aa.AddParents = true; client.Add(Path.Combine(trunkPath, "dir/test.txt"), aa); client.Commit(trunkPath); client.RemoteDelete(trunkUri, new SvnDeleteArgs()); } }
public bool CommitWorkingCopy() { SvnCommitArgs commitArgs = new SvnCommitArgs(); commitArgs.Notify += new EventHandler <SvnNotifyEventArgs>(CommitNotifyHandler); commitArgs.Depth = SvnDepth.Infinity; commitArgs.LogMessage = "user commit: " + _Username; //commitArgs.ThrowOnError = false; //commitArgs.SvnError += new EventHandler<SvnErrorEventArgs>(commitArgs_SvnError); try { SvnCommitResult result; bool returnCode = _SvnClient.Commit(WorkingCopyPath, commitArgs, out result); if (returnCode) { _RepositoryRevision = (int)result.Revision; return(true); } else { return(false); } } catch (Exception ex) { return(false); } }
private void CreatePaths() { List <string> paths; paths = new List <string>(); using (SvnClient client = SvnUtilities.CreateClient(this.SvnConnectionSettings)) { this.OnProgressChanged(new ProgressEventArgs("Creating new directories...")); foreach (string str_rel_path in this.VssRelativeProjPaths) { if (!string.IsNullOrEmpty(str_rel_path)) { string path = Path.Combine(this.SvnFullRepositoryPath, str_rel_path); if (!Directory.Exists(path)) { paths.Add(path); } } } client.CreateDirectories(paths, new SvnCreateDirectoryArgs() { CreateParents = true }); string commitMessage = string.Format("VSS Porting from project: {0}. Initial directory creation.", this.VssDatabase.SrcSafeIni); client.Commit(this.SvnFullRepositoryPath, new SvnCommitArgs() { LogMessage = commitMessage }); } }
public bool commit(UsuarioSVN usuSVN, string Mensaje) { bool EsCorrecto = true; SvnUpdateResult result; SvnCommitArgs ca = new SvnCommitArgs(); using (SvnClient client = new SvnClient()) { try { client.Authentication.ForceCredentials(usuSVN.Nombre, usuSVN.Contraseña); //SvnUriTarget is a wrapper class for SVN repository URIs SvnUriTarget target = new SvnUriTarget(usuSVN.URL); client.Authentication.SslServerTrustHandlers += new EventHandler <SharpSvn.Security.SvnSslServerTrustEventArgs>(Authentication_SslServerTrustHandlers); // Checkout the code to the specified directory client.CheckOut(target, usuSVN.RutaLocal); // Update the specified working copy path to the head revision //client.Update("c:\\sharpsvn"); client.Update(usuSVN.RutaLocal, out result); ca.LogMessage = "Mensaje"; client.Commit(usuSVN.RutaLocal, ca); } catch { EsCorrecto = false; } return(EsCorrecto); } }
private void Commit(string message, string login, string password, Revision revision) { using (SvnClient client = new SvnClient()) { SvnCommitArgs aa = new SvnCommitArgs(); aa.Depth = SvnDepth.Infinity; aa.Progress += this.OnProgress; aa.SvnError += this.OnSvnError; aa.Notify += this.OnNotify; aa.LogMessage = message; aa.Committed += (o, args) => { revision.Id = args.Revision.ToString(); }; client.Authentication.ForceCredentials(login, password); client.Commit(this.repoPath, aa); // hack for (int i = 0; i <= 100; i++) { if (revision.Id == null) { Thread.Sleep(1000); } } } }
public void Commit_WithAlternateUser() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.Empty); string user = Guid.NewGuid().ToString(); string dir = sbox.Wc; using (SvnClient client = new SvnClient()) { client.Authentication.Clear(); client.Configuration.LogMessageRequired = false; client.Authentication.UserNameHandlers += delegate(object sender, SvnUserNameEventArgs e) { e.UserName = user; }; client.SetProperty(dir, "a", "b"); SvnCommitResult cr; client.Commit(dir, out cr); Collection <SvnLogEventArgs> la; client.GetLog(dir, out la); Assert.That(la.Count, Is.EqualTo(2)); Assert.That(la[0].Revision, Is.EqualTo(cr.Revision)); Assert.That(la[0].Author, Is.EqualTo(user)); Assert.That(la[0].LogMessage, Is.EqualTo("")); } }
public void WriteProps() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.Empty); string WcPath = sbox.Wc; string data = Guid.NewGuid().ToString(); using (SvnClient client = NewSvnClient(true, false)) { string file = Path.Combine(WcPath, "WriteTest"); using (StreamWriter sw = File.CreateText(file)) { sw.WriteLine(data); } client.Add(file); client.SetProperty(file, "A", "B"); client.Commit(file); using (MemoryStream ms = new MemoryStream()) { SvnPropertyCollection pc; client.Write(new SvnPathTarget(file, SvnRevision.Head), ms, out pc); Assert.That(pc, Is.Not.Empty); Assert.That(pc["A"].StringValue, Is.EqualTo("B")); } } }
/// <summary> /// 提交SVN /// </summary> /// <param name="path"></param> /// <param name="UserName"></param> /// <param name="Password"></param> public void CommitSvn(string path, string UserName, string Password) { //Authentication 身份验证 _client.Authentication.Clear(); _client.Authentication.UserNamePasswordHandlers += delegate(object obj, SharpSvn.Security.SvnUserNamePasswordEventArgs args) { args.UserName = UserName; args.Password = Password; }; //_client.Authentication.SslServerTrustHandlers += //delegate(object sender, SvnSslServerTrustEventArgs e) //{ // e.AcceptedFailures = e.Failures; // e.Save = true; //证书 Save acceptance to authentication store //}; var ca = new SvnCommitArgs { LogMessage = "提交信息" }; //"svn log message created at " + DateTime.Now.ToString(); bool action = _client.Commit(path, ca); if (action) { Console.WriteLine(" OK! 提交SVN成功> " + path); } else { Console.WriteLine(" ERR!!! 提交SVN失败> " + path); } }
public override bool CommitChanges(string Comments, ref string error) { //Commit Changes SvnCommitArgs ca = new SvnCommitArgs(); ca.LogMessage = Comments; try { client.Commit(SolutionFolder); } catch (Exception e) { error = e.Message + Environment.NewLine + e.InnerException; return(false); } return(true); }
//提交SVN public static void CommitSvn(string path) { SvnClient client = new SvnClient(); SvnCommitArgs comArgs = new SvnCommitArgs(); comArgs.LogMessage = "这里输入你的提交信息"; client.Commit(path); }
public override void Commit(FilePath[] paths, string message, IProgressMonitor monitor) { SvnCommitArgs args = new SvnCommitArgs(); BindMonitor(args, monitor); args.LogMessage = message; client.Commit(paths.ToStringArray(), args); }
/// <summary> /// svn commit /// 提交工作区中的改变到版本库 /// </summary> /// <param name="path">需要提交的目录或者文件</param> /// <param name="message">提交说明</param> private void Commit(string path, string message) { using (SvnClient client = new SvnClient()) { SvnCommitArgs args = new SvnCommitArgs(); args.LogMessage = message; client.Commit(path, args); } }
public void CheckInChanges(string solutionDirectoryPath, Project oldProject, Project newProject) { using(SvnClient svnClient = new SvnClient()) { SvnCommitArgs svnCommitArgs = new SvnCommitArgs { LogMessage = string.Format("Renamed project {0} into {1}", oldProject.ProjectName, newProject.ProjectName) }; // TODO NKO: Do something with the result SvnCommitResult result; svnClient.Commit(solutionDirectoryPath, svnCommitArgs, out result); } }
/// <summary> /// Actual method to be executed for the implementing task /// </summary> /// <param name="client">The instance of the SVN client</param> /// <returns></returns> public override bool ExecuteCommand(SvnClient client) { SvnCommitArgs args = new SvnCommitArgs(); args.LogMessage = Message; args.KeepLocks = KeepLocks; args.KeepChangeLists = KeepChangeLists; SvnCommitResult result; bool success = client.Commit(RepositoryPath, args, out result); return success; }
public void CheckInChanges(string solutionDirectoryPath, Project oldProject, Project newProject) { using (SvnClient svnClient = new SvnClient()) { SvnCommitArgs svnCommitArgs = new SvnCommitArgs { LogMessage = string.Format("Renamed project {0} into {1}", oldProject.ProjectName, newProject.ProjectName) }; // TODO NKO: Do something with the result SvnCommitResult result; svnClient.Commit(solutionDirectoryPath, svnCommitArgs, out result); } }
public void WriteTest() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.Empty); string WcPath = sbox.Wc; string data = Guid.NewGuid().ToString(); using (SvnClient client = NewSvnClient(true, false)) { string file = Path.Combine(WcPath, "WriteTest"); using (StreamWriter sw = File.CreateText(file)) { sw.WriteLine(data); } client.Add(file); client.AddToChangeList(file, "WriteTest-Items"); SvnCommitArgs ca = new SvnCommitArgs(); ca.ChangeLists.Add("WriteTest-Items"); client.Commit(WcPath); using (MemoryStream ms = new MemoryStream()) { client.Write(new SvnPathTarget(file), ms); ms.Position = 0; using (StreamReader sr = new StreamReader(ms)) { Assert.That(sr.ReadLine(), Is.EqualTo(data)); Assert.That(sr.ReadToEnd(), Is.EqualTo("")); } } using (MemoryStream ms = new MemoryStream()) { client.Write(new Uri(sbox.RepositoryUri, "WriteTest"), ms); ms.Position = 0; using (StreamReader sr = new StreamReader(ms)) { Assert.That(sr.ReadLine(), Is.EqualTo(data)); Assert.That(sr.ReadToEnd(), Is.EqualTo("")); } } } }
public void Move_BasicMove() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.Empty); string WcPath = sbox.Wc; Uri ReposUrl = sbox.RepositoryUri; string TestPath = sbox.GetTempDir(); using (SvnClient client = NewSvnClient(true, false)) { string file = Path.Combine(WcPath, "LocalMoveBase"); TouchFile(file); client.Add(file); Directory.CreateDirectory(Path.Combine(TestPath, "MoveTestImport")); TouchFile(Path.Combine(TestPath, "MoveTestImport/RemoteMoveBase")); client.RemoteImport(Path.Combine(TestPath, "MoveTestImport"), new Uri(ReposUrl, "RemoteMoveBase")); client.Commit(WcPath); Assert.That(ItemExists(new Uri(ReposUrl, "RemoteMoveBase")), Is.True, "Remote base does exist"); Assert.That(ItemExists(new Uri(ReposUrl, "LocalMoveBase")), Is.True, "Local base does exist"); client.RemoteMove(new Uri(ReposUrl, "RemoteMoveBase"), new Uri(ReposUrl, "RemoteMoveTarget")); client.Move(file, Path.Combine(WcPath, "LocalMoveTarget")); client.Commit(WcPath); Assert.That(ItemExists(new Uri(ReposUrl, "RemoteMoveTarget")), Is.True, "Remote target exists"); Assert.That(ItemExists(new Uri(ReposUrl, "LocalMoveTarget")), Is.True, "Local target exists"); Assert.That(ItemExists(new Uri(ReposUrl, "RemoteMoveBase")), Is.False, "Remote base does not exist"); Assert.That(ItemExists(new Uri(ReposUrl, "LocalMoveBase")), Is.False, "Local base does not exist"); } }
/// <summary> /// Commits the Staged/Added files /// </summary> /// <param name="filePath"></param> /// <param name="message"></param> /// <returns></returns> public bool Commit(string filePath, string message) { var returnValue = false; var args = new SvnCommitArgs(); args.LogMessage = message; args.ThrowOnError = true; args.ThrowOnCancel = true; args.Depth = SvnDepth.Empty; // var status = GetSingleItemStatus(filePath); if (status.IsVersioned && status.IsModified) { returnValue = _svnClient.Commit(filePath, args); if (returnValue) { UpdateCache(filePath); } } //var sa = new SvnStatusArgs(); //sa.Depth = SvnDepth.Infinity; //sa.RetrieveAllEntries = true; //the new line //Collection<SvnStatusEventArgs> statuses; //_svnClient.GetStatus(_repo, sa, out statuses); //foreach (var item in statuses) //{ // if (item.LocalContentStatus == SvnStatus.Added || item.LocalContentStatus == SvnStatus.Modified) // { // } //} return(returnValue); }
public void TestCommit() { using (SvnClient client = new SvnClient()) { var localpath = "d:\\sharpsvn\\需求文档\\1.txt"; localpath = "d:\\sharpsvn\\1.txt"; //localpath = @"E:\project\ccms\CCMS_V7_HBYD_R"; var username = "******"; var pwd = "123456"; client.Authentication.DefaultCredentials = new System.Net.NetworkCredential(username, pwd); //如果项目不存在则checkout,否则进行update Console.WriteLine("开始检查是否需要提交新参数表..."); SvnCommitArgs ca = new SvnCommitArgs(); SvnStatusArgs sa = new SvnStatusArgs(); Collection <SvnStatusEventArgs> statuses; client.GetStatus(localpath, sa, out statuses); int i = 0; foreach (var item in statuses) { if (item.LocalContentStatus != item.RemoteContentStatus) { i++; } if (!item.Versioned) { client.Add(item.FullPath); Console.WriteLine("新增加文件" + item.FullPath); i++; } } if (i > 0) { ca.LogMessage = "测试提交文档"; SvnCommitResult clientr; if (client.Commit(localpath, ca, out clientr)) { Console.WriteLine("提交完成"); } else { Console.WriteLine("提交失败"); } } else { Console.WriteLine("无变化,无需检查"); } } }
/// <summary> /// 执行SVN的Commit操作 /// </summary> public static bool Commit(string localFilePath, string logMessage, out SvnException svnException) { try { SvnCommitArgs commitArgs = new SvnCommitArgs(); commitArgs.LogMessage = logMessage; bool result = _svnClient.Commit(localFilePath, commitArgs); svnException = null; return(result); } catch (SvnException exception) { svnException = exception; return(false); } }
static public void Commit(string fromLocalPath) { using (SvnClient svnClient = new SvnClient()) { try { //svnClient.Authentication.ForceCredentials(_svnUserName, _svnPwd); SvnCommitArgs args = new SvnCommitArgs(); args.LogMessage = Properties.Settings.Default.SVN_Commit_Msg; svnClient.Commit(fromLocalPath, args); } catch (Exception ex) { LogMessage(ex.Message); } } }
public override string Commit(string filePath, string changedContent, string commitComment) { string changedFilePath = Path.Combine(LocalRepositoryCheckedOutPath, filePath); using (var changedFile = File.OpenWrite(changedFilePath)) { var changes = new UTF8Encoding(true).GetBytes(changedContent); changedFile.Write(changes, 0, changes.Length); } var commit = new SvnCommitArgs { LogMessage = commitComment }; SvnCommitResult result; _client.Commit(LocalRepositoryCheckedOutPath, commit, out result); return(result.Revision.ToString()); }
private SvnCommitResult CommitChangesetFiles(SvnClient svnClient, Changeset changeset, List <string> filePaths) { SvnCommitResult commitResult; SvnCommitArgs commitArgs; int failCount; bool complete; commitArgs = new SvnCommitArgs { LogMessage = changeset.Comment }; failCount = 0; complete = false; commitResult = null; while (!complete) { if (failCount > 0) { this.LogMessage("Retrying commit again, attempt {0} of {1}...", failCount + 1, this.RetryCount); } try { svnClient.Commit(filePaths, commitArgs, out commitResult); complete = true; } catch (Exception ex) { this.LogException(ex); failCount++; if (failCount > this.RetryCount) { complete = true; // abort } else { Thread.Sleep(1000); } } } return(commitResult); }
/// <summary> /// Actualiza un archivo en el SVN. /// </summary> /// <param name="ruta"></param> /// <returns></returns> public static string ActualizarArchivo(string nombre, string usuario) { var msj = ""; try { string rutaCopiaTrabajo = ObtenerRutaCopiaTrabajo(); // Argumentos del agregado. var aa = new SvnAddArgs(); aa.Depth = SvnDepth.Infinity; aa.Force = true; // Argyumentos del commit. var args = new SvnCommitArgs(); args.LogMessage = "Editar: " + nombre + ".\nUsuario: " + usuario + ".\nFecha: " + DateTime.Now; args.Depth = SvnDepth.Infinity; using (var client = new SvnClient()) { // Agregar archivo a la copia de trabajo SVN. client.Add(rutaCopiaTrabajo, aa); // Hacer commit repositorio SVN. client.Commit(rutaCopiaTrabajo, args); } msj = "Exito"; } catch (Exception ex) { Debug.WriteLine(ex.ToString()); msj += "Error al subir el archivo: " + ex.Message; if (ex.InnerException != null) { msj += " " + ex.InnerException.Message; } } return(msj); }
public void CheckIn() { SvnCommitArgs a = new SvnCommitArgs(); a.LogMessage = "Status Update"; using (SvnClient client = new SvnClient()) { client.Commit(_excelFilePath, a); try { client.Unlock(_excelFilePath); } #pragma warning disable CS0168 // The variable 'ex' is declared but never used catch (SharpSvn.SvnClientMissingLockTokenException ex) #pragma warning restore CS0168 // The variable 'ex' is declared but never used { } } }
private void btnCommit_Click(object sender, EventArgs e) { if (txtSystemCode.Text == "") { return; } var localAppsCSFileVersion = FileVersionInfo.GetVersionInfo(string.Format("d:/APPS_CS/{0}/{1}", txtSystemCode.Text, txtApp.Text)); SvnCommitArgs args = new SvnCommitArgs(); args.LogMessage = string.Format("System {0} version {1} Commit", txtSystemCode, localAppsCSFileVersion.FileVersion); SvnCommitResult result; using (var client = new SvnClient()) { try { SvnUI.Bind(client, this); var addArgs = new SvnAddArgs() { Force = true }; client.Add(string.Format("d:/APPS_CS/{0}", txtSystemCode.Text.ToLower()), addArgs); client.Commit(string.Format("d:/APPS_CS/{0}", txtSystemCode.Text.ToLower()), args, out result); if (result != null) { MessageBox.Show("Successfully commited revision " + result.Revision); } else { MessageBox.Show("No changes have been made to working copy since it was checked out."); } } catch (SvnException se) { MessageBox.Show(se.Message + "Error: " + se.SvnErrorCode + Environment.NewLine, "svn commit error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private static long CommitNGetRevisionNumber(string source, string comment, SvnClient client) { SvnCommitArgs ca = new SvnCommitArgs(); ca.LogMessage = comment; SvnCommitResult commitResults; long revision; bool success = client.Commit(source, ca, out commitResults); if (ReferenceEquals(commitResults, null)) { SvnInfoEventArgs svnInfo = GetLatestRevisionInfo(client, client.GetRepositoryRoot(source).AbsoluteUri); revision = svnInfo.LastChangeRevision; } else { revision = commitResults.Revision; } return(revision); }
public int Commit(ICollection <string> targets, bool recurse, bool keepLocks, string logMessage) { try { SvnCommitArgs args = new SvnCommitArgs(); args.Depth = SvnDepth.Infinity; args.KeepLocks = true; args.LogMessage = logMessage; SvnCommitResult result; client.Commit(targets, args, out result); OnCommitted((int)result.Revision, result.Author, result.Time); return((int)result.Revision); } catch (Exception ex) { OnError(ex); } return(int.MinValue); }
/// <summary> /// Commit nisan.xml to svn repo based on working copy path and authentication. /// </summary> /// <remarks> /// See https://sharpsvn.open.collab.net/ using ver 1.6. /// </remarks> public bool Commit() { // save to file first SaveToFile("nisan.xml"); System.Diagnostics.Debug.WriteLine("svn commit nisan.xml -m \"Updating nisan order by NisanWPF.\""); //string url = "https://jawiweb.googlecode.com/svn/trunk/Samples"; SvnCommitArgs args = new SvnCommitArgs(); args.LogMessage = "Updating nisan order by NisanWPF."; using (SvnClient client = new SvnClient()) return client.Commit("nisan.xml", args);//url, args); }
public static void Checkout(string repoDir, string wcDir) { if (Directory.Exists(wcDir)) { Directory.Delete(wcDir, true); } using (var svn = new SvnClient()) { var repoUri = new Uri("file:///" + repoDir.Replace('\\', '/')); svn.CheckOut(new SvnUriTarget(repoUri), wcDir); foreach (var fse in Directory.EnumerateFileSystemEntries(wcDir)) { if (Path.GetFileName(fse).ToLowerInvariant() == ".svn") continue; svn.Add(fse, SvnDepth.Infinity); } svn.Commit(wcDir, new SvnCommitArgs { LogMessage = "PreCreate revision" }); } }
public bool Commit(string authorName, string authorEmail, string comment, DateTime localTime) { /* TempFile commentFile; var args = "commit"; AddComment(comment, ref args, out commentFile); using (commentFile) { var startInfo = GetStartInfo(args); startInfo.EnvironmentVariables["GIT_AUTHOR_NAME"] = authorName; startInfo.EnvironmentVariables["GIT_AUTHOR_EMAIL"] = authorEmail; startInfo.EnvironmentVariables["GIT_AUTHOR_DATE"] = GetUtcTimeString(localTime); // also setting the committer is supposedly useful for converting to Mercurial startInfo.EnvironmentVariables["GIT_COMMITTER_NAME"] = authorName; startInfo.EnvironmentVariables["GIT_COMMITTER_EMAIL"] = authorEmail; startInfo.EnvironmentVariables["GIT_COMMITTER_DATE"] = GetUtcTimeString(localTime); // ignore empty commits, since they are non-trivial to detect // (e.g. when renaming a directory) return ExecuteUnless(startInfo, "nothing to commit"); } */ if (string.IsNullOrEmpty(authorName)) { return false; } using (var client = new SvnClient()) { SvnUI.Bind(client, parentWindow); var svnCommitArgs = new SvnCommitArgs { LogMessage = comment }; var svnCommitResult = (SvnCommitResult)null; var result = client.Commit(useSvnStandardDirStructure ? trunkPath : workingCopyPath, svnCommitArgs, out svnCommitResult); // commit without files results in result=true and svnCommitResult=null if (svnCommitResult != null) { if (result) { var workingCopyUri = client.GetUriFromWorkingCopy(useSvnStandardDirStructure ? trunkPath : workingCopyPath); result &= client.SetRevisionProperty(svnCommitResult.RepositoryRoot, new SvnRevision(svnCommitResult.Revision), SvnPropertyNames.SvnAuthor, authorName); result &= client.SetRevisionProperty(svnCommitResult.RepositoryRoot, new SvnRevision(svnCommitResult.Revision), SvnPropertyNames.SvnDate, SvnPropertyNames.FormatDate(localTime)); result &= client.Update(workingCopyPath, new SvnUpdateArgs { AddsAsModifications = false, AllowObstructions = false, Depth = SvnDepth.Infinity, IgnoreExternals = true, KeepDepth = true, Revision = SvnRevision.Head, UpdateParents = false }); } else { MessageBox.Show(string.Format("{0} Error Code: {1}{2}", svnCommitResult.PostCommitError, "", Environment.NewLine), "SVN Commit Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } } return result; } return false; }
private async void Commit(string path) { var svnClient = new SvnClient(); AppendLog("Committing to SVN..."); await Task.Run(() => { svnClient.Commit(path); }); AppendLog("Complete!"); }
public void Commit_WithAlternateUser() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.Empty); string user = Guid.NewGuid().ToString(); string dir = sbox.Wc; using (SvnClient client = new SvnClient()) { client.Authentication.Clear(); client.Configuration.LogMessageRequired = false; client.Authentication.UserNameHandlers += delegate(object sender, SvnUserNameEventArgs e) { e.UserName = user; }; client.SetProperty(dir, "a", "b"); SvnCommitResult cr; client.Commit(dir, out cr); Collection<SvnLogEventArgs> la; client.GetLog(dir, out la); Assert.That(la.Count, Is.EqualTo(2)); Assert.That(la[0].Revision, Is.EqualTo(cr.Revision)); Assert.That(la[0].Author, Is.EqualTo(user)); Assert.That(la[0].LogMessage, Is.EqualTo("")); } }
public void CommitRevision(string author, string comment, DateTime time) { using (var svn = new SvnClient()) { // commit var commitArgs = new SvnCommitArgs { LogMessage = "author: " + author + "\n" + comment }; SvnCommitResult cr; svn.Commit(_wc, commitArgs, out cr); if (cr == null) { Console.WriteLine(" Nothing to commit. Seems this revision was already added or contains only unimportant chnages ?"); return; } try { var revision = new SvnRevision(cr.Revision); svn.SetRevisionProperty(_svnUri, revision, "svn:author", author); svn.SetRevisionProperty(_svnUri, revision, "svn:log", comment); svn.SetRevisionProperty(_svnUri, revision, "svn:date", time.ToString("o")); } catch (Exception ex) { _log.WriteLine("Change props error: {0}", ex); } } }
public static bool SvnCommit(string path) { SvnClient client = new SvnClient(); return client.Commit(path); }