// 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; }
private static void PopLogCallback(object sender, SharpSvn.SvnFileVersionEventArgs e) { StreamReader sr = new StreamReader(e.GetContentStream()); Revs.Add(new Thing { Author = e.Author ,Revision = e.Revision ,Date = e.Time ,Log = e.LogMessage ,Content = sr.ReadToEnd() }); }
public RepositoryListItem(RepositoryListView view, SharpSvn.Remote.ISvnRepositoryListItem listItem, SvnOrigin dirOrigin, IFileIconMapper iconMapper) : base(view) { if (listItem == null) throw new ArgumentNullException("listItem"); else if (dirOrigin == null) throw new ArgumentNullException("dirOrigin"); SvnDirEntry entry = listItem.Entry; Uri entryUri = listItem.Uri; _entry = entry; _origin = new SvnOrigin(entryUri, dirOrigin); string name = SvnTools.GetFileName(entryUri); bool isFile = (entry.NodeKind == SvnNodeKind.File); string extension = isFile ? Path.GetExtension(name) : ""; if (iconMapper != null) { if (isFile) ImageIndex = iconMapper.GetIconForExtension(extension); else { ImageIndex = iconMapper.DirectoryIcon; } } SvnLockInfo lockInfo = null; SvnListEventArgs lea = listItem as SvnListEventArgs; if (lea != null) lockInfo = lea.Lock; SetValues( name, IsFolder ? RepositoryStrings.ExplorerDirectoryName : view.Context.GetService<IFileIconMapper>().GetFileType(extension), entry.Revision.ToString(), entry.Author, IsFolder ? "" : entry.FileSize.ToString(), entry.Time.ToLocalTime().ToString("g"), (lockInfo != null) ? lockInfo.Owner : ""); }
/// <summary> /// SourceIndex detector which tries to find valid providers /// </summary> /// <param name="state"></param> /// <returns>true if one or more files might be managed in subversion, otherwise false</returns> public bool CanProvideSources(SharpSvn.PdbAnnotate.Framework.IndexerState state) { SortedList<string, string> directories = new SortedList<string, string>(StringComparer.InvariantCultureIgnoreCase); foreach (SourceFile file in state.SourceFiles.Values) { string dir = file.File.DirectoryName; if (directories.ContainsKey(dir)) continue; directories.Add(dir, dir); if (SvnTools.IsBelowManagedPath(dir)) return true; } return false; }
static SvnRevision ToBaseRevision (SharpSvn.SvnRevision rev) { if (rev.RevisionType == SvnRevisionType.Base) return SvnRevision.Base; if (rev.RevisionType == SvnRevisionType.Committed) return SvnRevision.Committed; if (rev.RevisionType == SvnRevisionType.Head) return SvnRevision.Head; if (rev.RevisionType == SvnRevisionType.Previous) return SvnRevision.Previous; if (rev.RevisionType == SvnRevisionType.Working) return SvnRevision.Working; if (rev.RevisionType == SvnRevisionType.Number) return new SvnRevision (null, (int) rev.Revision); throw new SubversionException ("Unknown revision type: " + rev.RevisionType); }
void Authenticator_UserNamePasswordHandlers(object sender, SharpSvn.Security.SvnUserNamePasswordEventArgs e) { GC.KeepAlive(e.InitialUserName); GC.KeepAlive(e.Realm); _userArgs = e; _userNamePasswordTicked = true; e.Cancel = true; e.Break = true; }
void Authenticator_SslServerTrustHandlersAllow(object sender, SharpSvn.Security.SvnSslServerTrustEventArgs e) { Assert.That(e.Break, Is.False); Assert.That(e.Cancel, Is.False); _serverTrustTicked = true; e.AcceptedFailures = e.Failures; }
void Authenticator_SslServerTrustHandlers(object sender, SharpSvn.Security.SvnSslServerTrustEventArgs e) { Assert.That(e.Break, Is.False); Assert.That(e.Cancel, Is.False); Assert.That(e.CommonName.EndsWith(".apache.org")); //Assert.That(DateTime.Parse(e.ValidFrom), Is.LessThan(DateTime.Now)); //Assert.That(DateTime.Parse(e.ValidUntil), Is.GreaterThan(DateTime.Now)); _serverTrustTicked = true; e.AcceptedFailures = e.Failures; }
/// <summary> /// Resolves the specified revision. /// </summary> /// <param name="origin"></param> /// <param name="revision">The revision.</param> /// <returns></returns> public AnkhRevisionType Resolve(SvnOrigin origin, SharpSvn.SvnRevision revision) { if (revision == null) throw new ArgumentNullException("revision"); foreach (IAnkhRevisionProvider p in _providers) { AnkhRevisionType r = p.Resolve(origin, revision); if (r != null) return r; } switch (revision.RevisionType) { case SvnRevisionType.Number: ExplicitRevisionType ert = new ExplicitRevisionType(Context, origin); ert.CurrentValue = revision; return ert; } return null; }
public AnkhRevisionType Resolve(SvnOrigin origin, SharpSvn.SvnRevision revision) { if (revision == null) throw new ArgumentNullException("revision"); switch (revision.RevisionType) { case SvnRevisionType.Head: return _head; case SvnRevisionType.Base: return _base; case SvnRevisionType.Committed: return _committed; case SvnRevisionType.Previous: return _previous; case SvnRevisionType.Working: return _working; } return null; }
/// <summary> /// Handles the Override event of the SVN_SSL control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="SharpSvn.Security.SvnSslServerTrustEventArgs"/> instance containing the event data.</param> static void SVN_SSL_Override(object sender, SharpSvn.Security.SvnSslServerTrustEventArgs e) { e.AcceptedFailures = e.Failures; e.Save = true; }
void Authentication_UserNameHandlers(object sender, SharpSvn.Security.SvnUserNameEventArgs e) { e.UserName = "******"; e.Save = true; }
public string GetTempFile(SharpSvn.SvnTarget target, SharpSvn.SvnRevision revision, bool withProgress) { if (target == null) throw new ArgumentNullException("target"); else if (revision == null) throw new ArgumentNullException("revision"); string file = GetTempPath(target.FileName, revision); bool unrelated = false; ProgressRunnerResult r = GetService<IProgressRunner>().RunModal("Getting file", delegate(object sender, ProgressWorkerArgs aa) { SvnWriteArgs wa = new SvnWriteArgs(); wa.Revision = revision; wa.AddExpectedError(SvnErrorCode.SVN_ERR_CLIENT_UNRELATED_RESOURCES); using (Stream s = File.Create(file)) if (!aa.Client.Write(target, s, wa)) { if (wa.LastException.SvnErrorCode == SvnErrorCode.SVN_ERR_CLIENT_UNRELATED_RESOURCES) unrelated = true; } }); if (!r.Succeeded || unrelated) return null; // User canceled if (File.Exists(file)) File.SetAttributes(file, FileAttributes.ReadOnly); // A readonly file does not allow editting from many diff tools return file; }
public string GetTempFile(SvnItem target, SharpSvn.SvnRevision revision, bool withProgress) { if (target == null) throw new ArgumentNullException("target"); else if (revision == null) throw new ArgumentNullException("revision"); string file = GetTempPath(target.Name, revision); if (target.NodeKind != SvnNodeKind.File) throw new InvalidOperationException("Can't create a tempfile from a directory"); ProgressRunnerResult r = GetService<IProgressRunner>().RunModal("Getting file", delegate(object sender, ProgressWorkerArgs aa) { SvnWriteArgs wa = new SvnWriteArgs(); wa.Revision = revision; using (Stream s = File.Create(file)) aa.Client.Write(new SvnPathTarget(target.FullPath), s, wa); }); if (!r.Succeeded) return null; // User canceled if (File.Exists(file)) File.SetAttributes(file, FileAttributes.ReadOnly); // A readonly file does not allow editting from many diff tools return file; }
public void RegisterConflictHandler(SharpSvn.SvnClientArgsWithConflict args, System.ComponentModel.ISynchronizeInvoke synch) { args.Conflict += new EventHandler<SvnConflictEventArgs>(new Handler(this, synch).OnConflict); }
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); } }