예제 #1
0
        void ExecuteDiff(CommandEventArgs e, ICollection <SvnOrigin> targets, SvnRevisionRange range)
        {
            if (targets.Count != 1)
            {
                return;
            }

            SvnTarget diffTarget = EnumTools.GetSingle(targets).Target;

            IAnkhDiffHandler diff = e.GetService <IAnkhDiffHandler>();
            AnkhDiffArgs     da   = new AnkhDiffArgs();

            string[] files = diff.GetTempFiles(diffTarget, range.StartRevision, range.EndRevision, true);

            if (files == null)
            {
                return;
            }

            da.BaseFile  = files[0];
            da.MineFile  = files[1];
            da.BaseTitle = diff.GetTitle(diffTarget, range.StartRevision);
            da.MineTitle = diff.GetTitle(diffTarget, range.EndRevision);
            da.ReadOnly  = true;
            diff.RunDiff(da);
        }
예제 #2
0
        private void addButton_Click(object sender, EventArgs e)
        {
            IAnkhDiffHandler diffHandler = Context.GetService <IAnkhDiffHandler>();

            using (AddAdvancedDiffUserTool myAddAdvancedDiffUserTool = new AddAdvancedDiffUserTool(listView, diffHandler))
            {
                myAddAdvancedDiffUserTool.ShowDialog(Context);
            }
        }
예제 #3
0
        public override void OnExecute(CommandEventArgs e)
        {
            IAnkhDiffHandler   diff      = e.GetService <IAnkhDiffHandler>();
            ISvnRepositoryItem reposItem = EnumTools.GetSingle(e.Selection.GetSelection <ISvnRepositoryItem>());

            if (reposItem == null)
            {
                return;
            }

            SvnRevision from;
            SvnRevision to;

            if (reposItem.Revision == SvnRevision.Working)
            {
                from = SvnRevision.Base;
                to   = SvnRevision.Working;
            }
            else if (e.Command == AnkhCommand.RepositoryCompareWithWc)
            {
                from = reposItem.Revision;
                to   = SvnRevision.Working;
            }
            else
            {
                from = reposItem.Revision.Revision - 1;
                to   = reposItem.Revision;
            }
            AnkhDiffArgs da = new AnkhDiffArgs();

            if (to == SvnRevision.Working)
            {
                da.BaseFile = diff.GetTempFile(reposItem.Origin.Target, from, true);

                if (da.BaseFile == null)
                {
                    return; // User canceled
                }
                da.MineFile = ((SvnPathTarget)reposItem.Origin.Target).FullPath;
            }
            else
            {
                string[] files = diff.GetTempFiles(reposItem.Origin.Target, from, to, true);

                if (files == null)
                {
                    return; // User canceled
                }
                da.BaseFile = files[0];
                da.MineFile = files[1];
                System.IO.File.SetAttributes(da.MineFile, System.IO.FileAttributes.ReadOnly | System.IO.FileAttributes.Normal);
            }

            da.BaseTitle = diff.GetTitle(reposItem.Origin.Target, from);
            da.MineTitle = diff.GetTitle(reposItem.Origin.Target, to);
            diff.RunDiff(da);
        }
예제 #4
0
        private void modifyButton_Click(object sender, EventArgs e)
        {
            IAnkhDiffHandler diffHandler = Context.GetService <IAnkhDiffHandler>();

            using (AddAdvancedDiffUserTool myAddAdvancedUserTool = new AddAdvancedDiffUserTool(listView, diffHandler))
            {
                myAddAdvancedUserTool.setItem(listView.SelectedItems[0]);
                myAddAdvancedUserTool.ShowDialog(Context);
            }
        }
예제 #5
0
        private void HandleConflictWithExternalMergeTool(SvnConflictEventArgs e)
        {
            IAnkhDiffHandler handler = GetService<IAnkhDiffHandler>();
            if (handler == null)
            {
                HandleConflictWithDialog(e);
            }
            else
            {
                AnkhMergeArgs ama = new AnkhMergeArgs();
                // Ensure paths are in valid format or the DiffToolMonitor constructor
                // throws argument exception validatig the file path to be monitored.
                ama.BaseFile = SvnTools.GetNormalizedFullPath(e.BaseFile);
                ama.TheirsFile = SvnTools.GetNormalizedFullPath(e.TheirFile);
                ama.MineFile = SvnTools.GetNormalizedFullPath(e.MyFile);
                ama.MergedFile = SvnTools.GetNormalizedFullPath(e.MergedFile);
                ama.Mode = DiffMode.PreferExternal;
                ama.BaseTitle = "Base";
                ama.TheirsTitle = "Theirs";
                ama.MineTitle = "Mine";
                ama.MergedTitle = new System.IO.FileInfo(e.Path).Name;
                bool merged = handler.RunMerge(ama);       
                if (merged)
                {
                    IUIService ui = Context.GetService<IUIService>();
                    string message = "Did you resolve all of the conflicts in the file?\n\nAnswering yes marks this file as resolved, no will keep it as conflicted.";
                    string caption = "Resolve Conflict";
                    DialogResult result = ui.ShowMessage(message, caption, MessageBoxButtons.YesNoCancel);
                    e.Cancel = result == DialogResult.Cancel;

                    if(!e.Cancel)
                        merged = result == DialogResult.Yes;
                }
                if (!merged)
                {
                    //Restore original merged file.
                    HandleConflictWithDialog(e);
                }
                else
                {
                    e.Choice = SvnAccept.Merged;
                }
            }
        }
예제 #6
0
        protected override void LoadSettingsCore()
        {
            IAnkhDiffHandler diff = Context.GetService <IAnkhDiffHandler>();

            LoadBox(diffExeBox, Config.DiffExePath, diff.DiffToolTemplates);
            LoadBox(mergeExeBox, Config.MergeExePath, diff.MergeToolTemplates);
            LoadBox(patchExeBox, Config.PatchExePath, diff.PatchToolTemplates);

            forceExternalBrowser.Checked = Config.ForceExternalBrowser;

            if (VSVersion.VS2008OrOlder)
            {
                floatVSDiffViewers.Enabled = floatVSDiffViewers.Visible = false;
            }
            else
            {
                floatVSDiffViewers.Checked = Config.FloatDiffEditors;
            }
        }
예제 #7
0
        public void OnExecute(CommandEventArgs e)
        {
            // All checked in OnUpdate
            ILogControl logWindow = e.Selection.GetActiveControl <ILogControl>();
            SvnOrigin   origin    = EnumTools.GetSingle(logWindow.Origins);
            ISvnLogItem item      = EnumTools.GetSingle(e.Selection.GetSelection <ISvnLogItem>());

            IAnkhDiffHandler diff = e.GetService <IAnkhDiffHandler>();

            AnkhDiffArgs da = new AnkhDiffArgs();

            da.BaseFile = diff.GetTempFile(origin.Target, item.Revision, true);
            if (da.BaseFile == null)
            {
                return; // User cancel
            }
            da.MineFile  = ((SvnPathTarget)origin.Target).FullPath;
            da.BaseTitle = string.Format("Base (r{0})", item.Revision);
            da.MineTitle = "Working";

            diff.RunDiff(da);
        }
예제 #8
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);
        }
예제 #9
0
        public override void OnExecute(CommandEventArgs e)
        {
            List <SvnItem> selectedFiles = new List <SvnItem>();

            if (e.Command == AnkhCommand.DocumentShowChanges)
            {
                SvnItem item = e.Selection.ActiveDocumentSvnItem;

                if (item == null)
                {
                    return;
                }
                selectedFiles.Add(item);
            }
            else
            {
                foreach (SvnItem item in e.Selection.GetSelectedSvnItems(false))
                {
                    if (!item.IsVersioned || (item.Status.LocalNodeStatus == SvnStatus.Added && !item.Status.IsCopied))
                    {
                        continue;
                    }

                    if (e.Command == AnkhCommand.ItemCompareBase ||
                        e.Command == AnkhCommand.ItemShowChanges)
                    {
                        if (!(item.IsModified || item.IsDocumentDirty) ||
                            !item.IsLocalDiffAvailable    // exclude if local diff is not available
                            )
                        {
                            continue;
                        }
                    }

                    if (e.Command == AnkhCommand.DiffLocalItem &&
                        !NotDeletedFilter(item))
                    {
                        continue;
                    }

                    selectedFiles.Add(item);
                }
            }

            SvnRevisionRange revRange = null;

            switch (e.Command)
            {
            case AnkhCommand.DiffLocalItem:
                break;     // revRange null -> show selector

            case AnkhCommand.ItemCompareBase:
            case AnkhCommand.ItemShowChanges:
            case AnkhCommand.DocumentShowChanges:
                revRange = new SvnRevisionRange(SvnRevision.Base, SvnRevision.Working);
                break;

            case AnkhCommand.ItemCompareCommitted:
                revRange = new SvnRevisionRange(SvnRevision.Committed, SvnRevision.Working);
                break;

            case AnkhCommand.ItemCompareLatest:
                revRange = new SvnRevisionRange(SvnRevision.Head, SvnRevision.Working);
                break;

            case AnkhCommand.ItemComparePrevious:
                revRange = new SvnRevisionRange(SvnRevision.Previous, SvnRevision.Working);
                break;
            }

            if (e.PromptUser || selectedFiles.Count > 1 || revRange == null)
            {
                SvnRevision start = revRange == null ? SvnRevision.Base : revRange.StartRevision;
                SvnRevision end   = revRange == null ? SvnRevision.Working : revRange.EndRevision;

                // should we show the path selector?
                if (e.PromptUser || !Shift)
                {
                    using (CommonFileSelectorDialog dlg = new CommonFileSelectorDialog())
                    {
                        dlg.Text          = CommandStrings.CompareFilesTitle;
                        dlg.Items         = selectedFiles;
                        dlg.RevisionStart = start;
                        dlg.RevisionEnd   = end;

                        if (dlg.ShowDialog(e.Context) != DialogResult.OK)
                        {
                            return;
                        }

                        selectedFiles.Clear();
                        selectedFiles.AddRange(dlg.GetCheckedItems());
                        start = dlg.RevisionStart;
                        end   = dlg.RevisionEnd;
                    }
                }

                revRange = new SvnRevisionRange(start, end);
            }

            if (revRange.EndRevision.RevisionType == SvnRevisionType.Working ||
                revRange.StartRevision.RevisionType == SvnRevisionType.Working)
            {
                // Save only the files needed

                IAnkhOpenDocumentTracker tracker = e.GetService <IAnkhOpenDocumentTracker>();
                if (tracker != null)
                {
                    tracker.SaveDocuments(SvnItem.GetPaths(selectedFiles));
                }
            }

            IAnkhDiffHandler diff = e.GetService <IAnkhDiffHandler>();

            foreach (SvnItem item in selectedFiles)
            {
                AnkhDiffArgs da = new AnkhDiffArgs();

                if ((item.Status.IsCopied || item.IsReplaced) &&
                    (!revRange.StartRevision.RequiresWorkingCopy || !revRange.EndRevision.RequiresWorkingCopy))
                {
                    // The file is copied, use its origins history instead of that of the new file
                    SvnUriTarget copiedFrom = diff.GetCopyOrigin(item);

                    // TODO: Maybe handle Previous/Committed as history

                    if (copiedFrom != null && !revRange.StartRevision.RequiresWorkingCopy)
                    {
                        if (null == (da.BaseFile = diff.GetTempFile(copiedFrom, revRange.StartRevision, true)))
                        {
                            return; // Canceled
                        }
                        da.BaseTitle = diff.GetTitle(copiedFrom, revRange.StartRevision);
                    }

                    if (copiedFrom != null && !revRange.EndRevision.RequiresWorkingCopy)
                    {
                        if (null == (da.MineFile = diff.GetTempFile(copiedFrom, revRange.EndRevision, true)))
                        {
                            return; // Canceled
                        }
                        da.MineTitle = diff.GetTitle(copiedFrom, revRange.EndRevision);
                    }
                }

                if (da.BaseFile == null)
                {
                    if (null == (da.BaseFile = (revRange.StartRevision == SvnRevision.Working) ? item.FullPath :
                                               diff.GetTempFile(item, revRange.StartRevision, true)))
                    {
                        return; // Canceled
                    }

                    da.BaseTitle = diff.GetTitle(item, revRange.StartRevision);
                }

                if (da.MineFile == null)
                {
                    if (null == (da.MineFile = (revRange.EndRevision == SvnRevision.Working) ? item.FullPath :
                                               diff.GetTempFile(item, revRange.EndRevision, true)))
                    {
                        return; // Canceled
                    }

                    da.MineTitle = diff.GetTitle(item, revRange.EndRevision);
                }

                if (!String.Equals(da.MineFile, item.FullPath, StringComparison.OrdinalIgnoreCase))
                {
                    da.ReadOnly = true;
                }

                diff.RunDiff(da);
            }
        }
예제 #10
0
        public override void OnExecute(CommandEventArgs e)
        {
            List <SvnOrigin> selected = new List <SvnOrigin>();
            ISvnStatusCache  cache    = e.GetService <ISvnStatusCache>();

            switch (e.Command)
            {
            case AnkhCommand.Log:
                IAnkhDiffHandler diffHandler = e.GetService <IAnkhDiffHandler>();
                List <SvnOrigin> items       = new List <SvnOrigin>();
                foreach (SvnItem i in e.Selection.GetSelectedSvnItems(false))
                {
                    Debug.Assert(i.IsVersioned);

                    if (i.IsReplaced || i.IsAdded)
                    {
                        if (!i.HasCopyableHistory)
                        {
                            continue;
                        }

                        items.Add(new SvnOrigin(diffHandler.GetCopyOrigin(i), i.WorkingCopy.RepositoryRoot));
                        continue;
                    }

                    items.Add(new SvnOrigin(i));
                }
                PerformLog(e.Context, items, null, null);
                break;

            case AnkhCommand.SolutionHistory:
                IAnkhSolutionSettings settings = e.GetService <IAnkhSolutionSettings>();

                PerformLog(e.Context, new SvnOrigin[] { new SvnOrigin(cache[settings.ProjectRoot]) }, null, null);
                break;

            case AnkhCommand.ProjectHistory:
                IProjectFileMapper mapper = e.GetService <IProjectFileMapper>();
                foreach (SccProject p in e.Selection.GetSelectedProjects(false))
                {
                    ISccProjectInfo info = mapper.GetProjectInfo(p);

                    if (info != null)
                    {
                        selected.Add(new SvnOrigin(cache[info.ProjectDirectory]));
                    }
                }

                PerformLog(e.Context, selected, null, null);
                break;

            case AnkhCommand.DocumentHistory:
                SvnItem docItem = e.Selection.ActiveDocumentSvnItem;
                Debug.Assert(docItem != null);

                PerformLog(e.Context, new SvnOrigin[] { new SvnOrigin(docItem) }, null, null);
                break;

            case AnkhCommand.ReposExplorerLog:
                foreach (ISvnRepositoryItem i in e.Selection.GetSelection <ISvnRepositoryItem>())
                {
                    if (i != null && i.Origin != null)
                    {
                        selected.Add(i.Origin);
                    }
                }

                if (selected.Count > 0)
                {
                    PerformLog(e.Context, selected, null, null);
                }
                break;

            case AnkhCommand.AnnotateShowLog:
                IAnnotateSection section = EnumTools.GetSingle(e.Selection.GetSelection <IAnnotateSection>());

                if (section == null)
                {
                    return;
                }

                PerformLog(e.Context, new SvnOrigin[] { section.Origin }, section.Revision, null);

                break;
            }
        }
예제 #11
0
 public AddAdvancedMergeUserTool(ListView listview, IAnkhDiffHandler diff)
 {
     InitializeComponent();
     myListView = listview;
     LoadBox(mergeExeBox, "", diff.MergeToolTemplates);
 }