public void Remote_CompareRanges() { SvnSandBox sbox = new SvnSandBox(this); Uri CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario); using (SvnRemoteSession rc = new SvnRemoteSession()) { rc.Open(CollabReposUri); Collection <SvnRemoteLocationSegmentEventArgs> c; rc.GetLocationSegments("branches/c/products/medium.html", out c); List <long> revs = new List <long>(); foreach (SvnRemoteLocationSegmentEventArgs e in c) { revs.Add(e.StartRevision); revs.Add(e.EndRevision); System.Diagnostics.Debug.WriteLine(string.Format("{0}: {1}", e.Uri, e.Range)); } SvnRevisionLocationMap revMap; rc.GetLocations("branches/c/products/medium.html", revs, out revMap); foreach (SvnRemoteLocationSegmentEventArgs e in c) { Assert.That(revMap.Contains(e.StartRevision)); Assert.That(revMap[e.StartRevision].Uri, Is.EqualTo(e.Uri)); Assert.That(revMap.Contains(e.EndRevision)); Assert.That(revMap[e.EndRevision].Uri, Is.EqualTo(e.Uri)); } } }
public static void InitSVNClient(string path) { svnPath = path; client = new SvnClient(); SvnRemoteSession remoteSession = new SvnRemoteSession(new Uri(svnPath)); remoteSession.GetLatestRevision(out latestRevision); }
/// <summary> /// Binds the specified client to the user interface defined by args /// </summary> /// <param name="client">The client to bind.</param> /// <param name="args">The args.</param> public static void Bind(SvnRemoteSession client, SvnUIBindArgs args) { if (client == null) throw new ArgumentNullException("client"); else if (args == null) throw new ArgumentNullException("args"); SvnClientUIHandler handler = new SvnClientUIHandler(args.ParentWindow); handler.Bind(client, args); }
public void Remote_RemoteList() { DateTime start = DateTime.Now; using (SvnRemoteSession rc = new SvnRemoteSession()) { rc.Open(new Uri("http://svn.apache.org/repos/asf/subversion/")); int n = 0; bool foundTrunk = false; List <Uri> uris = new List <Uri>(); SvnNodeKind dir; rc.GetNodeKind("", out dir); Assert.That(dir, Is.EqualTo(SvnNodeKind.Directory)); rc.List("", delegate(object sender, SvnRemoteListEventArgs e) { n++; if (e.Name == "trunk") { foundTrunk = true; Assert.That(e.Uri, Is.EqualTo(new Uri("http://svn.apache.org/repos/asf/subversion/trunk/"))); } uris.Add(e.Uri); }); Assert.That(foundTrunk); Assert.That(n, Is.GreaterThan(4)); Uri reposRoot; rc.GetRepositoryRoot(out reposRoot); rc.Reparent(reposRoot); int n2 = 0; rc.List("subversion/", delegate(object sender, SvnRemoteListEventArgs e) { n2++; Assert.That(uris.Contains(e.Uri), "Same Uri"); }); Assert.That(n2, Is.EqualTo(n)); } DateTime between = DateTime.Now; Collection <SvnListEventArgs> items; Client.GetList(new Uri("http://svn.apache.org/repos/asf/subversion/"), out items); DateTime after = DateTime.Now; Console.WriteLine(between - start); Console.WriteLine(after - between); }
/// <summary> /// Binds the specified client to the user interface defined by args /// </summary> /// <param name="client">The client to bind.</param> /// <param name="parentWindow">The parent window.</param> public static void Bind(SvnRemoteSession client, IWin32Window parentWindow) { if (client == null) { throw new ArgumentNullException("client"); } SvnUIBindArgs args = new SvnUIBindArgs(); args.ParentWindow = parentWindow; Bind(client, args); }
/// <summary> /// Binds the specified client to the user interface defined by args /// </summary> /// <param name="client">The client to bind.</param> /// <param name="args">The args.</param> public static void Bind(SvnRemoteSession client, SvnUIBindArgs args) { if (client == null) { throw new ArgumentNullException("client"); } else if (args == null) { throw new ArgumentNullException("args"); } SvnClientUIHandler handler = new SvnClientUIHandler(args.ParentWindow); handler.Bind(client, args); }
public void Remote_ListLocks() { SvnSandBox sbox = new SvnSandBox(this); Uri tmpRepos = sbox.CreateRepository(SandBoxRepository.Greek); using (SvnRemoteSession rs = new SvnRemoteSession()) { rs.Open(tmpRepos); int n = 0; rs.ListLocks("", delegate(object sender, SvnRemoteListLockEventArgs e) { n++; }); Assert.That(n, Is.EqualTo(0)); } using (SvnClient cl = new SvnClient()) { cl.RemoteLock(new Uri(tmpRepos, "trunk/iota"), ""); cl.RemoteLock(new Uri(tmpRepos, "trunk/A/D/gamma"), ""); } using (SvnRemoteSession rs = new SvnRemoteSession()) { rs.Open(tmpRepos); int n = 0; rs.ListLocks("trunk/A", delegate(object sender, SvnRemoteListLockEventArgs e) { n++; }); Assert.That(n, Is.EqualTo(1)); n = 0; rs.ListLocks("trunk", delegate(object sender, SvnRemoteListLockEventArgs e) { n++; }); Assert.That(n, Is.EqualTo(2)); } }
public void Remote_GetProps() { SvnSandBox sbox = new SvnSandBox(this); Uri CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario); using (SvnRemoteSession rc = new SvnRemoteSession(CollabReposUri)) { SvnPropertyCollection pc; rc.GetProperties("trunk", out pc); Assert.That(pc, Is.Not.Null); Assert.That(pc.Count, Is.EqualTo(1)); Assert.That(pc.Contains(SvnPropertyNames.SvnMergeInfo)); rc.GetProperties("trunk/about/index.html", out pc); Assert.That(pc, Is.Not.Null); Assert.That(pc.Count, Is.EqualTo(1)); Assert.That(pc.Contains(SvnPropertyNames.SvnEolStyle)); } }
public void Remote_LocationSegments() { SvnSandBox sbox = new SvnSandBox(this); SvnRemoteSession rs; using (SvnRemoteSession rc = new SvnRemoteSession()) { Uri root = sbox.CreateRepository(SandBoxRepository.MergeScenario); rc.Open(root); int n = 0; rc.LocationSegments("branches/b/about/index.html", delegate(object sender, SvnRemoteLocationSegmentEventArgs e) { switch (n++) { case 0: Assert.That(e.RepositoryPath, Is.EqualTo("branches/b/about/index.html")); Assert.That(e.Uri, Is.EqualTo(new Uri(root, e.RepositoryPath))); break; case 1: Assert.That(e.RepositoryPath, Is.EqualTo("trunk/about/index.html")); break; default: Assert.That(false); break; } }); Assert.That(n, Is.EqualTo(2)); rs = rc; long r; Assert.That(rc.GetDeletedRevision("trunk", 2, out r)); Assert.That(r, Is.EqualTo(-1)); } Assert.That(!rs.IsCommandRunning); Assert.That(rs.IsDisposed); }
public void Remote_Lock() { SvnSandBox sbox = new SvnSandBox(this); Uri reposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario); Uri toLock = new Uri(reposUri, "trunk/index.html"); Client.RemoteLock(toLock, ""); using (SvnRemoteSession rc = new SvnRemoteSession()) { bool locked = false; rc.Open(reposUri); rc.ListLocks("", delegate(object sender, SvnRemoteListLockEventArgs e) { Assert.That(e.Lock, Is.Not.Null); Assert.That(e.Path, Is.EqualTo("trunk/index.html")); Assert.That(e.RepositoryPath, Is.EqualTo("trunk/index.html")); Assert.That(e.Uri, Is.EqualTo(toLock)); locked = true; }); Assert.That(locked, Is.True); } using (SvnRemoteSession rc = new SvnRemoteSession()) { bool locked = false; rc.Open(new Uri(reposUri, "trunk")); rc.ListLocks("", delegate(object sender, SvnRemoteListLockEventArgs e) { Assert.That(e.Lock, Is.Not.Null); Assert.That(e.Path, Is.EqualTo("index.html")); Assert.That(e.RepositoryPath, Is.EqualTo("trunk/index.html")); Assert.That(e.Uri, Is.EqualTo(toLock)); locked = true; }); Assert.That(locked, Is.True); } }
public void Remote_OpenRepos() { SvnSandBox sbox = new SvnSandBox(this); Uri CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario); using (SvnRemoteSession r = new SvnRemoteSession(CollabReposUri)) { r.Reparent(CollabReposUri); long rev; Uri uri; Guid id; SvnRemoteStatEventArgs stat; long foundRev; r.GetLatestRevision(out rev); r.GetRepositoryRoot(out uri); r.GetRepositoryId(out id); r.GetStat(null, out stat); r.ResolveRevision(DateTime.Now, out foundRev); Assert.That(uri, Is.EqualTo(CollabReposUri)); Assert.That(rev, Is.EqualTo(17L)); Assert.That(id, Is.EqualTo(new Guid("d4e3f7eb-7f47-4c2b-9c6e-ba21fc616240"))); Assert.That(stat, Is.Not.Null); Assert.That(stat.Entry, Is.Not.Null); Assert.That(stat.Entry.Author, Is.EqualTo("merger")); Assert.That(stat.Entry.NodeKind, Is.EqualTo(SvnNodeKind.Directory)); int n = 0; r.List("", delegate(object sender, SvnRemoteListEventArgs e) { Assert.That(e.Name, Is.Not.Null); n++; }); Assert.That(n, Is.EqualTo(3)); Assert.That(r.SessionUri, Is.Not.Null); Assert.That(r.IsDisposed, Is.False); } }
public void Remote_StatFile() { using (SvnRemoteSession rc = new SvnRemoteSession()) { rc.Open(new Uri("http://svn.apache.org/repos/asf/subversion/trunk/COMMITTERS")); SvnRemoteStatEventArgs st; rc.GetStat("", out st); Assert.That(st, Is.Not.Null); Assert.That(st.Entry.Time, Is.GreaterThan(new DateTime(2006, 1, 1))); SvnNodeKind kind; rc.GetNodeKind("", out kind); Assert.That(kind, Is.EqualTo(SvnNodeKind.File)); rc.GetNodeKind("QQQ", out kind); Assert.That(kind, Is.EqualTo(SvnNodeKind.None)); } }
public void Remote_LogRanges() { SvnSandBox sbox = new SvnSandBox(this); Uri CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario); using (SvnRemoteSession rc = new SvnRemoteSession()) using (SvnRemoteSession rc2 = new SvnRemoteSession()) { Uri reposRoot; rc.Open(CollabReposUri); rc.GetRepositoryRoot(out reposRoot); rc2.Open(reposRoot); rc.LocationSegments("branches/c/products/medium.html", delegate(object sender, SvnRemoteLocationSegmentEventArgs e) { rc2.Log(rc2.MakeRelativePath(e.Uri), e.Range.Reverse(), delegate(object sender2, SvnRemoteLogEventArgs e2) { Debug.WriteLine(string.Format("{0} in {1} as {2} ({3}): {4}", e2.Author, e2.Revision, e.RepositoryPath, e.Range, e2.LogMessage)); }); }); } }
/// <summary> /// Binds the specified client to the user interface defined by args /// </summary> /// <param name="client">The client to bind.</param> /// <param name="parentWindow">The parent window.</param> public static void Bind(SvnRemoteSession client, IWin32Window parentWindow) { if (client == null) throw new ArgumentNullException("client"); SvnUIBindArgs args = new SvnUIBindArgs(); args.ParentWindow = parentWindow; Bind(client, args); }
private void btnStart_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(txtRemotePath.Text)) { MessageBox.Show("必须输入远程目录", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } if (string.IsNullOrWhiteSpace(txtOutputPath.Text)) { MessageBox.Show("必须输入文件输出目录", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } Task.Run(() => { List <ChangedFile> changedFiles = new List <ChangedFile>(); var deleteList = new List <string>(); var includeList = txtInclude.Text.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); using (SvnRemoteSession remoteSession = new SvnRemoteSession(new Uri(txtRemotePath.Text))) { SvnUI.Bind(remoteSession, new SvnUIBindArgs()); SvnRemoteLogArgs svnRemoteLogArgs = new SvnRemoteLogArgs(); var svnRemoteLocationSegmentEventArgsCollection = new Collection <SvnRemoteLocationSegmentEventArgs>(); remoteSession.GetLocationSegments("/", out svnRemoteLocationSegmentEventArgsCollection); foreach (var svnRemoteLocationSegmentEventArgse in svnRemoteLocationSegmentEventArgsCollection) { if (!long.TryParse(txtFirstRevision.Text, out var startRevision)) { startRevision = 0; } startRevision = svnRemoteLocationSegmentEventArgse.StartRevision > startRevision ? svnRemoteLocationSegmentEventArgse.StartRevision : startRevision; if (!long.TryParse(txtSecondRevision.Text, out var endRevision)) { endRevision = long.MaxValue; } endRevision = svnRemoteLocationSegmentEventArgse.EndRevision < endRevision ? svnRemoteLocationSegmentEventArgse.EndRevision : endRevision; remoteSession.Log("/", new SvnRevisionRange(startRevision, endRevision), ((o, args) => { foreach (var argsChangedPath in args.ChangedPaths) { if (cbDontIncludeDelete.Checked) { if (argsChangedPath.Action == SvnChangeAction.Delete) { deleteList.Add(argsChangedPath.Path); changedFiles = changedFiles.Where(x => x.Path != argsChangedPath.Path).ToList(); continue; } if (deleteList.Contains(argsChangedPath.Path)) { continue; } } if (argsChangedPath.ContentModified == false) { continue; } if (rbDontInclude.Checked && includeList.Any(x => argsChangedPath.Path.IndexOf(x) >= 0)) { continue; } if (rbInclude.Checked && !includeList.Any(x => argsChangedPath.Path.IndexOf(x) >= 0)) { continue; } ChangedFile changedFile = new ChangedFile(); changedFile.Path = argsChangedPath.Path; changedFile.Author = args.Author; changedFile.Message = args.LogMessage; changedFile.FirstModifyAction = argsChangedPath.Action.ToString(); changedFile.FirstModifyRevision = args.Revision; if (cbComparedEvery.Checked || !changedFiles.Contains(changedFile)) { changedFiles.Add(changedFile); } } })); } //File.AppendAllLines("E:/123.txt", changedFiles.Select(x => $"文件信息:{x.Path}\t文件是否是修改:{x.FirstModifyAction}\t文件初次修改版本号:{x.FirstModifyRevision}\t初次修改作者:{x.Author}\t提交信息:{x.Message}")); var wb = new XLWorkbook(new MemoryStream(Properties.Resources.model)); int lineNum = 1; if (wb.TryGetWorksheet("ソース一覧", out IXLWorksheet iWorksheet)) { foreach (var changedFile in changedFiles) { var row = iWorksheet.Row(lineNum + 2); row.Cell("A").SetValue(lineNum); row.Cell("B").SetValue(Path.GetDirectoryName(changedFile.Path)); row.Cell("C").SetValue(Path.GetFileName(changedFile.Path)); if (changedFile.FirstModifyAction == "Add") { row.Cell("H").SetValue("○"); } else if (changedFile.FirstModifyAction == "Modify") { row.Cell("I").SetValue("○"); } row.Cell("J").SetValue(changedFile.Author); if (cbWriteFirstRevision.Checked) { row.Cell("L").Value = "版本号:" + changedFile.FirstModifyRevision; } if (cbWriteFirstAction.Checked) { row.Cell("L").Value += "执行操作" + changedFile.FirstModifyAction; } lineNum++; } var range = iWorksheet.Range(3, 1, lineNum + 1, 12); range.Style.Border.BottomBorder = XLBorderStyleValues.Dotted; range.Style.Border.RightBorder = XLBorderStyleValues.Thin; wb.SaveAs(txtOutputPath.Text); } } this.Invoke((MethodInvoker)(() => { btnStart.Enabled = true; btnStart.Text = "开始"; })); MessageBox.Show("处理完成"); }); btnStart.Enabled = false; btnStart.Text = "处理中"; }
public void Remote_TestOptions() { Assert.That(SvnRemoteSession.IsConnectionlessRepository(new Uri("http://svn.collab.net/"))); Assert.That(SvnRemoteSession.RequiresExternalAuthorization(new Uri("http://svn.collab.net/")), Is.False); }