public LogEntry CopyTree(GitIndexInfo index) { var startTime = DateTime.Now; var itemsCopied = 0; var maxChangesetId = 0; var tfsTreeEntries = GetTree().ToArray(); if (tfsTreeEntries.Length == 0) { maxChangesetId = _changeset.ChangesetId; } else { foreach (var entry in tfsTreeEntries) { Add(entry.Item, entry.FullName, index); maxChangesetId = Math.Max(maxChangesetId, entry.Item.ChangesetId); itemsCopied++; if (DateTime.Now - startTime > TimeSpan.FromSeconds(30)) { _stdout.WriteLine("{0} objects created...", itemsCopied); startTime = DateTime.Now; } } } return MakeNewLogEntry(maxChangesetId == _changeset.ChangesetId ? _changeset : _tfs.GetChangeset(maxChangesetId)); }
private void Add(IItem item, string pathInGitRepo, GitIndexInfo index, ITfsWorkspace workspace) { if (item.DeletionId == 0) { index.Update(Mode.NewFile, pathInGitRepo, workspace.GetLocalPath(pathInGitRepo)); } }
private void Apply(IChange change, GitIndexInfo index, ITfsWorkspace workspace, IDictionary <string, GitObject> initialTree) { // If you make updates to a dir in TF, the changeset includes changes for all the children also, // and git doesn't really care if you add or delete empty dirs. if (change.Item.ItemType == TfsItemType.File) { var pathInGitRepo = GetPathInGitRepo(change.Item.ServerItem, workspace.Remote, initialTree); if (pathInGitRepo == null || Summary.Remote.ShouldSkip(pathInGitRepo)) { return; } if (change.ChangeType.IncludesOneOf(TfsChangeType.Rename)) { Rename(change, pathInGitRepo, index, workspace, initialTree); } else if (change.ChangeType.IncludesOneOf(TfsChangeType.Delete)) { Delete(pathInGitRepo, index, initialTree); } else { Update(change, pathInGitRepo, index, workspace, initialTree); } } }
public LogEntry CopyTree(GitIndexInfo index, ITfsWorkspace workspace) { var startTime = DateTime.Now; var itemsCopied = 0; var maxChangesetId = 0; var tfsTreeEntries = GetTree().ToArray(); if (tfsTreeEntries.Length == 0) { maxChangesetId = _changeset.ChangesetId; } else { workspace.Get(_changeset.ChangesetId); foreach (var entry in tfsTreeEntries) { Add(entry.Item, entry.FullName, index, workspace); maxChangesetId = Math.Max(maxChangesetId, entry.Item.ChangesetId); itemsCopied++; if (DateTime.Now - startTime > TimeSpan.FromSeconds(30)) { _stdout.WriteLine("{0} objects created...", itemsCopied); startTime = DateTime.Now; } } } return(MakeNewLogEntry(maxChangesetId == _changeset.ChangesetId ? _changeset : _tfs.GetChangeset(maxChangesetId))); }
private static int Do(TextWriter stdin, IGitRepository repository, Action <GitIndexInfo> action) { using (var indexInfo = new GitIndexInfo(stdin, repository)) { action(indexInfo); return(indexInfo.nr); } }
private void Delete(string pathInGitRepo, GitIndexInfo index, IDictionary <string, GitObject> initialTree) { if (initialTree.ContainsKey(pathInGitRepo)) { index.Remove(initialTree[pathInGitRepo].Path); Trace.WriteLine("\tD\t" + pathInGitRepo); } }
private void Delete(string pathInGitRepo, GitIndexInfo index, IDictionary<string, GitObject> initialTree) { if(initialTree.ContainsKey(pathInGitRepo)) { index.Remove(initialTree[pathInGitRepo].Path); Trace.WriteLine("\tD\t" + pathInGitRepo); } }
private static int Do(TextWriter stdin, IGitRepository repository, Action<GitIndexInfo> action) { using (var indexInfo = new GitIndexInfo(stdin, repository)) { action(indexInfo); return indexInfo.nr; } }
public LogEntry Apply(string lastCommit, GitIndexInfo index) { var initialTree = Summary.Remote.Repository.GetObjects(lastCommit); foreach (var change in Sort(_changeset.Changes)) { Apply(change, index, initialTree); } return MakeNewLogEntry(); }
public void Update(Change change, string pathInGitRepo, GitIndexInfo index, IDictionary<string, GitObject> initialTree) { using (var tempFile = new TemporaryFile()) { change.Item.DownloadFile(tempFile); index.Update(GetMode(change, initialTree, pathInGitRepo), UpdateDirectoryToMatchExtantCasing(pathInGitRepo, initialTree), tempFile); } }
public LogEntry Apply(string lastCommit, GitIndexInfo index) { var initialTree = Summary.Remote.Repository.GetObjects(lastCommit); foreach (var change in Sort(_changeset.Changes)) { Apply(change, index, initialTree); } return(MakeNewLogEntry()); }
private void Add(IItem item, string pathInGitRepo, GitIndexInfo index) { if (item.DeletionId == 0) { // Download the content directly into the git database as a blob: using (var temp = item.DownloadFile()) { index.Update(Mode.NewFile, pathInGitRepo, temp); } } }
private void ApplyAdds(Change change, GitIndexInfo index, IDictionary<string, GitObject> initialTree) { var pathInGitRepo = Summary.Remote.GetPathInGitRepo(change.Item.ServerItem); if (pathInGitRepo == null || Summary.Remote.ShouldSkip(pathInGitRepo)) return; if (change.ChangeType != ChangeType.Delete) { Update(change, pathInGitRepo, index, initialTree); } }
private void Add(IItem item, string pathInGitRepo, GitIndexInfo index) { if (item.DeletionId == 0) { using (var tempFile = new TemporaryFile()) { item.DownloadFile(tempFile); index.Update(Mode.NewFile, pathInGitRepo, tempFile); } } }
private void Add(IItem item, string pathInGitRepo, GitIndexInfo index) { if (item.DeletionId == 0) { // Download the content directly into the index as a blob: using (var stream = item.DownloadFile()) { index.Update(Mode.NewFile, pathInGitRepo, stream, item.ContentLength); } } }
private void Update(IChange change, string pathInGitRepo, GitIndexInfo index, ITfsWorkspace workspace, IDictionary <string, GitObject> initialTree) { if (change.Item.DeletionId == 0) { index.Update( GetMode(change, initialTree, pathInGitRepo), pathInGitRepo, workspace.GetLocalPath(pathInGitRepo) ); } }
private void Add(IItem item, string pathInGitRepo, GitIndexInfo index) { if(item.DeletionId == 0) { using(var tempFile = new TemporaryFile()) { item.DownloadFile(tempFile); index.Update(Mode.NewFile, pathInGitRepo, tempFile); } } }
private void Rename(IChange change, string pathInGitRepo, GitIndexInfo index, ITfsWorkspace workspace, IDictionary<string, GitObject> initialTree) { var oldPath = GetPathInGitRepo(GetPathBeforeRename(change.Item), initialTree); if (oldPath != null) { Delete(oldPath, index, initialTree); } if (!change.ChangeType.IncludesOneOf(TfsChangeType.Delete)) { Update(change, pathInGitRepo, index, workspace, initialTree); } }
private void Rename(IChange change, string pathInGitRepo, GitIndexInfo index, ITfsWorkspace workspace, IDictionary <string, GitObject> initialTree) { var oldPath = GetPathInGitRepo(GetPathBeforeRename(change.Item), workspace.Remote, initialTree); if (oldPath != null) { Delete(oldPath, index, initialTree); } if (!change.ChangeType.IncludesOneOf(TfsChangeType.Delete)) { Update(change, pathInGitRepo, index, workspace, initialTree); } }
private void Update(IChange change, string pathInGitRepo, GitIndexInfo index, IDictionary <string, GitObject> initialTree) { if (change.Item.DeletionId == 0) { using (var tempFile = new TemporaryFile()) { change.Item.DownloadFile(tempFile); index.Update(GetMode(change, initialTree, pathInGitRepo), pathInGitRepo, tempFile); } } }
private LogEntry CopyTree(string lastCommit, ITfsChangeset changeset) { LogEntry result = null; WithTemporaryIndex( () => GitIndexInfo.Do(Repository, index => result = changeset.CopyTree(index))); WithTemporaryIndex( () => result.Tree = Repository.CommandOneline("write-tree")); if (!String.IsNullOrEmpty(lastCommit)) { result.CommitParents.Add(lastCommit); } return(result); }
private LogEntry CopyTree(string lastCommit, ITfsChangeset changeset) { LogEntry result = null; WithTemporaryIndex(() => Tfs.WithWorkspace(WorkingDirectory, this, changeset.Summary, workspace => { GitIndexInfo.Do(Repository, index => result = changeset.CopyTree(index, workspace)); result.Tree = Repository.CommandOneline("write-tree"); })); if (!String.IsNullOrEmpty(lastCommit)) { result.CommitParents.Add(lastCommit); } return(result); }
private void Update(IChange change, string pathInGitRepo, GitIndexInfo index, IDictionary <string, GitObject> initialTree) { if (change.Item.DeletionId == 0) { using (var stream = change.Item.DownloadFile()) { index.Update( GetMode(change, initialTree, pathInGitRepo), pathInGitRepo, stream, change.Item.ContentLength ); } } }
private LogEntry Apply(string parent, ITfsChangeset changeset) { LogEntry result = null; WithTemporaryIndex(() => WithWorkspace(changeset.Summary, workspace => { AssertTemporaryIndexClean(parent); GitIndexInfo.Do(Repository, index => result = changeset.Apply(parent, index, workspace)); result.Tree = Repository.CommandOneline("write-tree"); })); if (!String.IsNullOrEmpty(parent)) { result.CommitParents.Add(parent); } return(result); }
public LogEntry CopyTree(GitIndexInfo index) { var maxChangesetId = 0; foreach(var item in changeset.VersionControlServer.GetItems(Summary.Remote.TfsRepositoryPath, changeset.ChangesetId, TfsRecursionType.Full)) { if (item.ItemType == TfsItemType.File) { var pathInGitRepo = Summary.Remote.GetPathInGitRepo(item.ServerItem); if (pathInGitRepo != null && !Summary.Remote.ShouldSkip(pathInGitRepo)) { Add(item, pathInGitRepo, index); maxChangesetId = Math.Max(maxChangesetId, item.ChangesetId); } } } return MakeNewLogEntry(tfs.GetChangeset(maxChangesetId)); }
public LogEntry CopyTree(GitIndexInfo index) { var startTime = DateTime.Now; var itemsCopied = 0; var maxChangesetId = 0; foreach (var entry in GetTree()) { Add(entry.Item, entry.FullName, index); maxChangesetId = Math.Max(maxChangesetId, entry.Item.ChangesetId); itemsCopied++; if(DateTime.Now - startTime > TimeSpan.FromSeconds(30)) { _stdout.WriteLine("" + itemsCopied + " objects created..."); startTime = DateTime.Now; } } return MakeNewLogEntry(maxChangesetId == _changeset.ChangesetId ? _changeset : _tfs.GetChangeset(maxChangesetId)); }
public LogEntry Apply(string lastCommit, GitIndexInfo index, TfsFailTracker failTracker) { var initialTree = Summary.Remote.Repository.GetObjects(lastCommit); // If you make updates to a dir in TF, the changeset includes changes for all the children also, // and git doesn't really care if you add or delete empty dirs. var fileChanges = changeset.Changes.Where(c => c.Item.ItemType == ItemType.File); foreach(var change in fileChanges) { ApplyDelete(change, index, initialTree, failTracker); } foreach (var change in fileChanges) { ApplyAdds(change, index, initialTree); } return MakeNewLogEntry(); }
public LogEntry CopyTree(GitIndexInfo index) { var startTime = DateTime.Now; var itemsCopied = 0; var maxChangesetId = 0; foreach (var entry in GetTree()) { Add(entry.Item, entry.FullName, index); maxChangesetId = Math.Max(maxChangesetId, entry.Item.ChangesetId); itemsCopied++; if (DateTime.Now - startTime > TimeSpan.FromSeconds(30)) { _stdout.WriteLine("" + itemsCopied + " objects created..."); startTime = DateTime.Now; } } return(MakeNewLogEntry(maxChangesetId == _changeset.ChangesetId ? _changeset : _tfs.GetChangeset(maxChangesetId))); }
private void Apply(IChange change, GitIndexInfo index, ITfsWorkspace workspace, IDictionary<string, GitObject> initialTree) { // If you make updates to a dir in TF, the changeset includes changes for all the children also, // and git doesn't really care if you add or delete empty dirs. if (change.Item.ItemType == TfsItemType.File) { var pathInGitRepo = GetPathInGitRepo(change.Item.ServerItem, initialTree); if (pathInGitRepo == null || Summary.Remote.ShouldSkip(pathInGitRepo)) return; if (change.ChangeType.IncludesOneOf(TfsChangeType.Rename)) { Rename(change, pathInGitRepo, index, workspace, initialTree); } else if (change.ChangeType.IncludesOneOf(TfsChangeType.Delete)) { Delete(pathInGitRepo, index, initialTree); } else { Update(change, pathInGitRepo, index, workspace, initialTree); } } }
private void Rename(Change change, string pathInGitRepo, GitIndexInfo index, IDictionary<string, GitObject> initialTree) { var oldPath = Summary.Remote.GetPathInGitRepo(GetPathBeforeRename(change.Item)); if (oldPath != null) { Delete(oldPath, index, initialTree); } if (!change.ChangeType.IncludesOneOf(ChangeType.Delete)) { Update(change, pathInGitRepo, index, initialTree); } }
private void Update(IChange change, string pathInGitRepo, GitIndexInfo index, ITfsWorkspace workspace, IDictionary<string, GitObject> initialTree) { if (change.Item.DeletionId == 0) { index.Update( GetMode(change, initialTree, pathInGitRepo), pathInGitRepo, workspace.GetLocalPath(pathInGitRepo) ); } }
private void Add(IItem item, string pathInGitRepo, GitIndexInfo index) { if(item.DeletionId == 0) { // Download the content directly into the index as a blob: using (var stream = item.DownloadFile()) { index.Update(Mode.NewFile, pathInGitRepo, stream, item.ContentLength); } } }
private void Update(IChange change, string pathInGitRepo, GitIndexInfo index, IDictionary<string, GitObject> initialTree) { if (change.Item.DeletionId == 0) { using (var temp = change.Item.DownloadFile()) { index.Update( GetMode(change, initialTree, pathInGitRepo), pathInGitRepo, temp ); } } }
void ApplyDelete(Change change, GitIndexInfo index, IDictionary<string, GitObject> initialTree, TfsFailTracker failTracker) { if (change.Item.DeletionId != 0) { string oldPath = null; try { oldPath = Summary.Remote.GetPathInGitRepo(GetPathBeforeRename(change.Item)); } catch (Exception e) { failTracker.TrackFailureLoadingChange(change.Item.ChangesetId, change.ChangeType, change.Item.ServerItem, "Unable to locate deleted item"); } if (oldPath != null) { Delete(oldPath, index, initialTree); } } }