Permalink
Browse files

fix 15114 (status not refresh when switching providers), 14539 (typo)…

…, 14484 (only solution items, no project)
  • Loading branch information...
1 parent 6568518 commit 6fd2eb1e92fe29c8d9773ec50af87d0930b69f92 @yysun committed Jan 25, 2011
View
2 BasicSccProvider.Tests/GitFileStatusTrackerTest.cs
@@ -178,7 +178,7 @@ public void GetFileStatusTest()
tracker.Commit("test");
tracker.Refresh();
- Assert.AreEqual(GitFileStatus.Trackered, tracker.GetFileStatus(tempFile));
+ Assert.AreEqual(GitFileStatus.Tracked, tracker.GetFileStatus(tempFile));
File.WriteAllText(tempFile, "changed text");
tracker.Refresh();
View
11 BasicSccProvider.cs
@@ -50,6 +50,8 @@ namespace GitScc
[Guid("C4128D99-2000-41D1-A6C3-704E6C1A3DE2")]
public class BasicSccProvider : MsVsShell.Package, IOleCommandTarget
{
+ private SccOnIdleEvent _OnIdleEvent = new SccOnIdleEvent();
+
private List<GitFileStatusTracker> projects;
private SccProviderService sccService = null;
@@ -110,12 +112,21 @@ protected override void Initialize()
// If the package is to become active, this will also callback on OnActiveStateChange and the menu commands will be enabled
IVsRegisterScciProvider rscp = (IVsRegisterScciProvider)GetService(typeof(IVsRegisterScciProvider));
rscp.RegisterSourceControlProvider(GuidList.guidSccProvider);
+
+ _OnIdleEvent.RegisterForIdleTimeCallbacks(GetGlobalService(typeof(SOleComponentManager)) as IOleComponentManager);
+ _OnIdleEvent.OnIdleEvent += new OnIdleEvent(sccService.UpdateNodesGlyphs);
+
}
protected override void Dispose(bool disposing)
{
Trace.WriteLine(String.Format(CultureInfo.CurrentUICulture, "Entering Dispose() of: {0}", this.ToString()));
+ _OnIdleEvent.OnIdleEvent -= new OnIdleEvent(sccService.UpdateNodesGlyphs);
+ _OnIdleEvent.UnRegisterForIdleTimeCallbacks();
+
+ sccService.Dispose();
+
base.Dispose(disposing);
}
View
1 BasicSccProvider.csproj
@@ -89,6 +89,7 @@
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
+ <Compile Include="SccOnIdleEvent.cs" />
<Compile Include="SccProviderOptions.cs">
<SubType>Component</SubType>
</Compile>
View
2 GitFileStatus.cs
@@ -8,7 +8,7 @@ public enum GitFileStatus
{
NotControlled,
New,
- Trackered,
+ Tracked,
Modified,
Staged,
Removed,
View
2 GitFileStatusTracker.cs
@@ -124,7 +124,7 @@ private GitFileStatus GetFileStatusNoCache(string fileName)
}
if (treeEntry != null && treeEntry.Id.Equals(indexEntry.ObjectId))
{
- return GitFileStatus.Trackered;
+ return GitFileStatus.Tracked;
}
}
else // <-- index entry == null
View
77 SccOnIdleEvent.cs
@@ -0,0 +1,77 @@
+using System;
+using Microsoft.VisualStudio.OLE.Interop;
+using System.Runtime.InteropServices;
+
+namespace GitScc
+{
+ // ------------------------------------------------------------------------
+ // IOleComponent OnIdle trigger
+ // ------------------------------------------------------------------------
+ public delegate void OnIdleEvent();
+
+ class SccOnIdleEvent : IOleComponent
+ {
+ uint _wComponentID = 0;
+ IOleComponentManager _cmService = null;
+
+ public event OnIdleEvent OnIdleEvent;
+
+ public void RegisterForIdleTimeCallbacks(IOleComponentManager cmService)
+ {
+ _cmService = cmService;
+
+ if (_cmService != null)
+ {
+ OLECRINFO[] pcrinfo = new OLECRINFO[1];
+ pcrinfo[0].cbSize = (uint)Marshal.SizeOf(typeof(OLECRINFO));
+ pcrinfo[0].grfcrf = (uint)_OLECRF.olecrfNeedIdleTime |
+ (uint)_OLECRF.olecrfNeedPeriodicIdleTime;
+ pcrinfo[0].grfcadvf = (uint)_OLECADVF.olecadvfModal |
+ (uint)_OLECADVF.olecadvfRedrawOff |
+ (uint)_OLECADVF.olecadvfWarningsOff;
+ pcrinfo[0].uIdleTimeInterval = 100;
+
+ _cmService.FRegisterComponent(this, pcrinfo, out _wComponentID);
+ }
+ }
+
+ public void UnRegisterForIdleTimeCallbacks()
+ {
+ if (_cmService != null)
+ _cmService.FRevokeComponent(_wComponentID);
+ }
+
+ public virtual int FContinueMessageLoop(uint uReason, IntPtr pvLoopData, MSG[] pMsgPeeked)
+ { return 1; }
+
+ /// <summary>
+ /// Idle processing trigger method
+ /// </summary>
+ public virtual int FDoIdle(uint grfidlef)
+ {
+ if (OnIdleEvent != null)
+ OnIdleEvent();
+
+ return 0;
+ }
+
+ public virtual int FPreTranslateMessage(MSG[] pMsg)
+ { return 0; }
+ public virtual int FQueryTerminate(int fPromptUser)
+ { return 1; }
+ public virtual int FReserved1(uint dwReserved, uint message, IntPtr wParam, IntPtr lParam)
+ { return 0; }
+ public virtual IntPtr HwndGetWindow(uint dwWhich, uint dwReserved)
+ { return IntPtr.Zero; }
+ public virtual void OnActivationChange(IOleComponent pic, int fSameComponent, OLECRINFO[] pcrinfo, int fHostIsActivating, OLECHOSTINFO[] pchostinfo, uint dwReserved)
+ { ; }
+ public virtual void OnAppActivate(int fActive, uint dwOtherThreadID)
+ { ; }
+ public virtual void OnEnterState(uint uStateID, int fEnter)
+ { ; }
+ public virtual void OnLoseActivation()
+ { ; }
+ public virtual void Terminate()
+ { ; }
+ }
+}
View
80 SccProviderService.cs
@@ -149,7 +149,7 @@ public int GetSccGlyph([InAttribute] int cFiles, [InAttribute] string[] rgpszFul
switch (status)
{
- case GitFileStatus.Trackered:
+ case GitFileStatus.Tracked:
rgsiGlyphs[0] = VsStateIcon.STATEICON_CHECKEDIN;
break;
@@ -619,11 +619,6 @@ internal void OpenTracker()
{
monitorFolder = Path.GetDirectoryName(solutionFileName);
- //IVsHierarchy sol = (IVsHierarchy)_sccProvider.GetService(typeof(SVsSolution));
- //EnumHierarchyItems(sol, VSConstants.VSITEMID_ROOT, 0,
- // (h, id) => {if(id==VSConstants.VSITEMID_ROOT) AddProject(h);} //only add project nodes
- //);
-
GetLoadedControllableProjects().ForEach(h => AddProject(h as IVsHierarchy));
if (monitorFolder != lastMinotorFolder)
@@ -667,39 +662,24 @@ private void RemoveFolderMonitor()
#region IVsFileChangeEvents
- internal void Refresh()
- {
- Debug.WriteLine("==== Refresh Nodes");
-
- noRefresh = true;
- OpenTracker();
-
- //IVsHierarchy sol = (IVsHierarchy)_sccProvider.GetService(typeof(SVsSolution));
- //EnumHierarchyItems(sol as IVsHierarchy, VSConstants.VSITEMID_ROOT, 0,
- // (h, id) => processNodeFunc(h, id)
- //);
-
- RefreshNodesGlyphs();
-
- noRefresh = false;
- }
-
- private DateTime lastTimeDirChangeFired = DateTime.Now;
+ //private DateTime lastTimeDirChangeFired = DateTime.Now;
public int DirectoryChanged(string pszDirectory)
{
if (noRefresh) return VSConstants.S_OK;
- double delta = DateTime.Now.Subtract(lastTimeDirChangeFired).TotalMilliseconds;
- lastTimeDirChangeFired = DateTime.Now;
+ //double delta = DateTime.Now.Subtract(lastTimeDirChangeFired).TotalMilliseconds;
+ //lastTimeDirChangeFired = DateTime.Now;
//Debug.WriteLine("==== dir changed: " + Math.Floor(delta).ToString());
- if (delta > 1000)
- {
- System.Threading.Thread.Sleep(200);
- Debug.WriteLine("==== dir changed REFRESH: " + Math.Floor(delta).ToString());
- Refresh();
- }
+ //if (delta > 1000)
+ //{
+ // System.Threading.Thread.Sleep(200);
+ // Debug.WriteLine("==== dir changed REFRESH: " + Math.Floor(delta).ToString());
+ // Refresh();
+ //}
+
+ NodesGlyphsDirty = true;
return VSConstants.S_OK;
}
@@ -762,8 +742,6 @@ internal void UndoSelectedFile()
#region IVsUpdateSolutionEvents2 Members
- bool noRefresh = false;
-
public int OnActiveProjectCfgChange(IVsHierarchy pIVsHierarchy)
{
return VSConstants.S_OK;
@@ -912,6 +890,28 @@ private void SaveFileFromRepository(string fileName, string tempFile)
#endregion
#region new Refresh methods
+
+ bool noRefresh = false;
+ bool NodesGlyphsDirty = false;
+
+ internal void Refresh()
+ {
+ Debug.WriteLine("==== Refresh Nodes");
+ NodesGlyphsDirty = true;
+ }
+
+ public void UpdateNodesGlyphs()
+ {
+ if (NodesGlyphsDirty)
+ {
+ noRefresh = true;
+ OpenTracker();
+ RefreshNodesGlyphs();
+ noRefresh = false;
+ }
+ NodesGlyphsDirty = false;
+ }
+
public void RefreshNodesGlyphs()
{
var solHier = (IVsHierarchy)_sccProvider.GetService(typeof(SVsSolution));
@@ -921,14 +921,6 @@ public void RefreshNodesGlyphs()
// to reflect the controlled state
IList<VSITEMSELECTION> nodes = new List<VSITEMSELECTION>();
- {
- // add solution root item
- VSITEMSELECTION vsItem;
- vsItem.itemid = VSConstants.VSITEMID_ROOT;
- vsItem.pHier = solHier;// pHierarchy;
- nodes.Add(vsItem);
- }
-
// add project node items
foreach (IVsHierarchy hr in projectList)
{
@@ -955,9 +947,10 @@ public void RefreshNodesGlyphs()
public List<IVsSccProject2> GetLoadedControllableProjects()
{
var list = new List<IVsSccProject2>();
- // Hashtable mapHierarchies = new Hashtable();
IVsSolution sol = (IVsSolution) _sccProvider.GetService(typeof(SVsSolution));
+ list.Add(sol as IVsSccProject2);
+
Guid rguidEnumOnlyThisType = new Guid();
IEnumHierarchies ppenum = null;
ErrorHandler.ThrowOnFailure(sol.GetProjectEnum((uint)__VSENUMPROJFLAGS.EPF_LOADEDINSOLUTION, ref rguidEnumOnlyThisType, out ppenum));
@@ -1077,5 +1070,6 @@ internal void InitRepo()
[Tt]est[Rr]esult*"
);
}
+
}
}
View
2 source.extension.vsixmanifest
@@ -3,7 +3,7 @@
<Identifier Id="C4128D99-2000-41D1-A6C3-704E6C1A3DE2">
<Name>Git Source Control Provider</Name>
<Author>Yiyisun@hotmail.com</Author>
- <Version>0.6.0</Version>
+ <Version>0.6.1</Version>
<Description xml:space="preserve">Git Source Control Provider is a plug-in that integrates git with Visual Studio.</Description>
<Locale>1033</Locale>
<License>License.txt</License>

0 comments on commit 6fd2eb1

Please sign in to comment.