public bool Login() { Initialize(m_strUser, m_strPassword); if (m_initialized) { using (m_client = new SvnClient()) { m_client.Authentication.Clear(); m_client.Authentication.DefaultCredentials = new System.Net.NetworkCredential(m_strUser, m_strPassword); m_client.Authentication.SslServerTrustHandlers += delegate(object sender, SharpSvn.Security.SvnSslServerTrustEventArgs e) { e.AcceptedFailures = e.Failures; e.Save = true; // save acceptance to authentication store }; System.Collections.ObjectModel.Collection<SvnLogEventArgs> logEntries; SvnLogArgs logArgs = new SvnLogArgs(); logArgs.Limit = 1; try { m_client.GetLog(m_uriRepository.Uri, logArgs, out logEntries); m_loggedIn = true; } catch (SvnException ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "SVN Connect Error", System.Windows.Forms.MessageBoxButtons.OK); m_loggedIn = false; return false; } } return true; } return false; }
private static void CheckoutUpdate(Parameters parameters) { using (var client = new SharpSvn.SvnClient()) { SetUpClient(parameters, client); var target = SvnTarget.FromString(parameters.Path); SvnInfoEventArgs svnInfoEventArgs; SvnUpdateResult svnUpdateResult; var nonExistentUrl = false; EventHandler<SvnErrorEventArgs> ignoreNonexistent = (o, eventArgs) => { nonExistentUrl = false; //if (eventArgs.Exception.SubversionErrorCode == 170000) if(eventArgs.Exception.Message.Contains("non-existent in revision")) { nonExistentUrl = true; eventArgs.Cancel = true; } }; if(client.GetWorkingCopyRoot(parameters.Path) == null) { client.SvnError += ignoreNonexistent; var getInfoSucceeded = client.GetInfo(SvnUriTarget.FromString(parameters.Url), out svnInfoEventArgs); client.SvnError -= ignoreNonexistent; if(!getInfoSucceeded) { if (nonExistentUrl) { Console.WriteLine("SVN info reported nonexistent URL; creating remote directory."); if (!client.RemoteCreateDirectory(new Uri(parameters.Url), new SvnCreateDirectoryArgs {CreateParents = true, LogMessage = parameters.Message})) { throw new Exception("Create directory failed on " + parameters.Url); } } else { throw new Exception("SVN info failed"); } } DebugMessage(parameters, "Checking out"); if (client.CheckOut(SvnUriTarget.FromString(parameters.Url), parameters.Path, out svnUpdateResult)) { DebugMessage(parameters, "Done"); Console.WriteLine("Checked out r" + svnUpdateResult.Revision); return; } throw new Exception("SVN checkout failed"); } if(!client.GetInfo(target, out svnInfoEventArgs)) { throw new Exception("SVN info failed"); } if(!UrlsMatch(svnInfoEventArgs.Uri.ToString(), parameters.Url)) { throw new Exception(string.Format("A different URL is already checked out ({0} != {1})", svnInfoEventArgs.Uri, parameters.Url)); } if(parameters.Cleanup) { DebugMessage(parameters, "Cleaning up"); client.CleanUp(parameters.Path); DebugMessage(parameters, "Done"); } if(parameters.Revert) { DebugMessage(parameters, "Reverting"); client.Revert(parameters.Path); DebugMessage(parameters, "Done"); } if (parameters.DeleteUnversioned) { DebugMessage(parameters, "Deleting unversioned files"); Collection<SvnStatusEventArgs> changedFiles; client.GetStatus(parameters.Path, out changedFiles); foreach (var changedFile in changedFiles) { if(changedFile.LocalContentStatus == SvnStatus.NotVersioned) { if(changedFile.NodeKind == SvnNodeKind.Directory) { DebugMessage(parameters, "NodeKind is directory for [" + changedFile.FullPath + "]"); } if ((File.GetAttributes(changedFile.FullPath) & FileAttributes.Directory) == FileAttributes.Directory) { DebugMessage(parameters, "Deleting directory [" + changedFile.FullPath + "] recursively!"); Directory.Delete(changedFile.FullPath, true); } else { DebugMessage(parameters, "Deleting file [" + changedFile.FullPath + "]"); File.Delete(changedFile.FullPath); } } } DebugMessage(parameters, "Done"); } DebugMessage(parameters, "Updating"); if(client.Update(parameters.Path, out svnUpdateResult)) { DebugMessage(parameters, "Done"); Console.WriteLine("Updated to r" + svnUpdateResult.Revision); return; } throw new Exception("SVN update failed"); } }
private long GetLatestCheckinVersion(string serverUrl, string branch) { try { using (SharpSvn.SvnClient client = new SharpSvn.SvnClient()) { client.Authentication.Clear(); // Clear a previous authentication client.Authentication.DefaultCredentials = new System.Net.NetworkCredential(svnuser, svnpasssword); client.Authentication.SslServerTrustHandlers += Authentication_SslServerTrustHandlers; SvnInfoEventArgs info; string endpoint = serverUrl.TrimEnd('/') + @"/" + branch; client.GetInfo(endpoint, out info); long lastRevision = info.LastChangeRevision; return(lastRevision); } } catch (Exception ex) { Console.WriteLine("EXCEPTION - " + ex.Message); Console.WriteLine(ex.StackTrace); return(-1); } }
public static string GetInfo(string[] args, string revision) { Parameters parameters; if (!Parameters.TryParse(args, out parameters)) { return("False"); } using (var client = new SharpSvn.SvnClient()) { SetUpClient(parameters, client); var target = SvnTarget.FromString(parameters.Path); SvnInfoEventArgs svnInfoEventArgs; SvnUpdateResult svnUpdateResult; if (!client.GetInfo(target, out svnInfoEventArgs)) { throw new Exception("SVN info failed"); } Uri svnUrl = svnInfoEventArgs.Uri; return(svnInfoEventArgs.Revision.ToString()); throw new Exception("SVN update failed"); } return("jhgjg"); }
private void btnPropSet_Click(object sender, EventArgs e) { using (SharpSvn.SvnClient client = new SharpSvn.SvnClient()) { try { if (rbFileValue.Checked) { client.SetProperty(tbFilePath.Text, tbPropName.Text, File.ReadAllBytes(tbFileValue.Text)); MessageBox.Show("eklenen özellik" + tbPropName.Text + "'," + tbFilePath.Text); } } catch (SvnException se) { MessageBox.Show(se.Message, "yeni özellik eklenirken hata oluştu", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (FileNotFoundException fnfe) { MessageBox.Show(fnfe.Message, "Geçersiz dosya adı", MessageBoxButtons.OK, MessageBoxIcon.Error); } catch (Exception ex) { MessageBox.Show(ex.Message, "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public bool CheckoutRepository(CheckoutRepositoryRequest request) { var projectFolder = GetRepositoryFolder(request.ProjectName); if (!Directory.Exists(projectFolder)) { Directory.CreateDirectory(projectFolder); } request.SvnServerUrl = request.SvnServerUrl.RemoveTrailing('/'); using (var client = new SharpSvn.SvnClient()) { try { client.Authentication.ForceCredentials(request.SvnUsername, request.SvnPassword); var result = client.CheckOut( new SvnUriTarget($"{request.SvnServerUrl}/{SettingsService.Current.DefaultSvnPath}"), projectFolder); } catch (Exception ex) { NotificationHelper.Show(SvnErrorHandling.FormatError(ex.Message)); return false; } } NotificationHelper.Show($"{request.ProjectName} checked out"); return true; }
internal void Commit(string text, SvnCommitArgs args, SvnCommitResult result) { using (SharpSvn.SvnClient client = new SharpSvn.SvnClient()) { SvnCommitArgs ca = new SvnCommitArgs(); client.Commit(args.LogMessage, ca); } }
protected void SetupContext() { svnClient = new SharpSvn.SvnClient(); svnClient.Authentication.DefaultCredentials = new NetworkCredential("guest", ""); svnClient.Authentication.SslServerTrustHandlers += AcceptCerticate; repositoryUrl = "https://agileprojectdashboard.org:8443/svn/IntegrationTest/trunk"; localDirectory = Path.Combine(Environment.CurrentDirectory, "IntegrationTest"); }
// TODO: make trusting not the default private static void TrustUnsignedCertificates(SharpSvn.SvnClient client) { client.Authentication.SslServerTrustHandlers += (sender, e) => { Console.WriteLine("Certificate errors: " + e.Failures); e.AcceptedFailures = e.Failures; e.Save = true; // Save it for future use? }; //client.Authentication.SslServerTrustHandlers += Authentication_SslServerTrustHandlers; }
public static string GetLogText(string[] args, string revision, out Collection <SvnLogEventArgs> logItemsColl) { Parameters parameters; if (!Parameters.TryParse(args, out parameters)) { throw new Exception("TryParse failed"); } using (var client = new SharpSvn.SvnClient()) { SetUpClient(parameters, client); var target = SvnTarget.FromString(parameters.Path); SvnInfoEventArgs svnInfoEventArgs; SvnUpdateResult svnUpdateResult; if (!client.GetInfo(target, out svnInfoEventArgs)) { throw new Exception("SVN info failed"); } Uri svnUrl = svnInfoEventArgs.Uri; long revisionLong = long.Parse(revision); long revisionLongTo = svnInfoEventArgs.Revision; SvnLogArgs Logargs = new SvnLogArgs { Range = new SvnRevisionRange(revisionLong, revisionLongTo) }; Collection <SvnLogEventArgs> logItems; // client.GetLog(svnUrl, Logargs, out logItems); client.GetLog(svnUrl, out logItemsColl); string AlllogText = ""; for (int i = logItemsColl.Count - 1; i > 0; i--) { AlllogText = AlllogText + (Char)13 + (Char)10 + logItemsColl[i].Revision.ToString() + " " + logItemsColl[i].Time.ToString() + " " + logItemsColl[i].LogMessage; } return(AlllogText); throw new Exception("SVN update failed"); } return("jhgjg"); }
public SVNServices() { m_client = null; m_strUser = ""; m_strPassword = ""; m_strServer = "http://192.168.4.148"; m_strRepository = "/svn/ReleaseData/trunk"; m_strCheckoutPath = System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal); m_nPort = 18080; m_initialized = false; m_loggedIn = false; }
private static void SetUpClient(Parameters parameters, SharpSvn.SvnClient client) { if (!string.IsNullOrEmpty(parameters.Username) && !string.IsNullOrEmpty(parameters.Password)) { client.Authentication.Clear(); // prevents checking cached credentials client.Authentication.DefaultCredentials = new NetworkCredential(parameters.Username, parameters.Password); } if (parameters.TrustServerCert) { TrustUnsignedCertificates(client); } }
private void btnGetProp_Click(object sender, EventArgs e) { if (tbFileURI.Text.Length == 0) { MessageBox.Show("geçerli bir URI girin"); return; } lvProps.Items.Clear(); //liste görüntüsünü temizliyor SvnTarget tgt = SvnTarget.FromString(tbFileURI.Text); // Bu, özellikleri aldığımız hedef dosya olacak System.Collections.ObjectModel.Collection <SvnPropertyListEventArgs> proplist; SvnPropertyListArgs args = new SvnPropertyListArgs();//argmanlar koyabilecegimiz yer if (cbRecurse.Checked == true) { args.Depth = SvnDepth.Infinity; } using (SharpSvn.SvnClient client = new SharpSvn.SvnClient()) { try { client.GetPropertyList(tgt, args, out proplist); foreach (SvnPropertyListEventArgs node in proplist) { foreach (SvnPropertyValue propVal in node.Properties) { ListViewItem entry = new ListViewItem(node.Path); entry.SubItems.Add(propVal.Key); entry.SubItems.Add(propVal.StringValue); lvProps.Items.Add(entry); } } for (int i = 0; i < 3; i++) { lvProps.Columns[i].Width = -2; } } catch (SvnException se) { MessageBox.Show(se.Message + Environment.NewLine + "Error:" + se.SvnErrorCode, "svn proplist error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
internal bool CheckOut(SvnUriTarget target, string path, SvnCheckOutArgs args, out SvnUpdateResult result) { bool checkoutResult; using (SharpSvn.SvnClient client = new SharpSvn.SvnClient()) { client.Authentication.ForceCredentials("selin", "123456"); checkoutResult = client.CheckOut(new Uri("https://DESKTOP-CK68HBF/svn/test"), path, out result); } return(checkoutResult); }
public static string UpdateToRevision(string[] args, string revision) { Parameters parameters; if (!Parameters.TryParse(args, out parameters)) { return("False"); } using (var client = new SharpSvn.SvnClient()) { SetUpClient(parameters, client); var target = SvnTarget.FromString(parameters.Path); SvnInfoEventArgs svnInfoEventArgs; SvnUpdateResult svnUpdateResult; if (!client.GetInfo(target, out svnInfoEventArgs)) { throw new Exception("SVN info failed"); } Uri svnUrl = svnInfoEventArgs.Uri; long revisionLong = long.Parse(revision); //update to revision //DebugMessage(parameters, "Updating"); SvnUpdateArgs SvnArgs = new SvnUpdateArgs(); //// If args.Revision is not set, it defaults to fetch the HEAD revision. SvnArgs.Revision = revisionLong; if (client.Update(parameters.Path, SvnArgs, out svnUpdateResult)) { DebugMessage(parameters, "Done"); Console.WriteLine("Updated to r" + svnUpdateResult.Revision); return("true"); } throw new Exception("SVN update failed"); } return("jhgjg"); }
private void btnCommit_Click(object sender, EventArgs e) { if (tbFileName.Text.Length == 0) { MessageBox.Show("dosya seç"); return; } SvnCommitArgs args = new SvnCommitArgs(); args.LogMessage = tbMessage.Text; SvnCommitResult result; using (SharpSvn.SvnClient client = new SharpSvn.SvnClient()) { try { SvnUI.Bind(client, this); client.Commit(tbFileName.Text, args, out result); if (result != null) { MessageBox.Show("başarıyla revize edildi" + result.Revision + "."); } else { MessageBox.Show("teslim edildiğinden beri hiçbir değişiklilik yapılmamıştır"); } } catch (SvnException se) { MessageBox.Show(se.Message + "Error: " + se.SvnErrorCode + Environment.NewLine, "svn commit error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private SharpSvn.SvnClient createClient(NetworkCredential credentials = null) { var client = new SharpSvn.SvnClient(); client.Authentication.SslServerTrustHandlers += (b, e) => { e.AcceptedFailures = e.Failures; e.Save = true; // Save acceptance to authentication store }; if (credentials != null) { client.Authentication.ForceCredentials(credentials.UserName, credentials.Password); } return client; }
public bool Update() { if (m_loggedIn) { if (m_client == null || m_client.IsDisposed) m_client = new SvnClient(); if (m_strCheckoutPath == "") return false; try { SvnCheckOutArgs args = new SvnCheckOutArgs(); args.Depth = SvnDepth.Files; args.IgnoreExternals = true; m_client.CheckOut(m_uriRepository, m_strCheckoutPath, args); } catch (SvnException ex) { String Msg = ex.Message + Environment.NewLine + Environment.NewLine + "Host: " + m_uriRepository.Uri.Host + Environment.NewLine + "Port: " + m_uriRepository.Uri.Port + Environment.NewLine + "Path: " + m_uriRepository.Uri.AbsolutePath; System.Windows.Forms.MessageBox.Show(Msg, "SVN Login Error", System.Windows.Forms.MessageBoxButtons.OK); m_loggedIn = false; return false; } try { m_client.Update(m_strCheckoutPath); } catch (SvnException ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "SVN Update Error", System.Windows.Forms.MessageBoxButtons.OK); m_loggedIn = false; return false; } return true; } return false; }
private void btnCheckout_Click(object sender, EventArgs e) { if (tbLocalPath.Text.Length == 0 || tbRepoURI.Text.Length == 0) { MessageBox.Show("The 'Repository URI' and 'Local Path' fields cannot be empty."); return; } //SvnUpdateResult provides info about what happened during a checkout SvnUpdateResult result; //we will use this to tell CheckOut() which revision to fetch long revision; //SvnCheckoutArgs wraps all of the options for the 'svn checkout' function SvnCheckOutArgs args = new SvnCheckOutArgs(); //path is the path where the local working copy will end up string path = tbLocalPath.Text; if (long.TryParse(tbRevision.Text, out revision)) { //set the revision number if the user entered a valid number args.Revision = new SvnRevision(revision); } //if args.Revision is not set, it defaults to fetch the HEAD revision. else { MessageBox.Show("Invalid Revision number, defaulting to HEAD"); } //the using statement is necessary to ensure we are freeing up resources using (SharpSvn.SvnClient client = new SharpSvn.SvnClient()) { try { //SvnUriTarget is a wrapper class for SVN repository URIs SvnUriTarget target = new SvnUriTarget(tbRepoURI.Text); if (cbAuthenticate.Checked == true) { logMsg("Authenticating"); client.Authentication.Clear(); // Clear a previous authentication client.Authentication.SslServerTrustHandlers += new EventHandler <SharpSvn.Security.SvnSslServerTrustEventArgs>(SVN_SSL_Override); client.Authentication.UserNamePasswordHandlers += delegate(object obj, SharpSvn.Security.SvnUserNamePasswordEventArgs val) { val.UserName = textUserid.Text; val.Password = textPassword.Text; val.Save = true; }; } logMsg("Checking out from:"); logMsg(tbRepoURI.Text); //this is the where 'svn checkout' actually happens. if (client.CheckOut(target, path, args, out result)) { MessageBox.Show("Successfully checked out revision " + result.Revision + "."); logMsg("Successfully checked out revision " + result.Revision + "."); } } catch (SvnException se) { MessageBox.Show(textUserid.Text + " " + textPassword.Text + " " + se.Message, "svn checkout error", MessageBoxButtons.OK, MessageBoxIcon.Error); logMsg("svn error code: " + se.SubversionErrorCode); logMsg("SvnErrorCategory: " + se.SvnErrorCategory); logMsg(se.StackTrace); } catch (UriFormatException ufe) { MessageBox.Show(ufe.Message, "svn checkout error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
public bool Disconnect() { if (!m_loggedIn) return true; using (m_client = new SvnClient()) { try { m_client.CleanUp(m_strCheckoutPath); } catch (Exception ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "SVN Disconnect Error", System.Windows.Forms.MessageBoxButtons.OK); m_loggedIn = false; return false; } m_client.Authentication.Clear(); } return true; }
public bool Commit() { if (!m_loggedIn) return false; using (m_client = new SvnClient()) { m_client.Authentication.Clear(); m_client.Authentication.DefaultCredentials = new System.Net.NetworkCredential(m_strUser, m_strPassword); m_client.Authentication.SslServerTrustHandlers += delegate(object sender, SharpSvn.Security.SvnSslServerTrustEventArgs e) { e.AcceptedFailures = e.Failures; e.Save = true; // save acceptance to authentication store }; System.Collections.ObjectModel.Collection<SvnLogEventArgs> logEntries; SvnLogArgs logArgs = new SvnLogArgs(); logArgs.Limit = 1; try { m_client.GetLog(m_uriRepository.Uri, logArgs, out logEntries); m_loggedIn = true; } catch (SvnException ex) { System.Windows.Forms.MessageBox.Show(ex.Message, "SVN Connect Error", System.Windows.Forms.MessageBoxButtons.OK); m_loggedIn = false; return false; } try { SvnCommitArgs args = new SvnCommitArgs(); args.LogMessage = "Update release data " + DateTime.Now.ToString(); args.Depth = SvnDepth.Infinity; return m_client.Commit(m_client.GetWorkingCopyRoot(m_strCheckoutPath), args); } catch (SvnException ex) { String msg = ex.Message + Environment.NewLine + Environment.NewLine + ex.StackTrace.ToString(); System.Windows.Forms.MessageBox.Show(ex.Message, "SVN Commit Error", System.Windows.Forms.MessageBoxButtons.OK); return false; } } }
public static void Diff_ReposDiff(string[] args, long Rev1, long Rev2) { //string clientDiff = this.RunCommand("svn", "diff -r 1:5 " + this.ReposUrl); MemoryStream outstream = new MemoryStream(); MemoryStream errstream = new MemoryStream(); SvnDiffArgs a = new SvnDiffArgs(); Parameters parameters; if (!Parameters.TryParse(args, out parameters)) { return; } using (var client = new SharpSvn.SvnClient()) { SetUpClient(parameters, client); var target = SvnTarget.FromString(parameters.Path); SvnInfoEventArgs svnInfoEventArgs; SvnUpdateResult svnUpdateResult; if (!client.GetInfo(target, out svnInfoEventArgs)) { throw new Exception("SVN info failed"); } Uri svnUrl = svnInfoEventArgs.Uri; a.ErrorStream = errstream; try { client.Diff(target, new SvnRevisionRange(Rev1, Rev2), a, outstream); } catch (Exception) { throw new Exception("SVN diff failed"); // return ; } return; } //string err = Encoding.Default.GetString(errstream.ToArray()); //Assert.That(err, Is.EqualTo(string.Empty), "Error in diff: " + err); //string apiDiff = Encoding.Default.GetString(outstream.ToArray()); //string[] clientLines = clientDiff.Split('\n'); //string[] apiLines = apiDiff.Split('\n'); //Array.Sort<string>(clientLines); //Array.Sort<string>(apiLines); //Assert.That(apiLines, Is.EqualTo(clientLines), "Diffs differ"); }
private static void CheckoutUpdate(Parameters parameters) { using (var client = new SharpSvn.SvnClient()) { SetUpClient(parameters, client); var target = SvnTarget.FromString(parameters.Path); SvnInfoEventArgs svnInfoEventArgs; SvnUpdateResult svnUpdateResult; var nonExistentUrl = false; EventHandler <SvnErrorEventArgs> ignoreNonexistent = (o, eventArgs) => { nonExistentUrl = false; //if (eventArgs.Exception.SubversionErrorCode == 170000) if (eventArgs.Exception.Message.Contains("non-existent in revision")) { nonExistentUrl = true; eventArgs.Cancel = true; } }; if (client.GetWorkingCopyRoot(parameters.Path) == null) { client.SvnError += ignoreNonexistent; var getInfoSucceeded = client.GetInfo(SvnUriTarget.FromString(parameters.Url), out svnInfoEventArgs); client.SvnError -= ignoreNonexistent; if (!getInfoSucceeded) { if (nonExistentUrl) { Console.WriteLine("SVN info reported nonexistent URL; creating remote directory."); if (!client.RemoteCreateDirectory(new Uri(parameters.Url), new SvnCreateDirectoryArgs { CreateParents = true, LogMessage = parameters.Message })) { throw new Exception("Create directory failed on " + parameters.Url); } } else { throw new Exception("SVN info failed"); } } DebugMessage(parameters, "Checking out"); if (client.CheckOut(SvnUriTarget.FromString(parameters.Url), parameters.Path, out svnUpdateResult)) { DebugMessage(parameters, "Done"); Console.WriteLine("Checked out r" + svnUpdateResult.Revision); return; } throw new Exception("SVN checkout failed"); } if (!client.GetInfo(target, out svnInfoEventArgs)) { throw new Exception("SVN info failed"); } if (!UrlsMatch(svnInfoEventArgs.Uri.ToString(), parameters.Url)) { throw new Exception(string.Format("A different URL is already checked out ({0} != {1})", svnInfoEventArgs.Uri, parameters.Url)); } if (parameters.Cleanup) { DebugMessage(parameters, "Cleaning up"); client.CleanUp(parameters.Path); DebugMessage(parameters, "Done"); } if (parameters.Revert) { DebugMessage(parameters, "Reverting"); client.Revert(parameters.Path); DebugMessage(parameters, "Done"); } if (parameters.DeleteUnversioned) { DebugMessage(parameters, "Deleting unversioned files"); Collection <SvnStatusEventArgs> changedFiles; client.GetStatus(parameters.Path, out changedFiles); foreach (var changedFile in changedFiles) { if (changedFile.LocalContentStatus == SvnStatus.NotVersioned) { if (changedFile.NodeKind == SvnNodeKind.Directory) { DebugMessage(parameters, "NodeKind is directory for [" + changedFile.FullPath + "]"); } if ((File.GetAttributes(changedFile.FullPath) & FileAttributes.Directory) == FileAttributes.Directory) { DebugMessage(parameters, "Deleting directory [" + changedFile.FullPath + "] recursively!"); Directory.Delete(changedFile.FullPath, true); } else { DebugMessage(parameters, "Deleting file [" + changedFile.FullPath + "]"); File.Delete(changedFile.FullPath); } } } DebugMessage(parameters, "Done"); } DebugMessage(parameters, "Updating"); if (client.Update(parameters.Path, out svnUpdateResult)) { DebugMessage(parameters, "Done"); Console.WriteLine("Updated to r" + svnUpdateResult.Revision); return; } throw new Exception("SVN update failed"); } }
public static void CompleteSync(Parameters parameters) { using (var client = new SharpSvn.SvnClient()) { SetUpClient(parameters, client); if (parameters.UpdateBeforeCompleteSync) { DebugMessage(parameters, "Updating"); client.Update(parameters.Path); DebugMessage(parameters, "Done"); } Collection<SvnStatusEventArgs> changedFiles; DebugMessage(parameters, "Getting status"); client.GetStatus(parameters.Path, out changedFiles); DebugMessage(parameters, "Done"); if(changedFiles.Count == 0) { Console.WriteLine("No changes to commit."); return; } //delete files from subversion that are not in filesystem //add files to subversion that are new in filesystem //modified files are automatically included as part of the commit //TODO: check remoteStatus DebugMessage(parameters, "Recording changes"); foreach (var changedFile in changedFiles) { if (changedFile.LocalContentStatus == SvnStatus.Missing) { // SVN thinks file is missing but it still exists hence // a change in the case of the filename. if (File.Exists(changedFile.Path)) { var changedArgs = new SvnDeleteArgs {KeepLocal = true}; client.Delete(changedFile.Path, changedArgs); } else client.Delete(changedFile.Path); } if (changedFile.LocalContentStatus == SvnStatus.NotVersioned) { client.Add(changedFile.Path); } } DebugMessage(parameters, "Done"); var ca = new SvnCommitArgs {LogMessage = parameters.Message}; SvnCommitResult result; DebugMessage(parameters, "Committing"); if (client.Commit(parameters.Path, ca, out result)) { DebugMessage(parameters, "Done"); if(result == null) { Console.WriteLine("No result returned from commit."); return; } if (!string.IsNullOrEmpty(result.PostCommitError)) { Console.WriteLine("Post-commit hook error: " + result.PostCommitError); return; } Console.WriteLine("Committed r" + result.Revision); } else { if (result != null && !string.IsNullOrEmpty(result.PostCommitError)) { Console.WriteLine("Post-commit hook error after failed commit: " + result.PostCommitError); return; } Console.WriteLine("Commit failed."); } } }
public static void CompleteSync(Parameters parameters) { using (var client = new SharpSvn.SvnClient()) { SetUpClient(parameters, client); if (parameters.UpdateBeforeCompleteSync) { DebugMessage(parameters, "Updating"); client.Update(parameters.Path); DebugMessage(parameters, "Done"); } Collection <SvnStatusEventArgs> changedFiles; DebugMessage(parameters, "Getting status"); client.GetStatus(parameters.Path, out changedFiles); DebugMessage(parameters, "Done"); if (changedFiles.Count == 0) { Console.WriteLine("No changes to commit."); return; } //delete files from subversion that are not in filesystem //add files to subversion that are new in filesystem //modified files are automatically included as part of the commit //TODO: check remoteStatus DebugMessage(parameters, "Recording changes"); foreach (var changedFile in changedFiles) { if (changedFile.LocalContentStatus == SvnStatus.Missing) { // SVN thinks file is missing but it still exists hence // a change in the case of the filename. if (File.Exists(changedFile.Path)) { var changedArgs = new SvnDeleteArgs { KeepLocal = true }; client.Delete(changedFile.Path, changedArgs); } else { client.Delete(changedFile.Path); } } if (changedFile.LocalContentStatus == SvnStatus.NotVersioned) { client.Add(changedFile.Path); } } DebugMessage(parameters, "Done"); var ca = new SvnCommitArgs { LogMessage = parameters.Message }; SvnCommitResult result; DebugMessage(parameters, "Committing"); if (client.Commit(parameters.Path, ca, out result)) { DebugMessage(parameters, "Done"); if (result == null) { Console.WriteLine("No result returned from commit."); return; } if (!string.IsNullOrEmpty(result.PostCommitError)) { Console.WriteLine("Post-commit hook error: " + result.PostCommitError); return; } Console.WriteLine("Committed r" + result.Revision); } else { if (result != null && !string.IsNullOrEmpty(result.PostCommitError)) { Console.WriteLine("Post-commit hook error after failed commit: " + result.PostCommitError); return; } Console.WriteLine("Commit failed."); } } }