From f148ed5666191a500f96124582980c5801ee4df1 Mon Sep 17 00:00:00 2001 From: Joel Reed Date: Wed, 18 Jul 2007 13:57:15 -0400 Subject: [PATCH] honor.excludes.in.ls-files --- tools/tf/Command.cs | 9 ++++++++- tools/tf/LsFilesCommand.cs | 2 ++ tools/tf/OnlineCommand.cs | 12 ++++-------- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/tools/tf/Command.cs b/tools/tf/Command.cs index fd60212..0058522 100644 --- a/tools/tf/Command.cs +++ b/tools/tf/Command.cs @@ -40,6 +40,7 @@ abstract class Command : CommandOptions private static bool runningOnUnix = true; private string[] arguments; protected Driver driver; + private static Regex excludes; public string[] Arguments { @@ -50,6 +51,7 @@ abstract class Command : CommandOptions { int p = (int) Environment.OSVersion.Platform; if (!((p == 4) || (p == 128))) runningOnUnix = false; + excludes = WildcardToRegex(Settings.Current.Get("File.Excludes")); } public static StringComparer PathComparer @@ -197,7 +199,7 @@ abstract class Command : CommandOptions File.Delete(fullName); } - public Regex WildcardToRegex(string exclusionList) + static public Regex WildcardToRegex(string exclusionList) { string[] wildcards = exclusionList.Split(','); StringBuilder sb = new StringBuilder(); @@ -212,6 +214,11 @@ abstract class Command : CommandOptions return new Regex(sb.ToString()); } + public bool IsExcludedFile(string file) + { + return excludes.IsMatch(file); + } + public void ConfirmFilesSpecified() { if (Arguments.Length < 2) diff --git a/tools/tf/LsFilesCommand.cs b/tools/tf/LsFilesCommand.cs index 689bb9a..169317c 100644 --- a/tools/tf/LsFilesCommand.cs +++ b/tools/tf/LsFilesCommand.cs @@ -98,6 +98,8 @@ class LsFilesCommand : Command DirectoryInfo dir = new DirectoryInfo(itemPath); foreach (FileInfo file in dir.GetFiles("*", SearchOption.AllDirectories)) { + if (IsExcludedFile(file.Name)) continue; + bool isReadOnly = (FileAttributes.ReadOnly == (File.GetAttributes(file.FullName) & FileAttributes.ReadOnly)); if (!isReadOnly) Console.WriteLine(file.FullName); } diff --git a/tools/tf/OnlineCommand.cs b/tools/tf/OnlineCommand.cs index cb3f002..7f96be1 100644 --- a/tools/tf/OnlineCommand.cs +++ b/tools/tf/OnlineCommand.cs @@ -60,7 +60,6 @@ class OnlineCommand : Command private List deletedFiles = new List(); private Workspace workspace; private MD5CryptoServiceProvider md5 = new MD5CryptoServiceProvider(); - private Regex excludes; public OnlineCommand(Driver driver, string[] args): base(driver, args) { @@ -120,7 +119,7 @@ class OnlineCommand : Command foreach (string file in files.Keys) { // skip files we're not interested in here - if (excludes.IsMatch(file)) continue; + if (IsExcludedFile(file)) continue; if (!File.Exists(file)) continue; ProcessFile(itemList, file); @@ -133,7 +132,7 @@ class OnlineCommand : Command { // skip files that exist or we're not interested in if (files.ContainsKey(key)) continue; - if (excludes.IsMatch(key)) continue; + if (IsExcludedFile(key)) continue; Console.WriteLine("Deleted: " + key); deletedFiles.Add(key); @@ -186,7 +185,7 @@ class OnlineCommand : Command foreach (FileInfo file in localFiles) { // skip files we're not interested in - if (excludes.IsMatch(file.Name)) continue; + if (IsExcludedFile(file.Name)) continue; dirList.Add(file.FullName, true); ProcessFile(itemList, file.FullName); @@ -203,7 +202,7 @@ class OnlineCommand : Command { // skip files that exist or we're not interested in if (dirList.ContainsKey(key)) continue; - if (excludes.IsMatch(key)) continue; + if (IsExcludedFile(key)) continue; Console.WriteLine("Deleted: " + key); deletedFiles.Add(key); @@ -241,9 +240,6 @@ class OnlineCommand : Command OptionModified = OptionAdded = OptionDeleted = true; } - // should we ignore/exclude any thing? - excludes = WildcardToRegex(Settings.Current.Get("File.Excludes")); - Online(Arguments); if (OptionPreview) return; -- 2.11.4.GIT