Skip to content

Commit

Permalink
V 0.5.6 - support multiple repositories
Browse files Browse the repository at this point in the history
  • Loading branch information
yysun committed Jun 13, 2010
1 parent 4880268 commit 988025c
Show file tree
Hide file tree
Showing 7 changed files with 156 additions and 118 deletions.
4 changes: 2 additions & 2 deletions BasicSccProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace GitScc
[Guid("C4128D99-2000-41D1-A6C3-704E6C1A3DE2")]
public class BasicSccProvider : MsVsShell.Package, IOleCommandTarget
{
private List<GitProject> projects;
private List<GitFileStatusTracker> projects;
private SccProviderService sccService = null;

public BasicSccProvider()
Expand All @@ -62,7 +62,7 @@ protected override void Initialize()
Trace.WriteLine(String.Format(CultureInfo.CurrentUICulture, "Entering Initialize() of: {0}", this.ToString()));
base.Initialize();

projects = new List<GitProject>();
projects = new List<GitFileStatusTracker>();
sccService = new SccProviderService(this, projects);

((IServiceContainer)this).AddService(typeof(SccProviderService), sccService, true);
Expand Down
1 change: 0 additions & 1 deletion BasicSccProvider.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
</ItemGroup>
<ItemGroup>
<Compile Include="GitFileStatusTracker.cs" />
<Compile Include="GitProject.cs" />
<Compile Include="GitSccOptions.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="BasicSccProvider.cs" />
Expand Down
44 changes: 25 additions & 19 deletions GitFileStatusTracker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,27 @@

namespace GitScc
{
public class GitFileStatusTracker
public class GitFileStatusTracker : IDisposable
{
private string initFolder;

private Repository repository;
private Tree commitTree;
private GitIndex index;
private IgnoreHandler ignoreHandler;
//private IgnoreHandler ignoreHandler;

private Dictionary<string, GitFileStatus> cache;

public GitFileStatusTracker(string workingFolder)
{
this.initFolder = workingFolder;
cache = new Dictionary<string, GitFileStatus>();

this.initFolder = workingFolder;
Refresh();
}

public void Refresh()
{

Close();

cache.Clear();
if (!string.IsNullOrEmpty(initFolder))
{
try
Expand All @@ -43,24 +40,20 @@ public void Refresh()
var commit = repository.MapCommit(id);
this.commitTree = (commit != null ? commit.TreeEntry : new Tree(repository));
this.index = repository.Index;
this.index.Read();
this.ignoreHandler = new IgnoreHandler(repository);
this.index.RereadIfNecessary();
//this.ignoreHandler = new IgnoreHandler(repository);
//this.watcher = new FileSystemWatcher(this.repository.WorkingDirectory.FullName);
}
}
catch
catch(Exception ex)
{
}
}
}

public void Close()
public void Dispose()
{
cache.Clear();

if (this.repository != null) this.repository.Close();
this.repository = null;

}

public string GitWorkingDirectory
Expand Down Expand Up @@ -139,10 +132,11 @@ private GitFileStatus GetFileStatusNoCache(string fileName)
}
if (File.Exists(fileName))
{
if (this.ignoreHandler.IsIgnored(fileName))
{
return GitFileStatus.Ignored;
}
//remove the ingore check for better performance
//if (this.ignoreHandler.IsIgnored(fileName))
//{
// return GitFileStatus.Ignored;
//}

return GitFileStatus.New;
}
Expand Down Expand Up @@ -182,5 +176,17 @@ public string CurrentBranch
return this.HasGitRepository ? this.repository.getBranch() : "";
}
}

internal static string GetRepositoryDirectory(string folder)
{
var repository = Repository.Open(folder);
return repository == null ? null :
repository.WorkingDirectory.FullName;
}

public override string ToString()
{
return repository == null ? "[no repo]" : repository.WorkingDirectory.FullName;
}
}
}
4 changes: 3 additions & 1 deletion GitProject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ namespace GitScc
{
public class GitProject
{
public string ProjectDirectory { get; set; }
//public string ProjectDirectory { get; set; }
public GitFileStatusTracker Tracker { get; set; }
//public uint IVsHierarchyEventsCookie { get; set; }
//public IVsHierarchy Hierarchy { get; set; }
}
}
4 changes: 4 additions & 0 deletions PkgCmd.vsct
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,21 @@
<Buttons>
<Button guid="guidSccProviderCmdSet" id="icmdSccCommandGitBash" priority="0x0104" type="Button">
<Parent guid="guidSccProviderCmdSet" id="igrpSourceControlCommands"/>
<Icon guid="guidSccProviderImages" id="iconGitBash" />
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>
<CommandFlag>IconAndText</CommandFlag>
<Strings>
<ButtonText>Git Bash ...</ButtonText>
</Strings>
</Button>

<Button guid="guidSccProviderCmdSet" id="icmdSccCommandGitExtension" priority="0x0105" type="Button">
<Parent guid="guidSccProviderCmdSet" id="igrpSourceControlCommands"/>
<Icon guid="guidSccProviderImages" id="iconGitExt" />
<CommandFlag>DynamicVisibility</CommandFlag>
<CommandFlag>DefaultInvisible</CommandFlag>
<CommandFlag>IconAndText</CommandFlag>
<Strings>
<ButtonText>Git Extensions ...</ButtonText>
</Strings>
Expand Down
Loading

0 comments on commit 988025c

Please sign in to comment.