當前位置: 首頁>>代碼示例>>C#>>正文


C# PatchManager.LoadPatch方法代碼示例

本文整理匯總了C#中PatchApply.PatchManager.LoadPatch方法的典型用法代碼示例。如果您正苦於以下問題:C# PatchManager.LoadPatch方法的具體用法?C# PatchManager.LoadPatch怎麽用?C# PatchManager.LoadPatch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在PatchApply.PatchManager的用法示例。


在下文中一共展示了PatchManager.LoadPatch方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestLoadPatch

        public void TestLoadPatch()
        {
            PatchManager manager = new PatchManager();

            PatchApply.Patch expectedPatch = new PatchApply.Patch();
            expectedPatch.Type = PatchApply.Patch.PatchType.ChangeFile;
            expectedPatch.Apply = true;
            expectedPatch.PatchHeader = "diff --git a/thisisatest.txt b/thisisatest.txt";
            expectedPatch.PatchIndex = "index 5e4dce2..5eb1e6f 100644";
            expectedPatch.FileNameA = "thisisatest.txt";
            expectedPatch.FileNameB = "thisisatest.txt";
            expectedPatch.AppendTextLine(expectedPatch.PatchHeader);
            expectedPatch.AppendTextLine(expectedPatch.PatchIndex);
            expectedPatch.AppendTextLine("--- a/thisisatest.txt");
            expectedPatch.AppendTextLine("+++ b/thisisatest.txt");
            expectedPatch.AppendTextLine("@@ -1,2 +1,2 @@");
            expectedPatch.AppendTextLine("iiiiii");
            expectedPatch.AppendTextLine("-asdkjaldskjlaksd");
            expectedPatch.AppendTextLine("+changed again");

            manager.LoadPatch(expectedPatch.Text, false, Encoding.Default);

            PatchApply.Patch createdPatch = manager.Patches.First();
            Assert.AreEqual(expectedPatch.Text, createdPatch.Text);
        }
開發者ID:Copro,項目名稱:gitextensionstest,代碼行數:25,代碼來源:PatchManagerTest.cs

示例2: TestCorrectlyLoadsTheRightNumberOfDiffsInAPatchFile

        public void TestCorrectlyLoadsTheRightNumberOfDiffsInAPatchFile()
        {
            var manager = new PatchManager();
            var testPatch = Encoding.UTF8.GetString(TestResource.TestPatch);
            manager.LoadPatch(testPatch, false);

            Assert.AreEqual(12, manager.Patches.Count);
        }
開發者ID:ultonis,項目名稱:gitextensions,代碼行數:8,代碼來源:PatchTest.cs

示例3: TestCorrectlyLoadsTheRightFilenamesInAPatchFile

        public void TestCorrectlyLoadsTheRightFilenamesInAPatchFile()
        {
            var manager = new PatchManager();
            var testPatch = Encoding.UTF8.GetString(TestResource.TestPatch);
            manager.LoadPatch(testPatch, false);

            Assert.AreEqual(12, manager.Patches.Select(p => p.FileNameA).Distinct().Count());
            Assert.AreEqual(12, manager.Patches.Select(p => p.FileNameB).Distinct().Count());
        }
開發者ID:ultonis,項目名稱:gitextensions,代碼行數:9,代碼來源:PatchTest.cs

示例4: TestCorrectlyLoadsTheRightTypeOfDiffsInAPatchFile

        public void TestCorrectlyLoadsTheRightTypeOfDiffsInAPatchFile()
        {
            var manager = new PatchManager();
            var testPatch = Encoding.UTF8.GetString(TestResource.TestPatch);
            manager.LoadPatch(testPatch, false);

            Assert.IsTrue(manager.Patches.Any(p => p.Type == Patch.PatchType.NewFile));
            Assert.IsTrue(manager.Patches.Any(p => p.Type == Patch.PatchType.ChangeFile));
            Assert.IsTrue(manager.Patches.Any(p => p.Type == Patch.PatchType.DeleteFile));
        }
開發者ID:ultonis,項目名稱:gitextensions,代碼行數:10,代碼來源:PatchTest.cs

示例5: GetStashedItems

        public static List<Patch> GetStashedItems(string stashName)
        {
            var patchManager = new PatchManager();
            patchManager.LoadPatch(RunCmd(Settings.GitCommand, "stash show -p " + stashName), false);

            return patchManager.Patches;
        }
開發者ID:avish,項目名稱:gitextensions,代碼行數:7,代碼來源:GitCommandsHelper.cs

示例6: GetSingleDiff

        public static Patch GetSingleDiff(string from, string to, string fileName, string oldFileName, string extraDiffArguments)
        {
            if (!string.IsNullOrEmpty(fileName))
                fileName = string.Concat("\"", FixPath(fileName), "\"");

            if (!string.IsNullOrEmpty(oldFileName))
                oldFileName = string.Concat("\"", FixPath(oldFileName), "\"");

            from = FixPath(from);
            to = FixPath(to);

            if (Settings.UsePatienceDiffAlgorithm)
                extraDiffArguments = string.Concat(extraDiffArguments, " --patience");

            var patchManager = new PatchManager();
            var arguments = string.Format("diff{0} -M -C \"{1}\" \"{2}\" -- {3} {4}", extraDiffArguments, to, from, fileName, oldFileName);
            patchManager.LoadPatch(RunCachableCmd(Settings.GitCommand, arguments), false);

            return patchManager.Patches.Count > 0 ? patchManager.Patches[0] : null;
        }
開發者ID:avish,項目名稱:gitextensions,代碼行數:20,代碼來源:GitCommandsHelper.cs

示例7: GetDiff

        public static List<Patch> GetDiff(string from, string to, string extraDiffArguments)
        {
            PatchManager patchManager = new PatchManager();
            patchManager.LoadPatch(GitCommands.RunCachableCmd(Settings.GitCommand, "diff" + extraDiffArguments + " \"" + from + "\" \"" + to + "\""), false);

            return patchManager.patches;
        }
開發者ID:Gitulf,項目名稱:gitextensions,代碼行數:7,代碼來源:GitCommands.cs

示例8: GetSingleDiff

        public static Patch GetSingleDiff(string from, string to, string filter, string extraDiffArguments)
        {
            filter = FixPath(filter);
            from = FixPath(from);
            to = FixPath(to);

            PatchManager patchManager = new PatchManager();
            patchManager.LoadPatch(GitCommands.RunCachableCmd(Settings.GitCommand, "diff" + extraDiffArguments + " \"" + to + "\" \"" + from + "\" -- \"" + filter + "\""), false);

            if (patchManager.patches.Count > 0)
                return patchManager.patches[0];

            return null;
        }
開發者ID:Gitulf,項目名稱:gitextensions,代碼行數:14,代碼來源:GitCommands.cs

示例9: GetSingleDiff

        public Patch GetSingleDiff(string @from, string to, string fileName, string oldFileName, string extraDiffArguments, Encoding encoding, bool cacheResult)
        {
            if (!string.IsNullOrEmpty(fileName))
            {
                fileName = fileName.ToPosixPath();
            }
            if (!string.IsNullOrEmpty(oldFileName))
            {
                oldFileName = oldFileName.ToPosixPath();
            }

            //fix refs slashes
            from = from.ToPosixPath();
            to = to.ToPosixPath();
            string commitRange = string.Empty;
            if (!to.IsNullOrEmpty())
                commitRange = "\"" + to + "\"";
            if (!from.IsNullOrEmpty())
                commitRange = string.Join(" ", commitRange, "\"" + from + "\"");

            if (AppSettings.UsePatienceDiffAlgorithm)
                extraDiffArguments = string.Concat(extraDiffArguments, " --patience");

            var patchManager = new PatchManager();
            var arguments = String.Format("diff {0} -M -C {1} -- {2} {3}", extraDiffArguments, commitRange,
                fileName.Quote(), oldFileName.Quote());
            string patch;
            if (cacheResult)
                patch = RunCacheableCmd(AppSettings.GitCommand, arguments, LosslessEncoding);
            else
                patch = RunCmd(AppSettings.GitCommand, arguments, LosslessEncoding);
            patchManager.LoadPatch(patch, false, encoding);

            return GetPatch(patchManager, fileName, oldFileName);
        }
開發者ID:pmiossec,項目名稱:gitextensions,代碼行數:35,代碼來源:GitModule.cs

示例10: GetSingleDiff

        public Patch GetSingleDiff(string @from, string to, string fileName, string oldFileName, string extraDiffArguments, Encoding encoding, bool cacheResult)
        {
            string fileA = null;
            string fileB = null;

            if (!string.IsNullOrEmpty(fileName))
            {
                fileB = fileName;
                fileName = string.Concat("\"", FixPath(fileName), "\"");
            }

            if (!string.IsNullOrEmpty(oldFileName))
            {
                fileA = oldFileName;
                oldFileName = string.Concat("\"", FixPath(oldFileName), "\"");
            }

            if (fileA.IsNullOrEmpty())
                fileA = fileB;
            else if (fileB.IsNullOrEmpty())
                fileB = fileA;

            from = FixPath(from);
            to = FixPath(to);
            string commitRange = string.Empty;
            if (!to.IsNullOrEmpty())
                commitRange = "\"" + to + "\"";
            if (!from.IsNullOrEmpty())
                commitRange = string.Join(" ", commitRange, "\"" + from + "\"");

            if (AppSettings.UsePatienceDiffAlgorithm)
                extraDiffArguments = string.Concat(extraDiffArguments, " --patience");

            var patchManager = new PatchManager();
            var arguments = String.Format("diff {0} -M -C {1} -- {2} {3}", extraDiffArguments, commitRange, fileName, oldFileName);
            string patch;
            if (cacheResult)
                patch = RunCacheableCmd(AppSettings.GitCommand, arguments, LosslessEncoding);
            else
                patch = RunCmd(AppSettings.GitCommand, arguments, LosslessEncoding);
            patchManager.LoadPatch(patch, false, encoding);

            foreach (Patch p in patchManager.Patches)
                if (p.FileNameA.Equals(fileA) && p.FileNameB.Equals(fileB) ||
                    p.FileNameA.Equals(fileB) && p.FileNameB.Equals(fileA))
                    return p;

            return patchManager.Patches.Count > 0 ? patchManager.Patches[patchManager.Patches.Count - 1] : null;
        }
開發者ID:saland,項目名稱:gitextensions,代碼行數:49,代碼來源:GitModule.cs

示例11: GetSingleDiff

        public static Patch GetSingleDiff(string from, string to, string filter)
        {
            filter = FixPath(filter);
            from = FixPath(from);
            to = FixPath(to);

            PatchManager patchManager = new PatchManager();
            patchManager.LoadPatch(GitCommands.RunCmd(Settings.GitDir + "git.cmd", "diff --ignore-submodules \"" + to + "\" \"" + from + "\" -- \"" + filter + "\""), false);

            if (patchManager.patches.Count > 0)
                return patchManager.patches[0];

            return null;
        }
開發者ID:MikeDSmith,項目名稱:gitextensions,代碼行數:14,代碼來源:GitCommands.cs

示例12: GetDiff

        public static List<Patch> GetDiff(string from, string to)
        {
            PatchManager patchManager = new PatchManager();
            patchManager.LoadPatch(GitCommands.RunCmd(Settings.GitDir + "git.cmd", "diff \"" + from + "\" \"" + to + "\""), false);

            return patchManager.patches;
        }
開發者ID:MikeDSmith,項目名稱:gitextensions,代碼行數:7,代碼來源:GitCommands.cs

示例13: GetStashedItems

        public static List<Patch> GetStashedItems(string stashName)
        {
            PatchManager patchManager = new PatchManager();
            patchManager.LoadPatch(GitCommands.RunCmd(Settings.GitDir + "git.cmd", "stash show -p " + stashName), false);

            return patchManager.patches;
        }
開發者ID:MikeDSmith,項目名稱:gitextensions,代碼行數:7,代碼來源:GitCommands.cs

示例14: GetSingleDiff

        public Patch GetSingleDiff(string @from, string to, string fileName, string oldFileName, string extraDiffArguments, Encoding encoding)
        {
            if (!string.IsNullOrEmpty(fileName))
                fileName = string.Concat("\"", FixPath(fileName), "\"");

            if (!string.IsNullOrEmpty(oldFileName))
                oldFileName = string.Concat("\"", FixPath(oldFileName), "\"");

            from = FixPath(from);
            to = FixPath(to);
            string commitRange = string.Empty;
            if (!to.IsNullOrEmpty())
                commitRange = "\"" + to + "\"";
            if (!from.IsNullOrEmpty())
                commitRange = commitRange.Join(" ", "\"" + from + "\"");

            if (Settings.UsePatienceDiffAlgorithm)
                extraDiffArguments = string.Concat(extraDiffArguments, " --patience");

            var patchManager = new PatchManager();
            var arguments = string.Format("diff {0} -M -C {1} -- {2} {3}", extraDiffArguments, commitRange, fileName, oldFileName);
            patchManager.LoadPatch(this.RunCachableCmd(Settings.GitCommand, arguments, Settings.LosslessEncoding), false, encoding);

            return patchManager.Patches.Count > 0 ? patchManager.Patches[patchManager.Patches.Count - 1] : null;
        }
開發者ID:byplayer,項目名稱:gitextensions,代碼行數:25,代碼來源:GitModule.cs

示例15: GetStashedItems

        public List<Patch> GetStashedItems(string stashName)
        {
            var patchManager = new PatchManager();
            patchManager.LoadPatch(RunGitCmd("stash show -p " + stashName), false);

            return patchManager.Patches;
        }
開發者ID:nitoyon,項目名稱:gitextensions,代碼行數:7,代碼來源:GitModule.cs


注:本文中的PatchApply.PatchManager.LoadPatch方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。