From 63051312d452219530ba0541bddd3b201fb54f98 Mon Sep 17 00:00:00 2001 From: "Joel W. Reed" Date: Wed, 15 Aug 2007 13:46:14 -0400 Subject: [PATCH] changesetview --- tools/tf/ChangesetView.cs | 61 +++++++++++++++++++++++++++++++++++++++------- tools/tf/ExploreCommand.cs | 10 +++++--- tools/tf/ExploreView.cs | 33 ++++++++++++++++--------- tools/tf/HistoryCommand.cs | 2 +- 4 files changed, 81 insertions(+), 25 deletions(-) diff --git a/tools/tf/ChangesetView.cs b/tools/tf/ChangesetView.cs index 9ab5827..17a04a7 100644 --- a/tools/tf/ChangesetView.cs +++ b/tools/tf/ChangesetView.cs @@ -1,26 +1,69 @@ using System; +using System.Collections; +using System.Collections.Generic; using System.Net; using Gtk; using Microsoft.TeamFoundation.Client; using Microsoft.TeamFoundation.VersionControl.Common; using Microsoft.TeamFoundation.VersionControl.Client; -public class ChangesetView : Gtk.TreeView +public class ChangesetView : Gtk.VPaned { - private Gtk.ListStore changeStore; + private Gtk.ListStore store; private Driver driver; - + Gtk.TextBuffer textBuffer; + Gtk.TreeView tree; + public ChangesetView(Driver driver) { this.driver = driver; - HeadersVisible = false; - AppendColumn ("", new Gtk.CellRendererText (), "text", 0); - TreeViewColumn fullPath = AppendColumn ("", new Gtk.CellRendererText (), "text", 0); - fullPath.Visible = false; + Gtk.TreeView tree = new Gtk.TreeView(); + tree.EnableGridLines = TreeViewGridLines.Vertical; + + tree.AppendColumn ("Id", new Gtk.CellRendererText (), "text", 0); + tree.AppendColumn ("Owner", new Gtk.CellRendererText (), "text", 1); + tree.AppendColumn ("Date", new Gtk.CellRendererText (), "text", 2); + tree.AppendColumn ("Comment", new Gtk.CellRendererText (), "text", 3); - changeStore = new Gtk.ListStore (typeof (string), typeof (string)); + store = new Gtk.ListStore (typeof(string), typeof(string), typeof(string), typeof(string)); + tree.Model = store; + tree.Selection.Changed += OnSelectionChanged; + Add1(tree); - Model = changeStore; + Gtk.TextView view = new Gtk.TextView (); + textBuffer = view.Buffer; + Add2(view); } + + void OnSelectionChanged (object o, EventArgs args) + { + TreeIter iter; + TreeModel model; + + if (!((TreeSelection)o).GetSelected (out model, out iter)) return; + + string cid = (string) model.GetValue (iter, 0); + textBuffer.Text = cid; + } + + public void Update(string path, int stopAfter) + { + store.Clear(); + + bool detailed = false; + IEnumerable changeSets = driver.VersionControlServer.QueryHistory(path, VersionSpec.Latest, 0, RecursionType.Full, null, + null, null, stopAfter, detailed, false, false); + + foreach (Changeset changeSet in changeSets) + { + store.AppendValues(changeSet.ChangesetId.ToString(), + changeSet.Owner, + changeSet.CreationDate.ToString("d"), + changeSet.Comment); + } + + // this would be nice be seems to cause a segfault + //tree.ColumnsAutosize(); + } } diff --git a/tools/tf/ExploreCommand.cs b/tools/tf/ExploreCommand.cs index 81ff6c4..6ec2687 100644 --- a/tools/tf/ExploreCommand.cs +++ b/tools/tf/ExploreCommand.cs @@ -42,18 +42,20 @@ class ExploreCommand : Command [Option("Version", "V", "version")] public string OptionVersion; + [Option("Limit the number of changesets shown", "", "stopafter")] + public int OptionStopAfter = -1; + public ExploreCommand(Driver driver, string[] args): base(driver, args) { } public override void Run() { - string path = Environment.CurrentDirectory; - if (Arguments.Length > 0) path = Arguments[0]; - if (!VersionControlPath.IsServerItem(path)) path = Path.GetFullPath(path); + int stopAfter = Settings.Current.GetAsInt("History.StopAfter"); + if (OptionStopAfter != -1) stopAfter = OptionStopAfter; Application.Init (); - new ExploreView (driver); + new ExploreView (driver, stopAfter); Application.Run (); } } diff --git a/tools/tf/ExploreView.cs b/tools/tf/ExploreView.cs index ed41cfa..57cfd61 100644 --- a/tools/tf/ExploreView.cs +++ b/tools/tf/ExploreView.cs @@ -5,9 +5,14 @@ public class ExploreView : Gtk.Window { private RepositoryView repositoryView; private ChangesetView changesetView; - - public ExploreView(Driver driver) : base ("Explore") + private int stopAfter; + private Driver driver; + + public ExploreView(Driver driver, int stopAfter) : base ("Explore") { + this.stopAfter = stopAfter; + this.driver = driver; + SetSizeRequest (800, 600); ScrolledWindow scrolledWindow = new ScrolledWindow(); @@ -19,18 +24,24 @@ public class ExploreView : Gtk.Window repositoryView = new RepositoryView (driver); hPaned.Add1(repositoryView); - VPaned vPaned = new VPaned (); - hPaned.Add2(vPaned); - changesetView = new ChangesetView (driver); - vPaned.Add1(changesetView); + hPaned.Add2(changesetView); - Gtk.TextView view = new Gtk.TextView (); - Gtk.TextBuffer buffer = view.Buffer; - buffer.Text = "Hello, this is some text"; - vPaned.Add2(view); - ShowAll (); + repositoryView.Selection.Changed += OnPathSelectionChanged; + } + + void OnPathSelectionChanged (object o, EventArgs args) + { + TreeIter iter; + TreeModel model; + + if (!((TreeSelection)o).GetSelected (out model, out iter)) return; + + string path = (string) model.GetValue (iter, 1); + //Console.WriteLine ("{0} was selected", path); + + changesetView.Update(path, stopAfter); } protected override bool OnDeleteEvent (Gdk.Event ev) diff --git a/tools/tf/HistoryCommand.cs b/tools/tf/HistoryCommand.cs index 69fa13e..72a6add 100644 --- a/tools/tf/HistoryCommand.cs +++ b/tools/tf/HistoryCommand.cs @@ -45,7 +45,7 @@ class HistoryCommand : Command [Option("Recursive", "R", "recursive")] public bool OptionRecursive = false; - [Option("Stop After", "", "stopafter")] + [Option("Limit the number of changesets shown", "", "stopafter")] public int OptionStopAfter = -1; public HistoryCommand(Driver driver, string[] args): base(driver, args) -- 2.11.4.GIT