/// <summary> /// Returns a list of the contents of the directory /// </summary> /// <param name="svnTarget"></param> /// <returns></returns> public static Collection<SvnListEventArgs> FetchListing(SvnTarget svnTarget, SvnListArgs args = null) { args = args == null ? new SvnListArgs() : args; var result = new Collection<SvnListEventArgs>(); _client.Value.GetList(svnTarget, args, out result); return result; }
public void ForEachChild(string path, int revision, Change change, Action <PathChange> action) { SvnClient client = AllocSvnClient(); SvnTarget target = MakeTarget(path, change == Change.Delete ? revision - 1 : revision); try { SvnListArgs args = new SvnListArgs { Depth = SvnDepth.Infinity }; client.List(target, args, delegate(object s, SvnListEventArgs e) { if (string.IsNullOrEmpty(e.Path)) { return; } var pc = new PathChange(); { pc.Change = change; pc.Revision = revision; // to be compatible with the log output (which has no trailing '/' for directories) // we need to remove trailing '/' pc.Path = (e.BasePath.EndsWith("/") ? e.BasePath : e.BasePath + "/") + e.Path.TrimEnd('/'); } action(pc); }); } finally { FreeSvnClient(client); } }
static IEnumerable <DirectoryEntry> List(SvnTarget target, bool recurse) { var list = new List <DirectoryEntry> (); var args = new SvnListArgs { Depth = recurse ? SvnDepth.Infinity : SvnDepth.Children, }; lock (client) client.List(target, args, delegate(object o, SvnListEventArgs a) { if (string.IsNullOrEmpty(a.Path)) { return; } list.Add(new DirectoryEntry { CreatedRevision = ToBaseRevision(a.Entry.Revision).Rev, HasProps = a.Entry.HasProperties, IsDirectory = a.Entry.NodeKind == SvnNodeKind.Directory, LastAuthor = a.Entry.Author, Name = a.Path, Size = a.Entry.FileSize, Time = a.Entry.Time, }); }); return(list); }
/// <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) { SvnTarget target = new SvnUriTarget(RepositoryPath); SvnListArgs args = new SvnListArgs(); args.Depth = Recursive ? SvnDepth.Infinity : SvnDepth.Children; return client.List(target, args, listHandler); }
static void Test4() { var client = new SvnClient(); Collection <SvnListEventArgs> list; SvnListArgs args = new SvnListArgs(); args.Depth = SvnDepth.Infinity; if (client.GetList(new SvnUriTarget("file:///D:/Work/svn/BIST/repo/releases"), args, out list)) { } }
// lists immediate children; checks if one of them is a stopper static bool CheckChildrenForStoppers(SvnClient client, Uri uri, string subPath, string[] stoppers, ref List <string> modules) { Collection <SvnListEventArgs> list; try { SvnListArgs args = new SvnListArgs(); args.Depth = SvnDepth.Children; args.IncludeExternals = false; if (!client.GetList(new SvnUriTarget(uri), args, out list)) { return(false); } } catch (SvnException) { return(false); } bool first = true; foreach (var li in list) { // skip first item as it is the base directory if (first) { first = false; continue; } if (li.Entry.NodeKind == SvnNodeKind.Directory) { if (IsStopper(li.Name, stoppers)) { // found a stopper, stop recursion modules.Add(subPath); return(true); } // continue recursion var childrenSubPath = String.IsNullOrEmpty(subPath) ? li.Name : $"{subPath}/{li.Name}"; if (!CheckChildrenForStoppers(client, li.Uri, childrenSubPath, stoppers, ref modules)) { return(false); } } } return(true); }
public void List_TestList() { SvnSandBox sbox = new SvnSandBox(this); Uri ReposUrl = sbox.CreateRepository(SandBoxRepository.AnkhSvnCases); string list = this.RunCommand("svn", "list -v " + ReposUrl); // clean out whitespace string[] entries = Regex.Split(list, @"\r\n"); //string[] entries = list.Trim().Split( '\n' ); Hashtable ht = new Hashtable(); foreach (string e in entries) { if (e != "") { Entry ent = new Entry(e); ht[ent.Path] = ent; } } Collection <SvnListEventArgs> apiList; SvnListArgs a = new SvnListArgs(); a.Depth = SvnDepth.Children; Assert.That(Client.GetList(new SvnUriTarget(ReposUrl, SvnRevision.Head), a, out apiList)); Assert.That(apiList.Count, Is.EqualTo(ht.Count), "Wrong number of entries returned"); foreach (SvnListEventArgs ent in apiList) { string path = ent.Path; if (path == "") { break; // New in 1.4+ ; was not available in ankh tests, as svn_client_ls was used instead of svn_client_list } if (ent.Entry.NodeKind == SvnNodeKind.Directory) { path += "/"; } Entry entry = (Entry)ht[path]; Assert.IsNotNull(entry, "No entry found for " + path); entry.Match(ent.Entry); } }
public int GetRepositoryFiles(out Collection <SvnListEventArgs> apiList, string subPath) { SvnListArgs listArgs = new SvnListArgs(); listArgs.Depth = SvnDepth.Children; bool returnCode = _SvnClient.GetList(new SvnUriTarget(subPath, SvnRevision.Head), listArgs, out apiList); if (returnCode) { return(apiList.Count); } return(-1); }
// lists immediate children; // if no one found (leaf) and depth >= minLevel, add the path to the result static bool CheckChildrenLeaf(SvnClient client, Uri uri, string subPath, int depth, int minDepth, ref List <string> results) { Collection <SvnListEventArgs> list; SvnListArgs args = new SvnListArgs(); args.Depth = SvnDepth.Children; args.IncludeExternals = false; if (!client.GetList(new SvnUriTarget(uri), args, out list)) { return(false); } // if leaf if (list.Count <= 1) { if (depth >= minDepth) { results.Add(subPath); } return(true); } bool first = true; foreach (var li in list) { // skip first item as it is the base directory if (first) { first = false; continue; } if (li.Entry.NodeKind == SvnNodeKind.Directory) { // continue recursion var childrenSubPath = String.IsNullOrEmpty(subPath) ? li.Name : $"{subPath}/{li.Name}"; var childrenDepth = depth + 1; if (!CheckChildrenLeaf(client, li.Uri, childrenSubPath, childrenDepth, minDepth, ref results)) { return(false); } } } return(true); }
private List <SvnListEventArgs> SearchInternal(string searchText, bool caseSensitive, ValidatorType type, string fileFilter, string authorFilter, bool recursive, CancellationToken token, IProgress <SvnListEventArgs> progress) { using (var client = new SvnClient()) { var results = new Collection <SvnListEventArgs>(); var args = new SvnListArgs() { RetrieveEntries = SvnDirEntryItems.AllFieldsV15, Depth = (recursive) ? SvnDepth.Infinity : SvnDepth.Children }; var validator = new ResultValidator() { SearchText = searchText, CaseSensitive = caseSensitive, FileFilter = fileFilter, AuthorFilter = authorFilter, Type = type }; if (token != null) { args.Cancel += (sender, e) => e.Cancel = token.IsCancellationRequested; } if (progress != null) { args.List += (sender, e) => { if (!string.IsNullOrEmpty(e.Path) && validator.Validate(e)) { progress.Report(e); } }; } try { if (!client.GetList(_target, args, out results)) { return(null); } return((from r in results where !string.IsNullOrEmpty(r.Path) && validator.Validate(r) select r).ToList()); } catch (SvnOperationCanceledException) { token.ThrowIfCancellationRequested(); return(null); } } }
public void List_ListDepth() { SvnSandBox sbox = new SvnSandBox(this); Uri CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario); Uri url = new Uri(CollabReposUri, "trunk/"); string dir = sbox.Wc; Client.CheckOut(url, dir); foreach (SvnDepth d in new SvnDepth[] { SvnDepth.Infinity, SvnDepth.Children, SvnDepth.Files, SvnDepth.Empty }) { Collection <SvnListEventArgs> remoteList, localList; SvnListArgs la = new SvnListArgs(); la.Depth = d; Client.GetList(url, la, out remoteList); Client.GetList(dir, la, out localList); Assert.That(remoteList.Count, Is.EqualTo(localList.Count)); switch (d) { case SvnDepth.Infinity: Assert.That(localList.Count, Is.EqualTo(16)); break; case SvnDepth.Children: Assert.That(localList.Count, Is.EqualTo(7)); break; case SvnDepth.Files: Assert.That(localList.Count, Is.EqualTo(2)); break; case SvnDepth.Empty: Assert.That(localList.Count, Is.EqualTo(1)); break; } } }
private Uri GetRemoteUriFromPath(string Path, out Collection <SvnListEventArgs> ListEventArgs) { try { string relativePath = System.IO.Path.GetFullPath(Path); relativePath = relativePath.Substring(SolutionFolder.Length - 1); Uri targetUri = new Uri(SourceControlURL + relativePath); SvnTarget target = SvnTarget.FromUri(targetUri); SvnListArgs args = new SvnListArgs(); args.RetrieveLocks = true; client.GetList(target, args, out ListEventArgs); return(targetUri); } catch (Exception ex) { ListEventArgs = null; Reporter.ToLog(eLogLevel.ERROR, $"Method - {MethodBase.GetCurrentMethod().Name}, Error - {ex.Message}"); return(null); } }
public void RemoteList() { SvnClient cl = new SvnClient(); bool found = false; SvnListArgs la = new SvnListArgs(); la.RetrieveEntries = SvnDirEntryItems.AllFieldsV15; cl.List(new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/trunk"), la, delegate(object Sender, SvnListEventArgs e) { Assert.That(e.Entry, Is.Not.Null); Assert.That(e.Entry.Revision, Is.GreaterThan(0L)); Assert.That(e.Entry.Author, Is.Not.Null); found = true; }); Assert.That(found); Collection<SvnListEventArgs> ee; cl.GetList(new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/trunk"), out ee); Assert.That(ee, Is.Not.Null); Assert.That(ee[0].Entry.Author, Is.Not.Null); }
IEnumerable <DirectoryEntry> List(SvnTarget target, bool recurse) { List <DirectoryEntry> list = new List <DirectoryEntry> (); SvnListArgs args = new SvnListArgs(); args.Depth = recurse ? SvnDepth.Infinity : SvnDepth.Children; client.List(target, args, delegate(object o, SvnListEventArgs a) { if (string.IsNullOrEmpty(a.Path)) { return; } DirectoryEntry de = new DirectoryEntry(); de.CreatedRevision = ToBaseRevision(a.Entry.Revision).Rev; de.HasProps = a.Entry.HasProperties; de.IsDirectory = a.Entry.NodeKind == SvnNodeKind.Directory; de.LastAuthor = a.Entry.Author; de.Name = a.Path; de.Size = a.Entry.FileSize; de.Time = a.Entry.Time; list.Add(de); }); return(list); }
public void List_ListDepth() { SvnSandBox sbox = new SvnSandBox(this); Uri CollabReposUri = sbox.CreateRepository(SandBoxRepository.MergeScenario); Uri url = new Uri(CollabReposUri, "trunk/"); string dir = sbox.Wc; Client.CheckOut(url, dir); foreach (SvnDepth d in new SvnDepth[] { SvnDepth.Infinity, SvnDepth.Children, SvnDepth.Files, SvnDepth.Empty }) { Collection<SvnListEventArgs> remoteList, localList; SvnListArgs la = new SvnListArgs(); la.Depth = d; Client.GetList(url, la, out remoteList); Client.GetList(dir, la, out localList); Assert.That(remoteList.Count, Is.EqualTo(localList.Count)); switch (d) { case SvnDepth.Infinity: Assert.That(localList.Count, Is.EqualTo(16)); break; case SvnDepth.Children: Assert.That(localList.Count, Is.EqualTo(7)); break; case SvnDepth.Files: Assert.That(localList.Count, Is.EqualTo(2)); break; case SvnDepth.Empty: Assert.That(localList.Count, Is.EqualTo(1)); break; } } }
public void RemoteList() { SvnClient cl = NewSvnClient(false, false); bool found = false; SvnListArgs la = new SvnListArgs(); la.RetrieveEntries = SvnDirEntryItems.AllFieldsV15; cl.List(new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/trunk"), la, delegate(object Sender, SvnListEventArgs e) { Assert.That(e.Entry, Is.Not.Null); Assert.That(e.Entry.Revision, Is.GreaterThan(0L)); Assert.That(e.Entry.Author, Is.Not.Null); found = true; }); Assert.That(found); Collection <SvnListEventArgs> ee; cl.GetList(new Uri("https://ctf.open.collab.net/svn/repos/sharpsvn/trunk"), out ee); Assert.That(ee, Is.Not.Null); Assert.That(ee[0].Entry.Author, Is.Not.Null); }
/// <summary> /// Update the cache with all the files. /// </summary> private void ReloadCache() { var subdirs = new string[] { "common", "nonStandard", "higgscontrol", "susycontrol", "topcontrol" }; // A list fo the files to access, one after the other var opt = new SvnListArgs() { Depth = SvnDepth.Infinity }; var linesCommon = subdirs .Select(d => MCJobSVNHelpers.BuildTarget(d, MCCampaign)) .SelectMany(dl => MCJobSVNHelpers.FetchListing(dl, opt)); // Now, write it out. var cacheFile = GetCacheFileInfo(); using (var writer = cacheFile.CreateText()) { foreach (var item in linesCommon) { writer.WriteLine(item.Uri.OriginalString); } } }
/// <summary> /// Update the cache with all the files. /// </summary> private void ReloadCache() { var subdirs = new string[] { "common", "nonStandard", "higgscontrol", "susycontrol", "topcontrol"}; // A list fo the files to access, one after the other var opt = new SvnListArgs() { Depth = SvnDepth.Infinity }; var linesCommon = subdirs .Select(d => MCJobSVNHelpers.BuildTarget(d, MCCampaign)) .SelectMany(dl => MCJobSVNHelpers.FetchListing(dl, opt)); // Now, write it out. var cacheFile = GetCacheFileInfo(); using (var writer = cacheFile.CreateText()) { foreach (var item in linesCommon) { writer.WriteLine(item.Uri.OriginalString); } } }
IEnumerable<DirectoryEntry> List (SvnTarget target, bool recurse) { List<DirectoryEntry> list = new List<DirectoryEntry> (); SvnListArgs args = new SvnListArgs (); args.Depth = recurse ? SvnDepth.Infinity : SvnDepth.Children; lock (client) client.List (target, args, delegate (object o, SvnListEventArgs a) { if (string.IsNullOrEmpty (a.Path)) return; DirectoryEntry de = new DirectoryEntry (); de.CreatedRevision = ToBaseRevision (a.Entry.Revision).Rev; de.HasProps = a.Entry.HasProperties; de.IsDirectory = a.Entry.NodeKind == SvnNodeKind.Directory; de.LastAuthor = a.Entry.Author; de.Name = a.Path; de.Size = a.Entry.FileSize; de.Time = a.Entry.Time; list.Add (de); }); return list; }
/// <summary> /// Determines all directories OR files at <url> /// </summary> /// <param name="url">URL of the SVN Repository</param> /// <returns>List of directories or files. Null if url is invalid.</returns> /// //TODO: Liste<string, string> mit lokalem pfad und tatsächlichem pfad (svn:external) //-> artifact to clean = lokales verzeichnis //-> watermark = tatsächliches verzeichnis public Dictionary <string, string> GetItems(string svnUrl, ItemType itemType, bool recursive, string versionSpec) { SvnNodeKind searchedItemType = SvnNodeKind.Unknown; if (itemType == ItemType.Directory) { searchedItemType = SvnNodeKind.Directory; } else if (itemType == ItemType.File) { searchedItemType = SvnNodeKind.File; } SvnListArgs args = new SvnListArgs(); args.Revision = ConvertToRevsion(versionSpec); args.IncludeExternals = true; if (recursive) { args.Depth = SvnDepth.Infinity; } else { args.Depth = SvnDepth.Children; } var svnRootPath = _svn.GetRepositoryRoot(new Uri(svnUrl)); Collection <SvnListEventArgs> contents; Dictionary <string, string> ret = new Dictionary <string, string>(); try { if (_svn.GetList(new Uri(svnUrl), args, out contents)) { foreach (SvnListEventArgs item in contents) { //first entry is always empty if (!string.IsNullOrEmpty(item.Path) && item.Entry.NodeKind == searchedItemType) { if (string.IsNullOrEmpty(item.ExternalTarget)) { ret.Add(string.Format("{0}/{1}", svnUrl, item.Path), string.Format("{0}/{1}", svnUrl, item.Path)); } else { //Substring cuts the obosolte / at beginning //ret.Add(string.Format("{0}{1}/{2}", svnRootPath, item.BasePath.Substring(1), item.Path)); ret.Add(string.Format("{0}{1}/{2}", svnRootPath, item.BasePath.Substring(1), item.Path), string.Format("{0}/{1}/{2}", svnUrl, item.ExternalTarget, item.Path)); } } } } return(ret); } catch (SvnFileSystemException) { return(ret); } }
static IEnumerable<DirectoryEntry> List (SvnTarget target, bool recurse) { var list = new List<DirectoryEntry> (); var args = new SvnListArgs { Depth = recurse ? SvnDepth.Infinity : SvnDepth.Children, }; lock (client) client.List (target, args, delegate (object o, SvnListEventArgs a) { if (string.IsNullOrEmpty (a.Path)) return; list.Add (new DirectoryEntry { CreatedRevision = ToBaseRevision (a.Entry.Revision).Rev, HasProps = a.Entry.HasProperties, IsDirectory = a.Entry.NodeKind == SvnNodeKind.Directory, LastAuthor = a.Entry.Author, Name = a.Path, Size = a.Entry.FileSize, Time = a.Entry.Time, }); }); return list; }
public void List_ListDetails() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.Default); string WcPath = sbox.Wc; Uri WcUri = sbox.Uri; using (SvnClient client = NewSvnClient(true, false)) { string oneFile = Path.Combine(WcPath, "LocalFileForTestList"); TouchFile(oneFile); client.Add(oneFile); SvnCommitResult ci; client.Commit(WcPath, out ci); SvnUpdateResult r; client.Update(WcPath, out r); Assert.That(r, Is.Not.Null); Assert.That(r.HasRevision); Assert.That(r.HasResultMap); Assert.That(r.Revision, Is.EqualTo(ci.Revision)); bool visited = false; SvnListArgs a = new SvnListArgs(); a.RetrieveEntries = SvnDirEntryItems.AllFieldsV15; client.List(new SvnPathTarget(WcPath), a, delegate(object sender, SvnListEventArgs e) { Assert.That(e.Entry, Is.Not.Null, "Entry set"); Assert.That(e.RepositoryRoot, Is.Null, "Only valid when listing a Uri"); if (e.Path == "LocalFileForTestList") { Assert.That(e.BasePath, Is.EqualTo("/trunk"), "Basepath"); Assert.That(e.Lock, Is.Null); Assert.That(e.Entry.Author, Is.EqualTo(Environment.UserName)); Assert.That(e.Entry.FileSize, Is.EqualTo(0)); Assert.That(e.Entry.NodeKind, Is.EqualTo(SvnNodeKind.File)); Assert.That(e.Entry.Revision, Is.EqualTo(ci.Revision)); Assert.That(e.Entry.Time, Is.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 5, 0))); visited = true; } }); Assert.That(visited, Is.True, "Visited is true"); visited = false; client.List(WcUri, a, delegate(object sender, SvnListEventArgs e) { Assert.That(e.Entry, Is.Not.Null, "Entry set"); if (e.Path == "LocalFileForTestList") { Assert.That(e.BasePath, Is.EqualTo("/trunk"), "Basepath"); Assert.That(e.Lock, Is.Null); Assert.That(e.Entry.Author, Is.EqualTo(Environment.UserName)); Assert.That(e.Entry.FileSize, Is.EqualTo(0)); Assert.That(e.Entry.NodeKind, Is.EqualTo(SvnNodeKind.File)); Assert.That(e.Entry.Revision, Is.EqualTo(ci.Revision)); Assert.That(e.Entry.Time, Is.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 5, 0))); visited = true; } }); Assert.That(visited, Is.True, "Visited is true"); SvnWorkingCopyClient wcC = new SvnWorkingCopyClient(); SvnWorkingCopyState state; Assert.That(wcC.GetState(oneFile, out state)); Assert.That(state, Is.Not.Null); Assert.That(state.IsTextFile, Is.True); client.SetProperty(oneFile, "svn:mime-type", "application/binary"); Assert.That(wcC.GetState(oneFile, out state)); Assert.That(state, Is.Not.Null); Assert.That(state.IsTextFile, Is.False); } }
public void List_TestList() { SvnSandBox sbox = new SvnSandBox(this); Uri ReposUrl = sbox.CreateRepository(SandBoxRepository.AnkhSvnCases); string list = this.RunCommand("svn", "list -v " + ReposUrl); // clean out whitespace string[] entries = Regex.Split(list, @"\r\n"); //string[] entries = list.Trim().Split( '\n' ); Hashtable ht = new Hashtable(); foreach (string e in entries) { if (e != "") { Entry ent = new Entry(e); ht[ent.Path] = ent; } } Collection<SvnListEventArgs> apiList; SvnListArgs a = new SvnListArgs(); a.Depth = SvnDepth.Children; Assert.That(Client.GetList(new SvnUriTarget(ReposUrl, SvnRevision.Head), a, out apiList)); Assert.That(apiList.Count, Is.EqualTo(ht.Count), "Wrong number of entries returned"); foreach (SvnListEventArgs ent in apiList) { string path = ent.Path; if (path == "") break; // New in 1.4+ ; was not available in ankh tests, as svn_client_ls was used instead of svn_client_list if (ent.Entry.NodeKind == SvnNodeKind.Directory) path += "/"; Entry entry = (Entry)ht[path]; Assert.IsNotNull(entry, "No entry found for " + path); entry.Match(ent.Entry); } }
static void Main(string[] args) { if (args.Length != 1) { throw new InvalidOperationException("Specify directory at the command line"); } var lines = new List <Line>(); using (var client = new SvnClient()) { Collection <SvnListEventArgs> list; var listArgs = new SvnListArgs { Depth = SvnDepth.Infinity }; client.GetList(new SvnUriTarget(args[0]), listArgs, out list); foreach (var item in list) { string hashString = null; long length = 0; if (item.Entry.NodeKind == SvnNodeKind.File) { using (var stream = new MemoryStream()) { client.Write(item.Uri, stream); length = stream.Length; stream.Position = 0; using (var sha = new SHA1Managed()) { var hash = sha.ComputeHash(stream); hashString = BitConverter.ToString(hash).Replace("-", "").ToLower(); } } } lines.Add(new Line( item.Path, item.Entry.Revision, length, item.Entry.Author, item.Entry.Time, hashString )); } } lines.Sort((a, b) => String.Compare(a.Path, b.Path, StringComparison.InvariantCultureIgnoreCase)); using (var target = new StreamWriter("out.txt")) { target.WriteLine("Path\tRevision\tLength\tAuthor\tTime\tHash"); foreach (var line in lines) { target.WriteLine( new StringBuilder() .Append(line.Path) .Append('\t') .Append(line.Revision) .Append('\t') .Append(line.Length) .Append('\t') .Append(line.Author) .Append('\t') .Append(line.Time.ToString("yyyy-MM-dd hh:mm:ss")) .Append('\t') .Append(line.Hash) .ToString() ); } } }
public void List_ListDetails() { SvnSandBox sbox = new SvnSandBox(this); sbox.Create(SandBoxRepository.Default); string WcPath = sbox.Wc; Uri WcUri = sbox.Uri; using (SvnClient client = NewSvnClient(true, false)) { string oneFile = Path.Combine(WcPath, "LocalFileForTestList"); TouchFile(oneFile); client.Add(oneFile); SvnCommitResult ci; client.Commit(WcPath, out ci); SvnUpdateResult r; client.Update(WcPath, out r); Assert.That(r, Is.Not.Null); Assert.That(r.HasRevision); Assert.That(r.HasResultMap); Assert.That(r.Revision, Is.EqualTo(ci.Revision)); bool visited = false; SvnListArgs a = new SvnListArgs(); a.RetrieveEntries = SvnDirEntryItems.AllFieldsV15; client.List(new SvnPathTarget(WcPath), a, delegate(object sender, SvnListEventArgs e) { Assert.That(e.Entry, Is.Not.Null, "Entry set"); Assert.That(e.RepositoryRoot, Is.Null, "Only valid when listing a Uri"); if (e.Path == "LocalFileForTestList") { Assert.That(e.BasePath, Is.EqualTo("/trunk"), "Basepath"); Assert.That(e.Lock, Is.Null); Assert.That(e.Entry.Author, Is.EqualTo(Environment.UserName)); Assert.That(e.Entry.FileSize, Is.EqualTo(0)); Assert.That(e.Entry.NodeKind, Is.EqualTo(SvnNodeKind.File)); Assert.That(e.Entry.Revision, Is.EqualTo(ci.Revision)); Assert.That(e.Entry.Time, Is.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 5, 0))); visited = true; } }); Assert.That(visited, Is.True, "Visited is true"); visited = false; client.List(WcUri, a, delegate(object sender, SvnListEventArgs e) { Assert.That(e.Entry, Is.Not.Null, "Entry set"); if (e.Path == "LocalFileForTestList") { Assert.That(e.BasePath, Is.EqualTo("/trunk"), "Basepath"); Assert.That(e.Lock, Is.Null); Assert.That(e.Entry.Author, Is.EqualTo(Environment.UserName)); Assert.That(e.Entry.FileSize, Is.EqualTo(0)); Assert.That(e.Entry.NodeKind, Is.EqualTo(SvnNodeKind.File)); Assert.That(e.Entry.Revision, Is.EqualTo(ci.Revision)); Assert.That(e.Entry.Time, Is.GreaterThan(DateTime.UtcNow - new TimeSpan(0, 5, 0))); visited = true; } }); Assert.That(visited, Is.True, "Visited is true"); SvnWorkingCopyClient wcC = new SvnWorkingCopyClient(); SvnWorkingCopyState state; Assert.That(wcC.GetState(oneFile, out state)); Assert.That(state, Is.Not.Null); Assert.That(state.IsTextFile, Is.True); client.SetProperty(oneFile, "svn:mime-type", "application/binary"); Assert.That(wcC.GetState(oneFile, out state)); Assert.That(state, Is.Not.Null); Assert.That(state.IsTextFile, Is.False); } }
/// <summary> /// Returns a list of the contents of the directory /// </summary> /// <param name="svnTarget"></param> /// <returns></returns> public static Collection <SvnListEventArgs> FetchListing(SvnTarget svnTarget, SvnListArgs args = null) { args = args == null ? new SvnListArgs() : args; var result = new Collection <SvnListEventArgs>(); _client.Value.GetList(svnTarget, args, out result); return(result); }
internal void BrowseItem(Uri uri) { if (uri == null) { throw new ArgumentNullException("uri"); } if (DesignMode) { return; } Uri nUri = SvnTools.GetNormalizedUri(uri); if (_running.Contains(nUri)) { return; } _running.Add(nUri); if (_running.Count == 1) { OnRetrievingChanged(EventArgs.Empty); } AnkhAction d = delegate() { bool ok = false; try { SvnListArgs la = new SvnListArgs(); la.RetrieveEntries = RetrieveItems; la.RetrieveLocks = RetrieveLocks; la.Depth = SvnDepth.Children; la.ThrowOnError = false; Collection <SvnListEventArgs> items; using (SvnClient client = Context.GetService <ISvnClientPool>().GetClient()) { client.GetList(uri, la, out items); } AnkhAction addItems = (AnkhAction) delegate() { if (items != null && items.Count > 0) { bool first = true; foreach (SvnListEventArgs a in items) { if (first) { if (a.RepositoryRoot != null) { EnsureRoot(a.RepositoryRoot); } } AddItem(a, a.RepositoryRoot); first = false; } MaybeExpand(uri); } _running.Remove(nUri); if (_running.Count == 0) { OnRetrievingChanged(EventArgs.Empty); } }; if (IsHandleCreated) { BeginInvoke(addItems); } else { addItems(); } ok = true; } finally { if (!ok) { BeginInvoke((AnkhAction) delegate() { _running.Remove(nUri); if (_running.Count == 0) { OnRetrievingChanged(EventArgs.Empty); } }); } } }; d.BeginInvoke(null, null); }
static void Main(string[] args) { if (args.Length != 1) throw new InvalidOperationException("Specify directory at the command line"); var lines = new List<Line>(); using (var client = new SvnClient()) { Collection<SvnListEventArgs> list; var listArgs = new SvnListArgs { Depth = SvnDepth.Infinity }; client.GetList(new SvnUriTarget(args[0]), listArgs, out list); foreach (var item in list) { string hashString = null; long length = 0; if (item.Entry.NodeKind == SvnNodeKind.File) { using (var stream = new MemoryStream()) { client.Write(item.Uri, stream); length = stream.Length; stream.Position = 0; using (var sha = new SHA1Managed()) { var hash = sha.ComputeHash(stream); hashString = BitConverter.ToString(hash).Replace("-", "").ToLower(); } } } lines.Add(new Line( item.Path, item.Entry.Revision, length, item.Entry.Author, item.Entry.Time, hashString )); } } lines.Sort((a, b) => String.Compare(a.Path, b.Path, StringComparison.InvariantCultureIgnoreCase)); using (var target = new StreamWriter("out.txt")) { target.WriteLine("Path\tRevision\tLength\tAuthor\tTime\tHash"); foreach (var line in lines) { target.WriteLine( new StringBuilder() .Append(line.Path) .Append('\t') .Append(line.Revision) .Append('\t') .Append(line.Length) .Append('\t') .Append(line.Author) .Append('\t') .Append(line.Time.ToString("yyyy-MM-dd hh:mm:ss")) .Append('\t') .Append(line.Hash) .ToString() ); } } }