From bde4fe1bc686a61f02487950cfaa0241c841e9aa Mon Sep 17 00:00:00 2001 From: Joel Reed Date: Mon, 25 Jun 2007 12:55:11 -0400 Subject: [PATCH] /added | /modified | /deleted options for online command --- ChangeLog | 3 +++ docs/tf.txt | 13 ++++++++++--- tools/tf/OnlineCommand.cs | 36 +++++++++++++++++++++++------------- tools/tf/Options.cs | 7 +++++-- 4 files changed, 41 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index f587d80..b9e78f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -13,6 +13,9 @@ separator so /usr/bin/patch is happy # Add Online.Recursive setting. Make default non-recursive to match standard MS client. + # Add /added, /modified, /deleted flags to Online command to show + just additions, just modifications, or just deletions respectively. + These flags may be combined. With no flags, all changes are shown. 2007-06-08 Joel Reed diff --git a/docs/tf.txt b/docs/tf.txt index ee20a66..219af45 100644 --- a/docs/tf.txt +++ b/docs/tf.txt @@ -89,12 +89,14 @@ COMMANDS server you've not yet fetched. To show those files as well, use "/old /all". This behavior may change in future releases, based on user feedback. -*online *:: +*online [ /added | /modified | /deleted | /preview ]*:: Finds all writable files and marks them as pending changes on the server. It also finds all unknown files and marks them as pending adds, missing files are marked as pending deletes. A great command to use if you apply - a patch to a tfs-managed tree and want to pend the changes to the server - for checkin. + a patch to a clean tfs-managed tree and want to pend the changes to the + server for checkin. The /added, /modified, /deleted flags can be used + to show just additions, just modifications, or just deletions respectively. + These flags may be combined. With no flags, all changes are shown. *perm *:: Show server permissions on a file. Command alias: permission. @@ -219,6 +221,11 @@ The TF client stores configuration settings in ~/.tf/TfClient.config. The TF client will automatically do recursive history queries when set to "true". IMHO, this is far more useful than the default behavior. +*Online.Recursive*:: + The TF client will automatically do a recursive online command when set + to "true". IMHO, this is far more useful than the default behavior for + clean trees. Not as helpful for trees littered with build output files. + WORKSPACE CACHE --------------- diff --git a/tools/tf/OnlineCommand.cs b/tools/tf/OnlineCommand.cs index 47acdcb..b7e656e 100644 --- a/tools/tf/OnlineCommand.cs +++ b/tools/tf/OnlineCommand.cs @@ -39,10 +39,10 @@ using Microsoft.TeamFoundation.VersionControl.Client; class OnlineCommand : Command { public OnlineCommand(string[] arguments, TfOptions options, - VersionControlServer vcs): + VersionControlServer vcs): base(arguments, options, vcs) - { - } + { + } public override void Run() { @@ -52,7 +52,7 @@ class OnlineCommand : Command path = Path.GetFullPath(Arguments[1]); } - char[] charsToTrim = { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar}; + char[] charsToTrim = { Path.DirectorySeparatorChar, Path.AltDirectorySeparatorChar}; string itemPath = path.TrimEnd(charsToTrim); Workspace workspace = GetWorkspaceFromCache(); @@ -73,6 +73,7 @@ class OnlineCommand : Command ItemSpec itemSpec = new ItemSpec(itemPath, rtype); ItemSet itemSet = VersionControlServer.GetItems(itemSpec, version, DeletedState.NonDeleted, ItemType.Any, true); + // get item list from TFS server Item[] items = itemSet.Items; SortedList itemList = new SortedList(PathComparer); @@ -98,8 +99,15 @@ class OnlineCommand : Command List editedFiles = new List(); List deletedFiles = new List(); + // should we ignore/exclude any thing? Regex excludes = WildcardToRegex(Settings.Current.Get("File.Excludes")); + // by default, if nothing specified we process all changes + if ((!Options.Modified) && (!Options.Deleted) && (!Options.Added)) + { + Options.Modified = Options.Added = Options.Deleted = true; + } + foreach (FileInfo file in localFiles) { // skip files we're not interested in @@ -108,12 +116,12 @@ class OnlineCommand : Command dirList.Add(file.FullName, true); bool isReadOnly = (FileAttributes.ReadOnly == (File.GetAttributes(file.FullName) & FileAttributes.ReadOnly)); - if (!itemList.ContainsKey(file.FullName)) + if (Options.Added && !itemList.ContainsKey(file.FullName)) { Console.WriteLine("Added: " + file.FullName); addedFiles.Add(file.FullName); } - else if (!isReadOnly) + else if (Options.Modified && !isReadOnly) { Console.WriteLine("Modified: " + file.FullName); editedFiles.Add(file.FullName); @@ -125,15 +133,17 @@ class OnlineCommand : Command dirList.Add(di.FullName, true); } - foreach (string key in itemList.Keys) + if (Options.Deleted) { - if (dirList.ContainsKey(key)) continue; - - // skip files we're not interested in - if (excludes.IsMatch(key)) continue; + foreach (string key in itemList.Keys) + { + // skip files that exist or we're not interested in + if (dirList.ContainsKey(key)) continue; + if (excludes.IsMatch(key)) continue; - Console.WriteLine("Deleted: " + key); - deletedFiles.Add(key); + Console.WriteLine("Deleted: " + key); + deletedFiles.Add(key); + } } if (Options.Preview) return; diff --git a/tools/tf/Options.cs b/tools/tf/Options.cs index 373efef..f1bd839 100644 --- a/tools/tf/Options.cs +++ b/tools/tf/Options.cs @@ -34,6 +34,9 @@ class TfOptions : Options { public string Domain; public string Username; + [Option("Look for added files.", "", "added")] + public bool Added = false; + [Option("Get all files, not just those out of date", "", "all")] public bool All = false; @@ -46,7 +49,7 @@ class TfOptions : Options { [Option("Computer name", "M", "computer")] public string Computer; - [Option("Deleted", "D", "deleted")] + [Option("Look for deleted files.", "D", "deleted")] public bool Deleted = false; [Option("Force operation", "P", "force")] @@ -64,7 +67,7 @@ class TfOptions : Options { [Option("Login name", "Y", "login")] public string Login; - [Option("Show modified files", "", "modified")] + [Option("Look for modified files.", "", "modified")] public bool Modified = false; [Option("Newname", "N", "newname")] -- 2.11.4.GIT