Skip to content
This repository
Browse code

improve performance: use git.exe to get changed files

  • Loading branch information...
commit d12ced4f39cf493aa4336be78ab7d2f77c3345aa 1 parent 6fcee77
Yiyi Sun authored November 08, 2011
5  BasicSccProvider.Tests/BasicSccProvider.Tests.csproj
@@ -84,6 +84,7 @@
84 84
     </CodeAnalysisDependentAssemblyPaths>
85 85
   </ItemGroup>
86 86
   <ItemGroup>
  87
+    <Compile Include="GetFileStatusTest.cs" />
87 88
     <Compile Include="GitFileStatusTrackerTest.cs" />
88 89
     <Compile Include="PackageTest.cs" />
89 90
     <Compile Include="Properties\AssemblyInfo.cs" />
@@ -102,6 +103,10 @@
102 103
       <Project>{E3BFF8B4-189C-496A-A817-7E8B31E22B91}</Project>
103 104
       <Name>NGit</Name>
104 105
     </ProjectReference>
  106
+    <ProjectReference Include="..\ngit\NSch\NSch.csproj">
  107
+      <Project>{A19E6F3F-A25B-4B01-8922-CF0CC35C781D}</Project>
  108
+      <Name>NSch</Name>
  109
+    </ProjectReference>
105 110
     <ProjectReference Include="..\ngit\Sharpen\Sharpen.csproj">
106 111
       <Project>{72944A6C-45FF-4EF8-B349-8C9CABF519D4}</Project>
107 112
       <Name>Sharpen</Name>
153  BasicSccProvider.Tests/GetFileStatusTest.cs
... ...
@@ -0,0 +1,153 @@
  1
+using System;
  2
+using System.IO;
  3
+using System.Linq;
  4
+using GitScc;
  5
+using Microsoft.VisualStudio.TestTools.UnitTesting;
  6
+using System.Collections.Generic;
  7
+using System.Diagnostics;
  8
+
  9
+namespace BasicSccProvider.Tests
  10
+{
  11
+    /// <summary>
  12
+    ///This is a test class for GitFileStatusTrackerTest and is intended
  13
+    ///to contain all GitFileStatusTrackerTest Unit Tests
  14
+    ///</summary>
  15
+    [TestClass()]
  16
+    public class GetFileStatusTest
  17
+    {
  18
+        protected string tempFolder;
  19
+        protected string tempFile;
  20
+        protected string[] lines;
  21
+
  22
+        public GetFileStatusTest()
  23
+        {
  24
+
  25
+        }
  26
+
  27
+        private TestContext testContextInstance;
  28
+
  29
+        /// <summary>
  30
+        ///Gets or sets the test context which provides
  31
+        ///information about and functionality for the current test run.
  32
+        ///</summary>
  33
+        public TestContext TestContext
  34
+        {
  35
+            get
  36
+            {
  37
+                return testContextInstance;
  38
+            }
  39
+            set
  40
+            {
  41
+                testContextInstance = value;
  42
+            }
  43
+        }
  44
+
  45
+        #region Additional test attributes
  46
+        // 
  47
+        //You can use the following additional attributes as you write your tests:
  48
+        //
  49
+        //Use ClassInitialize to run code before running the first test in the class
  50
+        //[ClassInitialize()]
  51
+        //public static void MyClassInitialize(TestContext testContext)
  52
+        //{
  53
+        //}
  54
+        //
  55
+        //Use ClassCleanup to run code after all tests in a class have run
  56
+        //[ClassCleanup()]
  57
+        //public static void MyClassCleanup()
  58
+        //{
  59
+        //}
  60
+        //
  61
+        //Use TestInitialize to run code before running each test
  62
+        //[TestInitialize()]
  63
+        //public void MyTestInitialize()
  64
+        //{
  65
+        //}
  66
+        //
  67
+        //Use TestCleanup to run code after each test has run
  68
+        //[TestCleanup()]
  69
+        //public void MyTestCleanup()
  70
+        //{
  71
+        //}
  72
+        //
  73
+        #endregion
  74
+
  75
+        /// <summary>
  76
+        ///A test for GetFileStatus
  77
+        ///</summary>
  78
+        [TestMethod()]
  79
+        public void GetFileStatusTest1()
  80
+        {
  81
+            var stopwatch = new Stopwatch();
  82
+
  83
+            string workingFolder = @"D:\Users\Public\My Projects Tryout\orchard-1.0.20\src";
  84
+            GitFileStatusTracker target = new GitFileStatusTracker(workingFolder);
  85
+            
  86
+            var list1 = new List<GitFileStatus>();
  87
+            var list2= new List<GitFileStatus>();
  88
+
  89
+            var list = target.GetChangedFiles();
  90
+            stopwatch.Start();
  91
+            foreach (var f in list)
  92
+            {
  93
+                list1.Add(target.GetFileStatusNoCache(f.FileName));
  94
+            }
  95
+            stopwatch.Stop();
  96
+            Debug.WriteLine(list.Count() + ":" + stopwatch.ElapsedMilliseconds);
  97
+
  98
+            stopwatch.Reset();
  99
+            stopwatch.Start();
  100
+            foreach (var f in list)
  101
+            {
  102
+                list2.Add(target.GetFileStatusNoCacheOld(f.FileName));
  103
+            }
  104
+            stopwatch.Stop();
  105
+            Debug.WriteLine(list.Count() + ":" + stopwatch.ElapsedMilliseconds);
  106
+
  107
+            for(int i=0; i<list1.Count; i++)
  108
+            {
  109
+                Assert.AreEqual(list1[i], list2[i]);
  110
+            }
  111
+        }
  112
+
  113
+        /// <summary>
  114
+        ///A test for GetChangedFiles
  115
+        ///2183:4123
  116
+        ///2183:28931
  117
+        ///2183:4361
  118
+        ///2183:8281
  119
+        ///</summary>
  120
+        [TestMethod()]
  121
+        public void GetChangedFilesTest1()
  122
+        {
  123
+            var stopwatch = new Stopwatch();
  124
+
  125
+            string workingFolder = @"D:\Users\Public\My Projects Tryout\orchard-1.0.20\src";
  126
+            GitFileStatusTracker target = new GitFileStatusTracker(workingFolder);
  127
+
  128
+            stopwatch.Start();
  129
+            var list = target.GetChangedFiles();
  130
+            stopwatch.Stop();
  131
+            Debug.WriteLine(list.Count() + ":" + stopwatch.ElapsedMilliseconds);
  132
+
  133
+            stopwatch.Reset();
  134
+            stopwatch.Start();
  135
+            var changes = target.ChangedFiles;
  136
+
  137
+            stopwatch.Stop();
  138
+            Debug.WriteLine(changes.Count() + ":" + stopwatch.ElapsedMilliseconds);
  139
+
  140
+            Assert.AreEqual(list.Count(), changes.Count());
  141
+
  142
+             GitBash.GitExePath = @"C:\Program Files (x86)\Git\bin\sh.exe";
  143
+            stopwatch.Reset();
  144
+            stopwatch.Start();
  145
+            GitBash.Run("status --porcelain -z --untracked-files", workingFolder);
  146
+
  147
+            stopwatch.Stop();
  148
+            Debug.WriteLine(stopwatch.ElapsedMilliseconds);
  149
+
  150
+        }
  151
+    }
  152
+
  153
+}
4  BasicSccProvider.Tests/GitFileStatusTrackerTest.cs
@@ -274,8 +274,8 @@ public GitFileStatusTrackerTest_WithSubFolder_UsingGitBash()
274 274
         {
275 275
             GitBash.GitExePath = @"C:\Program Files (x86)\Git\bin\sh.exe";
276 276
             tempFolder = Environment.CurrentDirectory + "\\" + Guid.NewGuid().ToString();
277  
-            Directory.CreateDirectory(Path.Combine(tempFolder, "folder 中文 čćšđžČĆŠĐŽ"));
278  
-            tempFile = Path.Combine(tempFolder, "folder 中文 čćšđžČĆŠĐŽ\\test");
  277
+            Directory.CreateDirectory(Path.Combine(tempFolder, "folder"));
  278
+            tempFile = Path.Combine(tempFolder, "folder\\test");
279 279
         }
280 280
     }
281 281
 }
1  BasicSccProvider.cs
@@ -309,6 +309,7 @@ public void SetOleCmdText(IntPtr pCmdText, string text)
309 309
 
310 310
         private void OnRefreshCommand(object sender, EventArgs e)
311 311
         {
  312
+            sccService.NoRefresh = false;
312 313
             sccService.Refresh();
313 314
         }
314 315
 
6  GitBash.cs
@@ -31,7 +31,7 @@ public static string Run(string args, string workingDirectory)
31 31
             if (string.IsNullOrWhiteSpace(gitExePath) || !File.Exists(gitExePath))
32 32
                 throw new Exception("Git Executable not found");
33 33
 
34  
-            Debug.WriteLine(string.Format("{2}>{0} {1}", gitExePath, args, workingDirectory));
  34
+            //Debug.WriteLine(string.Format("{2}>{0} {1}", gitExePath, args, workingDirectory));
35 35
 
36 36
             var pinfo = new ProcessStartInfo(gitExePath)
37 37
             {
@@ -49,11 +49,11 @@ public static string Run(string args, string workingDirectory)
49 49
                 string error = process.StandardError.ReadToEnd();
50 50
                 process.WaitForExit();
51 51
 
52  
-                Debug.WriteLine(output);
  52
+                //Debug.WriteLine(output);
53 53
 
54 54
                 if (!string.IsNullOrEmpty(error))
55 55
                 {
56  
-                    Debug.WriteLine("STDERR: " + error);
  56
+                    //Debug.WriteLine("STDERR: " + error);
57 57
                     throw new Exception(error);
58 58
                 }
59 59
                 return output;
2  GitFileStatus.cs
@@ -17,6 +17,8 @@ public enum GitFileStatus
17 17
         Deleted,
18 18
         MergeConflict,
19 19
         Ignored,
  20
+        Renamed,
  21
+        Copied
20 22
     }
21 23
 
22 24
     public class GitFile : INotifyPropertyChanged
190  GitFileStatusTracker.cs
@@ -457,23 +457,13 @@ public void UnStageFile(string fileName)
457 457
             if (!this.HasGitRepository) return;
458 458
 
459 459
             var fileNameRel = GetRelativeFileName(fileName);
460  
-            var head = repository.Resolve(Constants.HEAD);
461  
-
462  
-            Tree commitTree = null;
463 460
             TreeEntry treeEntry = null;
464  
-            if (head == null)
465  
-            {
466  
-                commitTree = new Tree(repository);
467  
-            }
468  
-            else
469  
-            {
470  
-                var revTree = new RevWalk(repository).ParseTree(head);
471  
-                var treeId = revTree.Id;
472  
-                commitTree = new Tree(repository, treeId, repository.Open(treeId).GetBytes());
473  
-                if(commitTree!=null) treeEntry = commitTree.FindBlobMember(fileNameRel);
474  
-            }
475  
-            var index = repository.GetIndex();
476  
-            index.RereadIfNecessary();
  461
+
  462
+            if (commitTree != null) treeEntry = commitTree.FindBlobMember(fileNameRel);
  463
+
  464
+            //var index = repository.GetIndex();
  465
+            //index.RereadIfNecessary();
  466
+
477 467
             index.Remove(repository.WorkTree, fileName);
478 468
 
479 469
             if (treeEntry != null)
@@ -483,7 +473,8 @@ public void UnStageFile(string fileName)
483 473
 
484 474
             index.Write();
485 475
 
486  
-            this.cache.Remove(GetCacheKey(fileName));
  476
+            //this.cache.Remove(GetCacheKey(fileName));
  477
+            this.changedFiles = null;
487 478
         }
488 479
 
489 480
         /// <summary>
@@ -493,8 +484,9 @@ public void UnStageFile(string fileName)
493 484
         public void StageFile(string fileName)
494 485
         {
495 486
             if (!this.HasGitRepository) return;
496  
-            var index = repository.GetIndex();
497  
-            index.RereadIfNecessary();
  487
+            //var index = repository.GetIndex();
  488
+            //index.RereadIfNecessary();
  489
+
498 490
             index.Remove(repository.WorkTree, fileName);
499 491
 
500 492
             if (File.Exists(fileName))
@@ -508,7 +500,8 @@ public void StageFile(string fileName)
508 500
                 index.Remove(repository.WorkTree, fileName);
509 501
             }
510 502
             index.Write();
511  
-            this.cache.Remove(GetCacheKey(fileName));
  503
+            //this.cache.Remove(GetCacheKey(fileName));
  504
+            this.changedFiles = null;
512 505
         }
513 506
 
514 507
         #region under research ...
@@ -716,40 +709,50 @@ public IEnumerable<GitFile> ChangedFiles
716 709
 
717 710
         public IList<GitFile> GetChangedFiles()
718 711
         {
719  
-            var list = new List<GitFile>();
720  
-
721  
-            var treeWalk = new TreeWalk(this.repository);
722  
-            treeWalk.Recursive = true;
723  
-            treeWalk.Filter = TreeFilter.ANY_DIFF;
724  
-
725  
-            var id = repository.Resolve(Constants.HEAD);
726  
-            if (id != null)
  712
+            if (GitBash.Exists)
727 713
             {
728  
-                treeWalk.AddTree(new RevWalk(repository).ParseTree(id));
  714
+                var output = GitBash.Run("status --porcelain -z --untracked-files", this.GitWorkingDirectory);
  715
+                return ParseGitStatus(output);
729 716
             }
730 717
             else
731 718
             {
732  
-                treeWalk.AddTree(new EmptyTreeIterator());
733  
-            }
  719
+                var list = new List<GitFile>();
734 720
 
735  
-            treeWalk.AddTree(new DirCacheIterator(this.repository.ReadDirCache()));
736  
-            treeWalk.AddTree(new FileTreeIterator(this.repository));
737  
-            var filters = new TreeFilter[] { new SkipWorkTreeFilter(INDEX), new IndexDiffFilter(INDEX, WORKDIR) };
738  
-            treeWalk.Filter = AndTreeFilter.Create(filters);
  721
+                var treeWalk = new TreeWalk(this.repository);
  722
+                treeWalk.Recursive = true;
  723
+                treeWalk.Filter = TreeFilter.ANY_DIFF;
739 724
 
740  
-            while (treeWalk.Next())
741  
-            {
742  
-                WorkingTreeIterator workingTreeIterator = treeWalk.GetTree<WorkingTreeIterator>(WORKDIR);
743  
-                if (workingTreeIterator.IsEntryIgnored()) continue;
744  
-                var fileName = GetFullPath(treeWalk.PathString);
745  
-                if (Directory.Exists(fileName)) continue; // this excludes sub modules
746  
-                list.Add(new GitFile
  725
+                var id = repository.Resolve(Constants.HEAD);
  726
+                if (id != null)
  727
+                {
  728
+                    treeWalk.AddTree(new RevWalk(repository).ParseTree(id));
  729
+                }
  730
+                else
747 731
                 {
748  
-                    FileName = GetRelativeFileName(fileName),
749  
-                    Status = GetFileStatus(treeWalk)
750  
-                });
  732
+                    treeWalk.AddTree(new EmptyTreeIterator());
  733
+                }
  734
+
  735
+                treeWalk.AddTree(new DirCacheIterator(this.repository.ReadDirCache()));
  736
+                treeWalk.AddTree(new FileTreeIterator(this.repository));
  737
+                var filters = new TreeFilter[] { new SkipWorkTreeFilter(INDEX), new IndexDiffFilter(INDEX, WORKDIR) };
  738
+                treeWalk.Filter = AndTreeFilter.Create(filters);
  739
+
  740
+                while (treeWalk.Next())
  741
+                {
  742
+                    WorkingTreeIterator workingTreeIterator = treeWalk.GetTree<WorkingTreeIterator>(WORKDIR);
  743
+                    if (workingTreeIterator.IsEntryIgnored()) continue;
  744
+                    var fileName = GetFullPath(treeWalk.PathString);
  745
+                    if (Directory.Exists(fileName)) continue; // this excludes sub modules
  746
+
  747
+                    var status = GetFileStatus(treeWalk);
  748
+                    list.Add(new GitFile
  749
+                    {
  750
+                        FileName = GetRelativeFileName(fileName),
  751
+                        Status = status
  752
+                    });
  753
+                }
  754
+                return list;
751 755
             }
752  
-            return list;
753 756
         } 
754 757
         #endregion
755 758
 
@@ -775,6 +778,101 @@ public RepositoryGraph RepositoryGraph
775 778
                 return repositoryGraph;
776 779
             }
777 780
         }
  781
+
  782
+        #region copied and modified from git extensions
  783
+        public IList<GitFile> ParseGitStatus(string statusString)
  784
+        {
  785
+            //Debug.WriteLine(statusString);
  786
+
  787
+            var list = new List<GitFile>();
  788
+            if (string.IsNullOrEmpty(statusString)) return list;
  789
+
  790
+            // trim warning messages
  791
+            var nl = new char[] { '\n', '\r' };
  792
+            string trimmedStatus = statusString.Trim(nl);
  793
+            int lastNewLinePos = trimmedStatus.LastIndexOfAny(nl);
  794
+            if (lastNewLinePos > 0)
  795
+            {
  796
+                int ind = trimmedStatus.LastIndexOf('\0');
  797
+                if (ind < lastNewLinePos) //Warning at end
  798
+                {
  799
+                    lastNewLinePos = trimmedStatus.IndexOfAny(nl, ind >= 0 ? ind : 0);
  800
+                    trimmedStatus = trimmedStatus.Substring(0, lastNewLinePos).Trim(nl);
  801
+                }
  802
+                else                                              //Warning at beginning
  803
+                    trimmedStatus = trimmedStatus.Substring(lastNewLinePos).Trim(nl);
  804
+            }
  805
+
  806
+
  807
+            //Split all files on '\0' (WE NEED ALL COMMANDS TO BE RUN WITH -z! THIS IS ALSO IMPORTANT FOR ENCODING ISSUES!)
  808
+            var files = trimmedStatus.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries);
  809
+            for (int n = 0; n < files.Length; n++)
  810
+            {
  811
+                if (string.IsNullOrEmpty(files[n]))
  812
+                    continue;
  813
+
  814
+                int splitIndex = files[n].IndexOfAny(new char[] { '\0', '\t', ' ' }, 1);
  815
+
  816
+                string status = string.Empty;
  817
+                string fileName = string.Empty;
  818
+
  819
+                if (splitIndex < 0)
  820
+                {
  821
+                    status = files[n];
  822
+                    fileName = files[n + 1];
  823
+                    n++;
  824
+                }
  825
+                else
  826
+                {
  827
+                    status = files[n].Substring(0, splitIndex);
  828
+                    fileName = files[n].Substring(splitIndex);
  829
+                }
  830
+
  831
+                //X shows the status of the index, and Y shows the status of the work tree
  832
+
  833
+                char x = status[0];
  834
+                char y = status.Length > 1 ? status[1] : ' ';
  835
+
  836
+                var gitFile = new GitFile { FileName = fileName.Trim() };
  837
+
  838
+                switch (x)
  839
+                {
  840
+                    case '?':
  841
+                        gitFile.Status = GitFileStatus.New;
  842
+                        break;
  843
+                    case '!':
  844
+                        gitFile.Status = GitFileStatus.Ignored;
  845
+                        break;
  846
+                    case ' ':
  847
+                        if (y == 'M') gitFile.Status = GitFileStatus.Modified;
  848
+                        else if (y == 'D') gitFile.Status = GitFileStatus.Deleted;
  849
+                        break;
  850
+                    case 'M':
  851
+                        gitFile.Status = GitFileStatus.Staged;
  852
+                        break;
  853
+                    case 'A':
  854
+                        gitFile.Status = GitFileStatus.Added;
  855
+                        break;
  856
+                    case 'D':
  857
+                        gitFile.Status = GitFileStatus.Removed;
  858
+                        break;
  859
+                    case 'R':
  860
+                        gitFile.Status = GitFileStatus.Renamed;
  861
+                        break;
  862
+                    case 'C':
  863
+                        gitFile.Status = GitFileStatus.Copied;
  864
+                        break;
  865
+
  866
+                    case 'U':
  867
+                        gitFile.Status = GitFileStatus.MergeConflict;
  868
+                        break;
  869
+                }
  870
+                list.Add(gitFile);
  871
+            }
  872
+            return list;
  873
+        }
  874
+
  875
+        #endregion
778 876
     }
779 877
 
780 878
     public abstract class Log
25  PendingChangesView.xaml.cs
@@ -22,6 +22,7 @@ namespace GitScc
22 22
     /// </summary>
23 23
     public partial class PendingChangesView : UserControl
24 24
     {
  25
+        private SccProviderService service;
25 26
         private GitFileStatusTracker tracker;
26 27
         private ToolWindowWithEditor toolWindow;
27 28
         private IVsTextView textView;
@@ -31,6 +32,7 @@ public PendingChangesView(ToolWindowWithEditor toolWindow)
31 32
         {
32 33
             InitializeComponent();
33 34
             this.toolWindow = toolWindow;
  35
+            this.service = BasicSccProvider.GetServiceEx<SccProviderService>();
34 36
         }
35 37
 
36 38
         #region Events
@@ -69,7 +71,7 @@ private void dataGrid1_SelectionChanged(object sender, SelectionChangedEventArgs
69 71
                 return;
70 72
             }
71 73
 
72  
-            var dispatcher = Dispatcher.CurrentDispatcher;
  74
+            //var dispatcher = Dispatcher.CurrentDispatcher;
73 75
             Action act = () =>
74 76
             {
75 77
                 try
@@ -92,7 +94,7 @@ private void dataGrid1_SelectionChanged(object sender, SelectionChangedEventArgs
92 94
 
93 95
             };
94 96
 
95  
-            dispatcher.BeginInvoke(act, DispatcherPriority.ApplicationIdle);
  97
+            this.Dispatcher.BeginInvoke(act, DispatcherPriority.ApplicationIdle);
96 98
         }
97 99
 
98 100
         private void dataGrid1_MouseDoubleClick(object sender, MouseButtonEventArgs e)
@@ -153,8 +155,10 @@ internal void Refresh(GitFileStatusTracker tracker)
153 155
             this.tracker = tracker;
154 156
             if (tracker == null)
155 157
             {
  158
+                service.NoRefresh = true;
156 159
                 this.dataGrid1.ItemsSource = null;
157 160
                 ClearUI();
  161
+                service.NoRefresh = false;
158 162
                 return;
159 163
             }
160 164
 
@@ -166,6 +170,8 @@ internal void Refresh(GitFileStatusTracker tracker)
166 170
             var dispatcher = Dispatcher.CurrentDispatcher;
167 171
             Action act = () =>
168 172
             {
  173
+                service.NoRefresh = true;
  174
+
169 175
                 Stopwatch stopwatch = new Stopwatch();
170 176
                 stopwatch.Start();
171 177
 
@@ -187,6 +193,9 @@ internal void Refresh(GitFileStatusTracker tracker)
187 193
 
188 194
                 stopwatch.Stop();
189 195
                 Debug.WriteLine("**** PendingChangesView Refresh: " + stopwatch.ElapsedMilliseconds);
  196
+
  197
+                service.NoRefresh = false;
  198
+                service.lastTimeRefresh = DateTime.Now; //important!!
190 199
             };
191 200
 
192 201
             dispatcher.BeginInvoke(act, DispatcherPriority.ApplicationIdle);
@@ -238,10 +247,14 @@ internal void Commit()
238 247
             {
239 248
                 try
240 249
                 {
  250
+                    service.NoRefresh = true;
241 251
                     ShowStatusMessage("Committing ...");
242 252
                     var id = tracker.Commit(Comments);
243 253
                     ShowStatusMessage("Commit successfully. Commit Hash: " + id);
244 254
                     ClearUI();
  255
+                    service.NoRefresh = false;
  256
+                    service.lastTimeRefresh = DateTime.Now;
  257
+                    service.NodesGlyphsDirty = true;
245 258
                 }
246 259
                 catch (Exception ex)
247 260
                 {
@@ -264,11 +277,14 @@ internal void AmendCommit()
264 277
                 {
265 278
                     try
266 279
                     {
  280
+                        service.NoRefresh = true;
267 281
                         ShowStatusMessage("Amending last Commit ...");
268 282
                         var id = tracker.AmendCommit(Comments);
269 283
                         ShowStatusMessage("Amend last commit successfully. Commit Hash: " + id);
270 284
                         ClearUI();
271  
-
  285
+                        service.NoRefresh = false;
  286
+                        service.lastTimeRefresh = DateTime.Now;
  287
+                        service.NodesGlyphsDirty = true;
272 288
                     }
273 289
                     catch (Exception ex)
274 290
                     {
@@ -283,10 +299,11 @@ private bool StageSelectedFiles()
283 299
         {
284 300
             foreach (var item in this.dataGrid1.Items.Cast<GitFile>())
285 301
             {
286  
-                //var item = (GitFile) _item;
287 302
                 if (item.IsSelected && !item.IsStaged)
288 303
                 {
289 304
                     tracker.StageFile(System.IO.Path.Combine(this.tracker.GitWorkingDirectory, item.FileName));
  305
+                    ShowStatusMessage("Staged :" + item.FileName);
  306
+                    service.lastTimeRefresh = DateTime.Now;
290 307
                 }
291 308
             }
292 309
 
54  SccProviderService.cs
@@ -788,7 +788,7 @@ public int UpdateProjectCfg_Done(IVsHierarchy pHierProj, IVsCfg pCfgProj, IVsCfg
788 788
         public int UpdateSolution_Begin(ref int pfCancelUpdate)
789 789
         {
790 790
             Debug.WriteLine("Git Source Control Provider: suppress refresh before build...");
791  
-            noRefresh = true;
  791
+            NoRefresh = true;
792 792
             return VSConstants.S_OK;
793 793
         }
794 794
 
@@ -800,7 +800,7 @@ public int UpdateSolution_Cancel()
800 800
         public int UpdateSolution_Done(int fSucceeded, int fModified, int fCancelCommand)
801 801
         {
802 802
             Debug.WriteLine("Git Source Control Provider: resume refresh after build...");
803  
-            noRefresh = false;
  803
+            NoRefresh = false;
804 804
             return VSConstants.S_OK;
805 805
         }
806 806
 
@@ -819,7 +819,7 @@ private void AddProject(IVsHierarchy pHierarchy)
819 819
             if (string.IsNullOrEmpty(projectName)) return;
820 820
             string projectDirecotry = Path.GetDirectoryName(projectName);
821 821
 
822  
-            Debug.WriteLine("==== Adding project: " + projectDirecotry);
  822
+            //Debug.WriteLine("==== Adding project: " + projectDirecotry);
823 823
 
824 824
             string gitfolder = GitFileStatusTracker.GetRepositoryDirectory(projectDirecotry);
825 825
 
@@ -830,7 +830,7 @@ private void AddProject(IVsHierarchy pHierarchy)
830 830
             if (gitfolder.Length < monitorFolder.Length) monitorFolder = gitfolder;
831 831
             trackers.Add(new GitFileStatusTracker(gitfolder));
832 832
             
833  
-            Debug.WriteLine("==== Added git tracker: " + gitfolder);
  833
+            //Debug.WriteLine("==== Added git tracker: " + gitfolder);
834 834
            
835 835
         }
836 836
 
@@ -919,35 +919,43 @@ private void SaveFileFromRepository(string fileName, string tempFile)
919 919
 
920 920
         #region new Refresh methods
921 921
 
922  
-        bool noRefresh = false;
923  
-        bool NodesGlyphsDirty = false;
924  
-        
925  
-        private DateTime lastTimeRefresh = DateTime.Now;
  922
+        internal bool NodesGlyphsDirty = false;
  923
+        internal bool NoRefresh = false;
  924
+        internal DateTime lastTimeRefresh = DateTime.Now;
926 925
 
927 926
         internal void Refresh()
928 927
         {
929  
-            if (!noRefresh)
  928
+            if (!NoRefresh)
930 929
             {
931  
-                NodesGlyphsDirty = true;
932  
-                lastTimeRefresh = DateTime.Now;
  930
+                double delta = DateTime.Now.Subtract(lastTimeRefresh).TotalMilliseconds;
  931
+                if (delta > 500)
  932
+                {
  933
+                    Debug.WriteLine("==== Refresh: " + Math.Floor(delta).ToString());
  934
+                    NodesGlyphsDirty = true;
  935
+                }
933 936
             }
  937
+            lastTimeRefresh = DateTime.Now;
934 938
         }
935 939
 
936 940
         public void UpdateNodesGlyphs()
937 941
         {
938  
-            if (NodesGlyphsDirty && !noRefresh)
  942
+            if (NodesGlyphsDirty && !NoRefresh)
939 943
             {
940  
-                double delta = DateTime.Now.Subtract(lastTimeRefresh).TotalMilliseconds;
941  
-                if (delta > 500)
942  
-                {
943  
-                    Debug.WriteLine("==== Refresh: " + Math.Floor(delta).ToString());
944  
-                    noRefresh = true;
945  
-                    OpenTracker();
946  
-                    RefreshNodesGlyphs();
947  
-                    RefreshToolWindows();
948  
-                    noRefresh = false;
949  
-                    NodesGlyphsDirty = false;
950  
-                }
  944
+                Stopwatch stopwatch = new Stopwatch();
  945
+                stopwatch.Start();
  946
+
  947
+                NoRefresh = true;
  948
+                OpenTracker();
  949
+                RefreshNodesGlyphs();
  950
+                RefreshToolWindows();
  951
+
  952
+                //noRefresh = false;
  953
+                NodesGlyphsDirty = false;
  954
+
  955
+                stopwatch.Stop();
  956
+                Debug.WriteLine("==== UpdateNodesGlyphs: " + stopwatch.ElapsedMilliseconds);
  957
+
  958
+                lastTimeRefresh = DateTime.Now; //important !!
951 959
             }
952 960
         }
953 961
 
10  UI/HistoryGraph.xaml.cs
@@ -24,10 +24,12 @@ namespace GitScc.UI
24 24
     /// </summary>
25 25
     public partial class HistoryGraph : UserControl
26 26
     {
  27
+        private SccProviderService service;
27 28
 
28 29
         public HistoryGraph()
29 30
         {
30 31
             InitializeComponent();
  32
+            this.service = BasicSccProvider.GetServiceEx<SccProviderService>();
31 33
         }
32 34
 
33 35
         #region zoom upon mouse wheel
@@ -118,8 +120,9 @@ internal void Show(GitFileStatusTracker tracker)
118 120
         {
119 121
             this.tracker = tracker;
120 122
 
121  
-            loading.Visibility = Visibility.Visible;            
  123
+            loading.Visibility = Visibility.Visible;
122 124
             
  125
+            var dispatcher = Dispatcher.CurrentDispatcher;
123 126
             Action act = () =>
124 127
             {
125 128
                 Stopwatch stopwatch = new Stopwatch();
@@ -342,9 +345,12 @@ internal void Show(GitFileStatusTracker tracker)
342 345
                 stopwatch.Stop();
343 346
                 Debug.WriteLine("**** HistoryGraph Refresh: " + stopwatch.ElapsedMilliseconds);
344 347
 
  348
+                service.NoRefresh = false;
  349
+                service.lastTimeRefresh = DateTime.Now; //important!!
  350
+
345 351
             };
346 352
 
347  
-            this.Dispatcher.BeginInvoke(act, DispatcherPriority.ApplicationIdle);
  353
+            dispatcher.BeginInvoke(act, DispatcherPriority.ApplicationIdle);
348 354
         }
349 355
 
350 356
         private string GetHashCode(IList<GraphNode> commits)
2  source.extension.vsixmanifest
@@ -3,7 +3,7 @@
3 3
   <Identifier Id="C4128D99-2000-41D1-A6C3-704E6C1A3DE2">
4 4
     <Name>Git Source Control Provider</Name>
5 5
     <Author>Yiyisun@hotmail.com</Author>
6  
-    <Version>0.8.7</Version>
  6
+    <Version>0.8.8</Version>
7 7
     <Description xml:space="preserve">Git Source Control Provider is a plug-in that integrates git with Visual Studio.</Description>
8 8
     <Locale>1033</Locale>
9 9
     <License>License.txt</License>

0 notes on commit d12ced4

Please sign in to comment.
Something went wrong with that request. Please try again.