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 TestChangeLists() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.Default); string WcPath = sbox.Wc; Uri WcUri = sbox.Uri; string file1 = Path.Combine(WcPath, "ChangeListFile1"); string file2 = Path.Combine(WcPath, "ChangeListFile2"); string file3 = Path.Combine(WcPath, "ChangeListFile3"); string file4 = Path.Combine(WcPath, "ChangeListFile4"); using (SvnClient client = NewSvnClient(true, false)) { SvnInfoArgs ia = new SvnInfoArgs(); ia.ThrowOnError = false; SvnInfoEventArgs iea; Collection <SvnInfoEventArgs> ee; Assert.That(client.GetInfo(new Uri(WcUri, "ChangeListFile1"), ia, out ee), Is.False); Assert.That(client.GetInfo(new Uri(WcUri, "ChangeListFile2"), ia, out ee), Is.False); Assert.That(client.GetInfo(new Uri(WcUri, "ChangeListFile3"), ia, out ee), Is.False); Assert.That(client.GetInfo(new Uri(WcUri, "ChangeListFile4"), ia, out ee), Is.False); TouchFile(file1); TouchFile(file2); TouchFile(file3); TouchFile(file4); client.Add(file1); client.Commit(WcPath); client.GetInfo(new Uri(WcUri, "ChangeListFile1"), out iea); Assert.That(iea, Is.Not.Null); client.Add(file2); client.Add(file3); client.Add(file4); client.AddToChangeList(file2, "ChangeListTest-2"); client.AddToChangeList(file3, "ChangeListTest-3"); Collection <SvnListChangeListEventArgs> paths; SvnListChangeListArgs a = new SvnListChangeListArgs(); a.ChangeLists.Add("ChangeListTest-2"); client.GetChangeList(WcPath, a, out paths); Assert.That(paths, Is.Not.Null); Assert.That(paths.Count, Is.EqualTo(1)); Assert.That(paths[0].Path, Is.EqualTo(Path.GetFullPath(file2))); a = new SvnListChangeListArgs(); a.ChangeLists.Add("ChangeListTest-4"); client.GetChangeList(WcPath, a, out paths); Assert.That(paths, Is.Not.Null); Assert.That(paths.Count, Is.EqualTo(0)); SvnCommitArgs ca = new SvnCommitArgs(); ca.ChangeLists.Add("ChangeListTest-2"); client.Commit(WcPath, ca); Assert.That(client.GetInfo(new Uri(WcUri, "ChangeListFile2"), ia, out ee), Is.True); Assert.That(client.GetInfo(new Uri(WcUri, "ChangeListFile3"), ia, out ee), Is.False); Assert.That(client.GetInfo(new Uri(WcUri, "ChangeListFile4"), ia, out ee), Is.False); bool visited = false; a = new SvnListChangeListArgs(); a.ChangeLists.Add("ChangeListTest-3"); client.ListChangeList(WcPath, a, delegate(object sender, SvnListChangeListEventArgs e) { Assert.That(e.Path, Is.EqualTo(file3)); visited = true; }); Assert.That(visited, Is.True); visited = false; client.Status(file4, delegate(object sender, SvnStatusEventArgs e) { Assert.That(e.FullPath, Is.EqualTo(file4)); Assert.That(e.LocalNodeStatus, Is.EqualTo(SvnStatus.Added)); Assert.That(e.IsRemoteUpdated, Is.False); Assert.That(e.Path, Is.EqualTo(file4)); visited = true; }); Assert.That(visited, Is.True); client.Commit(WcPath); Assert.That(client.GetInfo(new Uri(WcUri, "ChangeListFile3"), ia, out ee), Is.True); Assert.That(client.GetInfo(new Uri(WcUri, "ChangeListFile4"), ia, out ee), Is.True); } }
public override void OnExecute(CommandEventArgs e) { string name; if (e.Command == AnkhCommand.MoveToIgnoreChangeList) { name = IgnoreOnCommit; } else if (e.Command == AnkhCommand.RemoveFromChangeList) { name = null; } else if (e.Command >= AnkhCommand.MoveToExistingChangeList0 && e.Command < AnkhCommand.MoveToExistingChangeListMax) { List <string> names = GetRecentNames(e); int n = e.Command - AnkhCommand.MoveToExistingChangeList0; if (n >= names.Count) { return; } name = names[n]; } else { using (CreateChangeListDialog dlg = new CreateChangeListDialog()) { if (DialogResult.OK != dlg.ShowDialog(e.Context)) { return; } name = dlg.ChangeListName; } } if (string.IsNullOrEmpty(name)) { name = null; } List <string> paths = new List <string>(); foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false)) { if (item.IsVersioned && (name != null) ? (item.IsFile || item.IsModified || item.IsDocumentDirty) : !string.IsNullOrEmpty(item.Status.ChangeList)) { paths.Add(item.FullPath); } } if (paths.Count == 0) { return; } e.Selection.Cache.Remove(typeof(ItemMoveToChangeList)); // Remove cached list of items using (SvnClient cl = e.GetService <ISvnClientPool>().GetNoUIClient()) { if (name == null) { SvnRemoveFromChangeListArgs ra = new SvnRemoveFromChangeListArgs(); ra.ThrowOnError = false; cl.RemoveFromChangeList(paths, ra); } else { SvnAddToChangeListArgs ca = new SvnAddToChangeListArgs(); ca.ThrowOnError = false; cl.AddToChangeList(paths, name, ca); } // The svn client broadcasts glyph updates to fix our UI } }