Example #1
0
        private void LoadBlobPrefetchArgs(
            ITracer tracer,
            GVFSEnlistment enlistment,
            out string headCommitId,
            out List <string> filesList,
            out List <string> foldersList,
            out FileBasedDictionary <string, string> lastPrefetchArgs)
        {
            string error;

            if (!FileBasedDictionary <string, string> .TryCreate(
                    tracer,
                    Path.Combine(enlistment.DotGVFSRoot, "LastBlobPrefetch.dat"),
                    new PhysicalFileSystem(),
                    out lastPrefetchArgs,
                    out error))
            {
                tracer.RelatedWarning("Unable to load last prefetch args: " + error);
            }

            filesList   = new List <string>();
            foldersList = new List <string>();

            if (!BlobPrefetcher.TryLoadFileList(enlistment, this.Files, this.FilesListFile, filesList, readListFromStdIn: this.FilesFromStdIn, error: out error))
            {
                this.ReportErrorAndExit(tracer, error);
            }

            if (!BlobPrefetcher.TryLoadFolderList(enlistment, this.Folders, this.FoldersListFile, foldersList, readListFromStdIn: this.FoldersFromStdIn, error: out error))
            {
                this.ReportErrorAndExit(tracer, error);
            }

            GitProcess gitProcess = new GitProcess(enlistment);

            GitProcess.Result result = gitProcess.RevParse(GVFSConstants.DotGit.HeadName);
            if (result.ExitCodeIsFailure)
            {
                this.ReportErrorAndExit(tracer, result.Errors);
            }

            headCommitId = result.Output.Trim();
        }
Example #2
0
        private static FileBasedDictionary <string, string> CreateFileBasedDictionary(FileBasedDictionaryFileSystem fs, string initialContents)
        {
            fs.ExpectedFiles.Add(MockEntryFileName, new ReusableMemoryStream(initialContents));

            fs.ExpectedOpenFileStreams.Add(MockEntryFileName + ".tmp", new ReusableMemoryStream(string.Empty));
            fs.ExpectedOpenFileStreams.Add(MockEntryFileName, fs.ExpectedFiles[MockEntryFileName]);

            string error;
            FileBasedDictionary <string, string> dut;

            FileBasedDictionary <string, string> .TryCreate(null, MockEntryFileName, fs, out dut, out error).ShouldEqual(true, error);

            dut.ShouldNotBeNull();

            // FileBasedDictionary should only open a file stream to the non-tmp file when being created.  At all other times it should
            // write to a tmp file and overwrite the non-tmp file
            fs.ExpectedOpenFileStreams.Remove(MockEntryFileName);

            return(dut);
        }