Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

in-progress getting checkin to work, need to figure out why it wont m…

…ap the workspace
  • Loading branch information...
commit fbb1d8dfad09eb9457fe9da09ad088b0d5274e87 1 parent d67e985
@gburgett authored
View
2  GitTfs.VsCommon/TfsHelper.Common.cs
@@ -198,7 +198,7 @@ private ITfsChangeset BuildTfsChangeset(Changeset changeset, IGitTfsRemote remot
public void WithWorkspace(string localDirectory, IGitTfsRemote remote, IEnumerable<Tuple<string, string>> mappings, TfsChangesetInfo versionToFetch, Action<ITfsWorkspace> action)
{
Trace.WriteLine("Setting up a TFS workspace for multiple remotes");
- var folders = mappings.Select(x => new WorkingFolder(Path.Combine(localDirectory, x.Item1), x.Item2)).ToArray();
+ var folders = mappings.Select(x => new WorkingFolder(x.Item1, Path.Combine(localDirectory, x.Item2))).ToArray();
var workspace = GetWorkspace(folders);
try
{
View
14 GitTfs/Commands/Subtree.cs
@@ -129,23 +129,29 @@ public int DoAdd(string tfsUrl, string tfsRepositoryPath)
if (result == GitTfsExitCodes.OK)
{
-
var p = Prefix.Replace(" ", "\\ ");
+
+
+ long latest = Math.Max(owner.MaxChangesetId, remote.MaxChangesetId);
+ string msg = string.Format(GitTfsConstants.TfsCommitInfoFormat, owner.TfsUrl, owner.TfsRepositoryPath, latest);
+ msg = string.Format(@"Add '{0}/' from commit '{1}'
+
+{2}", Prefix, remote.MaxCommitHash, msg);
+
List<string> args = new List<string>(){"subtree", "add",
"--prefix=" + p,
+ string.Format("-m {0}", msg),
remote.RemoteRef
};
command(args);
//update the owner remote to point at the commit where the newly created subtree was merged.
var commit = _globals.Repository.GetCurrentCommit();
- owner.UpdateRef(commit, remote.MaxChangesetId);
+ owner.UpdateRef(commit, latest);
result = GitTfsExitCodes.OK;
}
-
-
return result;
View
8 GitTfs/Core/DerivedGitTfsRemote.cs
@@ -68,6 +68,14 @@ public string TfsRepositoryPath
set { throw new NotImplementedException(); }
}
+ public string[] TfsSubtreePaths
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ }
+
#region Equality
public override bool Equals(object obj)
View
2  GitTfs/Core/GitRepository.cs
@@ -310,7 +310,7 @@ private TfsChangesetInfo TryParseChangesetInfo(string gitTfsMetaInfo, string com
if (match.Success)
{
var commitInfo = _container.GetInstance<TfsChangesetInfo>();
- commitInfo.Remote = ReadTfsRemote(match.Groups["url"].Value, match.Groups["repository"].Value, includeStubRemotes);
+ commitInfo.Remote = ReadTfsRemote(match.Groups["url"].Value, match.Groups["repository"].Success ? match.Groups["repository"].Value : null, includeStubRemotes);
commitInfo.ChangesetId = Convert.ToInt32(match.Groups["changeset"].Value);
commitInfo.GitCommit = commit;
return commitInfo;
View
42 GitTfs/Core/GitTfsRemote.cs
@@ -79,6 +79,23 @@ public string TfsPassword
}
public string TfsRepositoryPath { get; set; }
+
+ /// <summary>
+ /// Gets the TFS server-side paths of all subtrees of this remote.
+ /// Valid if the remote has subtrees, which occurs when <see cref="TfsRepositoryPath"/> is null.
+ /// </summary>
+ public string[] TfsSubtreePaths
+ {
+ get
+ {
+ if (tfsSubtreePaths == null)
+ tfsSubtreePaths = globals.Repository.GetSubtrees(this).Select(x => x.TfsRepositoryPath).ToArray();
+
+ return tfsSubtreePaths;
+ }
+ }
+ private string[] tfsSubtreePaths = null;
+
public string IgnoreRegexExpression { get; set; }
public IGitRepository Repository { get; set; }
public ITfsHelper Tfs { get; set; }
@@ -185,8 +202,19 @@ private bool IsInDotGit(string path)
public string GetPathInGitRepo(string tfsPath)
{
if (tfsPath == null) return null;
- if (!tfsPath.StartsWith(TfsRepositoryPath, StringComparison.InvariantCultureIgnoreCase)) return null;
- tfsPath = tfsPath.Substring(TfsRepositoryPath.Length);
+
+ if (TfsRepositoryPath != null)
+ {
+ if (!tfsPath.StartsWith(TfsRepositoryPath, StringComparison.InvariantCultureIgnoreCase)) return null;
+ tfsPath = tfsPath.Substring(TfsRepositoryPath.Length);
+ }
+ else
+ {
+ var p = this.TfsSubtreePaths.FirstOrDefault(x => tfsPath.StartsWith(x, StringComparison.InvariantCultureIgnoreCase));
+ if (p == null) return null;
+ tfsPath = tfsPath.Substring(p.Length);
+ }
+
while (tfsPath.StartsWith("/"))
tfsPath = tfsPath.Substring(1);
return tfsPath;
@@ -535,7 +563,7 @@ private long CheckinTool(string head, TfsChangesetInfo parentChangeset, ITfsWork
private void PendChangesToWorkspace(string head, string parent, ITfsWorkspaceModifier workspace)
{
- using (var tidyWorkspace = new DirectoryTidier(workspace, Tfs.GetLatestChangeset(this).GetFullTree()))
+ using (var tidyWorkspace = new DirectoryTidier(workspace, GetLatestChangeset().GetFullTree()))
{
foreach (var change in Repository.GetChangedFiles(parent, head))
{
@@ -586,7 +614,13 @@ private long Checkin(string head, string parent, ITfsWorkspace workspace, Checki
public bool MatchesUrlAndRepositoryPath(string tfsUrl, string tfsRepositoryPath)
{
- return MatchesTfsUrl(tfsUrl) && TfsRepositoryPath != null && TfsRepositoryPath.Equals(tfsRepositoryPath, StringComparison.OrdinalIgnoreCase);
+ if(!MatchesTfsUrl(tfsUrl))
+ return false;
+
+ if(TfsRepositoryPath == null)
+ return tfsRepositoryPath == null;
+
+ return TfsRepositoryPath.Equals(tfsRepositoryPath, StringComparison.OrdinalIgnoreCase);
}
private bool MatchesTfsUrl(string tfsUrl)
View
5 GitTfs/Core/IGitTfsRemote.cs
@@ -12,6 +12,11 @@ public interface IGitTfsRemote
string Id { get; set; }
string TfsUrl { get; set; }
string TfsRepositoryPath { get; set; }
+ /// <summary>
+ /// Gets the TFS server-side paths of all subtrees of this remote.
+ /// Valid if the remote has subtrees, which occurs when <see cref="TfsRepositoryPath"/> is null.
+ /// </summary>
+ string[] TfsSubtreePaths { get; }
string IgnoreRegexExpression { get; set; }
bool Autotag { get; set; }
string TfsUsername { get; set; }
View
11 GitTfs/Core/TfsChangeset.cs
@@ -135,7 +135,16 @@ public IEnumerable<TfsTreeEntry> GetTree()
public IEnumerable<TfsTreeEntry> GetFullTree()
{
var treeInfo = Summary.Remote.Repository.GetObjects();
- var tfsItems = _changeset.VersionControlServer.GetItems(Summary.Remote.TfsRepositoryPath, _changeset.ChangesetId, TfsRecursionType.Full);
+
+ IItem[] tfsItems;
+ if(Summary.Remote.TfsRepositoryPath != null)
+ {
+ tfsItems = _changeset.VersionControlServer.GetItems(Summary.Remote.TfsRepositoryPath, _changeset.ChangesetId, TfsRecursionType.Full);
+ }
+ else
+ {
+ tfsItems = Summary.Remote.TfsSubtreePaths.SelectMany(x => _changeset.VersionControlServer.GetItems(x, _changeset.ChangesetId, TfsRecursionType.Full)).ToArray();
+ }
var tfsItemsWithGitPaths = tfsItems.Select(item => new { item, gitPath = GetPathInGitRepo(item.ServerItem, treeInfo) });
return tfsItemsWithGitPaths.Where(x => x.gitPath != null).Select(x => new TfsTreeEntry(x.gitPath, x.item));
}
View
1  GitTfs/Core/TfsWriter.cs
@@ -22,6 +22,7 @@ public int Write(string refToWrite, Func<TfsChangesetInfo, int> write)
var tfsParents = _globals.Repository.GetLastParentTfsCommits(refToWrite);
if (_globals.UserSpecifiedRemoteId != null)
tfsParents = tfsParents.Where(changeset => changeset.Remote.Id == _globals.UserSpecifiedRemoteId);
+
switch (tfsParents.Count())
{
case 1:
View
2  GitTfs/GitTfsConstants.cs
@@ -19,7 +19,7 @@ public static class GitTfsConstants
GitTfsPrefix +
"-id:\\s+" +
"\\[(?<url>.+)\\]" +
- "(?<repository>.+);" +
+ "(?<repository>.+)?;" +
"C(?<changeset>\\d+)" +
"\\s*$", RegexOptions.Multiline);
// e.g. git-tfs-work-item: 24 associate
Please sign in to comment.
Something went wrong with that request. Please try again.