public override SnapshotId CreateSnapshotFromFiles(IEnumerable <KeyValuePair <string, System.IO.FileInfo> > fileList, string comment) { if (IsChild) { throw new InvalidOperationException("Can't create new snapshots from child repository."); } // remove all the files from the index. var files = GitRepo.Index.Select(elt => elt.Path).ToArray(); foreach (var file in files) { GitRepo.Index.Remove(file, removeFromWorkingDirectory: false); } // add files back. int copiedFiles = 0; int totalFiles = 0; var stopWatch = System.Diagnostics.Stopwatch.StartNew(); foreach (var elt in fileList) { var workingDirPath = SafeCombinePath(RepositoryDirectory, elt.Key); // suppress logging after the first 25 files. var logCopy = copiedFiles < 25; // copy to working dir. // note TryCopy handles the case of copying a file on to itself as a noop. if (TryCopyFile(elt.Value.FullName, workingDirPath, logCopy)) { copiedFiles++; } GitRepo.Index.Stage(workingDirPath); totalFiles++; } stopWatch.Stop(); LogEvent.CopySummary(copiedFiles, totalFiles, stopWatch.ElapsedMilliseconds); var author = new Signature("nobody", "*****@*****.**", DateTimeOffset.UtcNow); // call commit this way to avoid need on global git state // probably should only do this if the global configuration is not set var commit = GitRepo.Commit(comment, author, author, false); var currId = new GitCommitId(commit.Id); var previousCommit = GetPreviousCommit(commit); if (previousCommit != null) { var previousId = new GitCommitId(previousCommit.Id); ProcessDeletionsBetweenSnapshot(previousId, currId, RepositoryDirectory); } return(new GitCommitId(commit.Id)); }
public override SnapshotId FromToken(string tok) { return(GitCommitId.FromToken(tok)); }
public override SnapshotId CreateSnapshotFromFiles(IEnumerable<KeyValuePair<string, System.IO.FileInfo>> fileList, string comment) { if (IsChild) { throw new InvalidOperationException("Can't create new snapshots from child repository."); } // remove all the files from the index. var files = GitRepo.Index.Select(elt => elt.Path).ToArray(); foreach (var file in files) { GitRepo.Index.Remove(file, removeFromWorkingDirectory: false); } // add files back. int copiedFiles = 0; int totalFiles = 0; var stopWatch = System.Diagnostics.Stopwatch.StartNew(); foreach (var elt in fileList) { var workingDirPath = SafeCombinePath(RepositoryDirectory, elt.Key); // suppress logging after the first 25 files. var logCopy = copiedFiles < 25; // copy to working dir. // note TryCopy handles the case of copying a file on to itself as a noop. if (TryCopyFile(elt.Value.FullName, workingDirPath, logCopy)) { copiedFiles++; } GitRepo.Index.Stage(workingDirPath); totalFiles++; } stopWatch.Stop(); LogEvent.CopySummary(copiedFiles, totalFiles, stopWatch.ElapsedMilliseconds); var author = new Signature("nobody", "*****@*****.**", DateTimeOffset.UtcNow); // call commit this way to avoid need on global git state // probably should only do this if the global configuration is not set var commit = GitRepo.Commit(comment, author, author, false); var currId = new GitCommitId(commit.Id); var previousCommit = GetPreviousCommit(commit); if (previousCommit != null) { var previousId = new GitCommitId(previousCommit.Id); ProcessDeletionsBetweenSnapshot(previousId, currId, RepositoryDirectory); } return new GitCommitId(commit.Id); }