示例#1
0
        public override void OnExecute(CommandEventArgs e)
        {
            IAnkhSolutionSettings ss = e.GetService<IAnkhSolutionSettings>();
            IAnkhDiffHandler diff = e.GetService<IAnkhDiffHandler>();

            AnkhPatchArgs args = new AnkhPatchArgs();
            args.ApplyTo = ss.ProjectRoot;

            using (OpenFileDialog ofd = new OpenFileDialog())
            {
                ofd.Filter = "Patch files( *.patch)|*.patch|Diff files (*.diff)|*.diff|" +
                    "Text files (*.txt)|*.txt|All files (*.*)|*";

                if (ofd.ShowDialog(e.Context.DialogOwner) != DialogResult.OK)
                    return;

                args.PatchFile = ofd.FileName;
            }

            diff.RunPatch(args);
        }
示例#2
0
            public Replacer(AnkhDiff context, AnkhDiffToolArgs args, DiffToolMode toolMode)
            {
                if (context == null)
                    throw new ArgumentNullException("context");
                else if (args == null)
                    throw new ArgumentNullException("args");

                _context = context;
                _toolArgs = args;
                _diffArgs = args as AnkhDiffArgs;
                _mergeArgs = args as AnkhMergeArgs;
                _patchArgs = args as AnkhPatchArgs;
                _toolMode = toolMode;
            }
示例#3
0
        public bool RunPatch(AnkhPatchArgs args)
        {
            if (args == null)
                throw new ArgumentNullException("args");
            else if (!args.Validate())
                throw new ArgumentException("Arguments not filled correctly", "args");

            string diffApp = GetPatchPath(args.Mode);

            if (string.IsNullOrEmpty(diffApp))
            {
                new AnkhMessageBox(Context).Show("Please specify a merge tool in Tools->Options->SourceControl->Subversion", "AnkhSVN - No visual merge tool is available");

                return false;
            }

            string program;
            string arguments;
            if (!Substitute(diffApp, args, DiffToolMode.Patch, out program, out arguments))
            {
                new AnkhMessageBox(Context).Show(string.Format("Can't find patch program '{0}'", program));
                return false;
            }

            Process p = new Process();
            p.StartInfo = new ProcessStartInfo(program, arguments);

            string applyTo = args.ApplyTo;

            DiffToolMonitor monitor = null;
            if (applyTo != null)
            {
                monitor = new DiffToolMonitor(Context, applyTo, true);

                p.EnableRaisingEvents = true;
                monitor.Register(p);
            }

            bool started = false;
            try
            {
                return started = p.Start();
            }
            finally
            {
                if (!started)
                {
                    if (monitor != null)
                        monitor.Dispose();
                }
            }
        }