Ejemplo n.º 1
0
        public bool RunDiff(AnkhDiffArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            else if (!args.Validate())
            {
                throw new ArgumentException("Arguments not filled correctly", "args");
            }

            SetFloat(args);

            string diffApp = this.GetDiffPath(args.Mode, args.MineFile);

            if (string.IsNullOrEmpty(diffApp))
            {
                IAnkhInternalDiff internalDiff = GetService <IAnkhInternalDiff>();

                if (internalDiff == null || !internalDiff.HasDiff)
                {
                    throw new InvalidOperationException("Internal diff not available");
                }

                return(internalDiff.RunDiff(args));
            }

            string program;
            string arguments;

            if (!Substitute(diffApp, args, DiffToolMode.Diff, out program, out arguments) ||
                !File.Exists(program))
            {
                new AnkhMessageBox(Context).Show(string.Format("Can't find diff program '{0}'", program ?? diffApp));
                return(false);
            }

            Process p = new Process();

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

            string mergedFile = args.MineFile;

            DiffToolMonitor monitor = null;

            if (!string.IsNullOrEmpty(mergedFile))
            {
                monitor = new DiffToolMonitor(Context, mergedFile, false, null);

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

            bool started = false;

            try
            {
                return(started = p.Start());
            }
            finally
            {
                if (!started)
                {
                    if (monitor != null)
                    {
                        monitor.Dispose();
                    }
                }
            }
        }
Ejemplo n.º 2
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");
            }

            SetFloat(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, args.GetMergedExitCodes());

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

            bool started = false;

            try
            {
                return(started = p.Start());
            }
            finally
            {
                if (!started)
                {
                    if (monitor != null)
                    {
                        monitor.Dispose();
                    }
                }
            }
        }
Ejemplo n.º 3
0
        public bool RunMerge(AnkhMergeArgs args)
        {
            if (args == null)
            {
                throw new ArgumentNullException("args");
            }
            else if (!args.Validate())
            {
                throw new ArgumentException("Arguments not filled correctly", "args");
            }

            SetFloat(args);

            string mergeApp = this.GetMergePath(args.Mode, args.MineFile);

            if (string.IsNullOrEmpty(mergeApp))
            {
                IAnkhInternalDiff internalDiff = GetService <IAnkhInternalDiff>();

                if (internalDiff != null && internalDiff.HasMerge)
                {
                    return(internalDiff.RunMerge(args));
                }
            }

            if (string.IsNullOrEmpty(mergeApp))
            {
                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(mergeApp, args, DiffToolMode.Merge, out program, out arguments) ||
                !File.Exists(program))
            {
                new AnkhMessageBox(Context).Show(string.Format("Can't find merge program '{0}'", program ?? mergeApp));
                return(false);
            }

            Process p = new Process();

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

            string mergedFile = args.MergedFile;

            DiffToolMonitor monitor = null;

            if (!string.IsNullOrEmpty(mergedFile))
            {
                monitor = new DiffToolMonitor(Context, mergedFile, false, args.GetMergedExitCodes());

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

            bool started = false;

            try
            {
                return(started = p.Start());
            }
            finally
            {
                if (!started)
                {
                    if (monitor != null)
                    {
                        monitor.Dispose();
                    }
                }
            }
        }
Ejemplo n.º 4
0
        public bool RunPatch(VisualGitPatchArgs 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 VisualGitMessageBox(Context).Show("Please specify a merge tool in Tools->Options->SourceControl->Git", "VisualGit - No visual merge tool is available");

                return false;
            }

            string program;
            string arguments;
            if (!Substitute(diffApp, args, DiffToolMode.Patch, out program, out arguments))
            {
                new VisualGitMessageBox(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();
                }
            }
        }
Ejemplo n.º 5
0
        public bool RunDiff(VisualGitDiffArgs args)
        {
            if (args == null)
                throw new ArgumentNullException("args");
            else if (!args.Validate())
                throw new ArgumentException("Arguments not filled correctly", "args");

            string diffApp = this.GetDiffPath(args.Mode);

            if (string.IsNullOrEmpty(diffApp))
                return RunInternalDiff(args);

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

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

            string mergedFile = args.MineFile;

            DiffToolMonitor monitor = null;
            if (!string.IsNullOrEmpty(mergedFile))
            {
                monitor = new DiffToolMonitor(Context, mergedFile, false);

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

            bool started = false;
            try
            {
                return started = p.Start();
            }
            finally
            {
                if (!started)
                {
                    if (monitor != null)
                        monitor.Dispose();
                }
            }
        }
Ejemplo n.º 6
0
        public bool RunMerge(AnkhMergeArgs args)
        {
            if (args == null)
                throw new ArgumentNullException("args");
            else if (!args.Validate())
                throw new ArgumentException("Arguments not filled correctly", "args");

            string diffApp = this.GetMergePath(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.Merge, out program, out arguments))
            {
                new AnkhMessageBox(Context).Show(string.Format("Can't find merge program '{0}'", program));
                return false;
            }

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

            string mergedFile = args.MergedFile;

            DiffToolMonitor monitor = null;
            if (!string.IsNullOrEmpty(mergedFile))
            {
                monitor = new DiffToolMonitor(Context, mergedFile, false);

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

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