/// <summary>
        /// Resolves the specified revision.
        /// </summary>
        /// <param name="origin"></param>
        /// <param name="revision">The revision.</param>
        /// <returns></returns>
        public AnkhRevisionType Resolve(SvnOrigin origin, SharpSvn.SvnRevision revision)
        {
            if (revision == null)
            {
                throw new ArgumentNullException("revision");
            }

            foreach (IAnkhRevisionProvider p in _providers)
            {
                AnkhRevisionType r = p.Resolve(origin, revision);

                if (r != null)
                {
                    return(r);
                }
            }

            switch (revision.RevisionType)
            {
            case SvnRevisionType.Number:
                ExplicitRevisionType ert = new ExplicitRevisionType(Context, origin);
                ert.CurrentValue = revision;
                return(ert);
            }

            return(null);
        }
Example #2
0
        /// <summary>
        /// Initializes a dummy instance of the <see cref="RepositoryTreeNode"/> class.
        /// </summary>
        /// <param name="uri">The URI.</param>
        /// <param name="dummyNode">if set to <c>true</c> [dummy node].</param>
        internal RepositoryTreeNode(Uri uri, bool dummyNode)
        {
            Debug.Assert(dummyNode, "Must specify dummyNode");

            _uri    = uri;
            _origin = null;
        }
Example #3
0
        public void AddLines(SvnOrigin origin, Collection <SvnBlameEventArgs> blameResult)
        {
            _origin = origin;

            SortedList <long, AnnotateSource> sources = new SortedList <long, AnnotateSource>();

            AnnotateRegion section = null;

            blameSections.Clear();

            foreach (SvnBlameEventArgs e in blameResult)
            {
                AnnotateSource src;
                if (!sources.TryGetValue(e.Revision, out src))
                {
                    sources.Add(e.Revision, src = new AnnotateSource(e, origin));
                }

                int line = (int)e.LineNumber;

                if (section == null || section.Source != src)
                {
                    section = new AnnotateRegion(line, src);
                    blameSections.Add(section);
                }
                else
                {
                    section.EndLine = line;
                }
            }
            blameMarginControl1.Invalidate();
        }
            public AnkhRevisionType Resolve(SvnOrigin origin, SharpSvn.SvnRevision revision)
            {
                if (revision == null)
                {
                    throw new ArgumentNullException("revision");
                }

                switch (revision.RevisionType)
                {
                case SvnRevisionType.Head:
                    return(_head);

                case SvnRevisionType.Base:
                    return(_base);

                case SvnRevisionType.Committed:
                    return(_committed);

                case SvnRevisionType.Previous:
                    return(_previous);

                case SvnRevisionType.Working:
                    return(_working);
                }

                return(null);
            }
Example #5
0
        public PathListViewItem(LogChangedPathsView view, ISvnLogItem logItem, SvnChangeItem change, Uri reposRoot, bool isInSelection, Color[] colorInfo)
            : base(view)
        {
            if (logItem == null)
            {
                throw new ArgumentNullException("logItem");
            }
            if (change == null)
            {
                throw new ArgumentNullException("change");
            }
            _logItem       = logItem;
            _change        = change;
            _isInSelection = isInSelection;
            Uri uri;

            string path = change.Path.TrimStart('/');

            if (string.IsNullOrEmpty(path))
            {
                uri = reposRoot;
            }
            else
            {
                uri = SvnTools.AppendPathSuffix(reposRoot, path);
            }

            _origin = new SvnOrigin(new SvnUriTarget(uri, logItem.Revision), reposRoot);

            RefreshText();
            UpdateColors(colorInfo);
        }
Example #6
0
        public void StartLog(SvnOrigin target, SvnRevision start, SvnRevision end)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            StartLog(new SvnOrigin[] { target }, start, end);
        }
Example #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RepositoryTreeNode"/> class.
        /// </summary>
        /// <param name="origin">The origin.</param>
        public RepositoryTreeNode(SvnOrigin origin)
        {
            if (origin == null)
            {
                throw new ArgumentNullException("origin");
            }

            _uri    = origin.Uri;
            _origin = origin;
        }
Example #8
0
        private static void AutoOpenCommand(CommandEventArgs e, SvnOrigin origin)
        {
            IAnkhCommandService   svc = e.GetService <IAnkhCommandService>();
            IAnkhSolutionSettings solutionSettings = e.GetService <IAnkhSolutionSettings>();

            if (svc == null || solutionSettings == null)
            {
                return;
            }

            // Ok, we can assume we have a file
            string filename = origin.Target.FileName;
            string ext      = Path.GetExtension(filename);

            if (string.IsNullOrEmpty(ext))
            {
                // No extension -> Open as text
                svc.PostExecCommand(AnkhCommand.ViewInVsText);
                return;
            }

            foreach (string projectExt in solutionSettings.AllProjectExtensionsFilter.Split(';'))
            {
                if (projectExt.TrimStart('*').Trim().Equals(ext, StringComparison.OrdinalIgnoreCase))
                {
                    // We found a project or solution, use Open from Subversion to create a checkout

                    svc.PostExecCommand(AnkhCommand.FileFileOpenFromSubversion, origin);
                    return;
                }
            }

            bool odd = false;

            foreach (string block in solutionSettings.OpenFileFilter.Split('|'))
            {
                odd = !odd;
                if (odd)
                {
                    continue;
                }

                foreach (string itemExt in block.Split(';'))
                {
                    if (itemExt.TrimStart('*').Trim().Equals(ext, StringComparison.OrdinalIgnoreCase))
                    {
                        svc.PostExecCommand(AnkhCommand.ViewInVsNet);
                        return;
                    }
                }
            }

            // Ultimate fallback: Just ask the user what to do (don't trust the repository!)
            svc.PostExecCommand(AnkhCommand.ViewInWindowsWith);
        }
Example #9
0
        public RepositoryExplorerItem(IAnkhServiceProvider context, SvnOrigin origin, RepositoryListItem li)
        {
            if (context == null)
                throw new ArgumentNullException("context");
            else if (li == null)
                throw new ArgumentNullException("li");

            _context = context;
            _origin = origin;
            _li = li;
        }
Example #10
0
        public RepositoryListItem(RepositoryListView view, SharpSvn.Remote.ISvnRepositoryListItem listItem, SvnOrigin dirOrigin, IFileIconMapper iconMapper)
            : base(view)
        {
            if (listItem == null)
            {
                throw new ArgumentNullException("listItem");
            }
            else if (dirOrigin == null)
            {
                throw new ArgumentNullException("dirOrigin");
            }

            SvnDirEntry entry    = listItem.Entry;
            Uri         entryUri = listItem.Uri;

            _entry  = entry;
            _origin = new SvnOrigin(entryUri, dirOrigin);

            string name = SvnTools.GetFileName(entryUri);

            bool isFile = (entry.NodeKind == SvnNodeKind.File);

            string extension = isFile ? Path.GetExtension(name) : "";

            if (iconMapper != null)
            {
                if (isFile)
                {
                    ImageIndex = iconMapper.GetIconForExtension(extension);
                }
                else
                {
                    ImageIndex = iconMapper.DirectoryIcon;
                }
            }

            SvnLockInfo      lockInfo = null;
            SvnListEventArgs lea      = listItem as SvnListEventArgs;

            if (lea != null)
            {
                lockInfo = lea.Lock;
            }

            SetValues(
                name,
                IsFolder ? RepositoryStrings.ExplorerDirectoryName : view.Context.GetService <IFileIconMapper>().GetFileType(extension),
                entry.Revision.ToString(),
                entry.Author,
                IsFolder ? "" : entry.FileSize.ToString(),
                entry.Time.ToLocalTime().ToString("g"),
                (lockInfo != null) ? lockInfo.Owner : "");
        }
Example #11
0
        public RepositoryExplorerItem(IAnkhServiceProvider context, SvnOrigin origin, RepositoryTreeNode tn)
        {
            if (context == null)
                throw new ArgumentNullException("context");
            else if (tn == null)
                throw new ArgumentNullException("tn");

            _context = context;
            _origin = origin;
            _tn = tn;
            _name = tn.Text;
        }
Example #12
0
        protected override string GetCanonicalName(RepositoryListItem item)
        {
            SvnOrigin origin = item.Origin;

            if (origin != null)
            {
                return(origin.Uri.AbsoluteUri);
            }
            else
            {
                return(null);
            }
        }
Example #13
0
        public void StartMergesMerged(IAnkhServiceProvider context, SvnItem target, Uri source)
        {
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }

            SvnOrigin origin = new SvnOrigin(target);

            _origins = new SvnOrigin[] { origin };
            _baseUri = null;
            UpdateTitle();
            logControl.StartMergesMerged(context, origin, source);
        }
Example #14
0
                public override bool IsValidOn(SvnOrigin origin)
                {
                    switch (_rev.RevisionType)
                    {
                    case SvnRevisionType.Base:
                    case SvnRevisionType.Committed:
                    case SvnRevisionType.Previous:
                    case SvnRevisionType.Working:
                        return(origin.Target is SvnPathTarget);

                    default:
                        return(base.IsValidOn(origin));
                    }
                }
Example #15
0
            public ExplicitRevisionType(IAnkhServiceProvider context, SvnOrigin origin)
            {
                if (context == null)
                {
                    throw new ArgumentNullException("context");
                }
                else if (origin == null)
                {
                    throw new ArgumentNullException("origin");
                }

                _context = context;
                _origin  = origin;
            }
Example #16
0
            public DateRevisionType(IAnkhServiceProvider context, SvnOrigin origin)
            {
                if (context == null)
                {
                    throw new ArgumentNullException("context");
                }
                else if (origin == null)
                {
                    throw new ArgumentNullException("origin");
                }

                _context = context;
                _origin  = origin;
                _date    = DateTime.Today;
            }
Example #17
0
        public RepositoryExplorerItem(IAnkhServiceProvider context, SvnOrigin origin, RepositoryListItem li)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            else if (li == null)
            {
                throw new ArgumentNullException("li");
            }

            _context = context;
            _origin  = origin;
            _li      = li;
        }
Example #18
0
        public void OnUpdate(CommandUpdateEventArgs e)
        {
            ILogControl logWindow = e.Selection.GetActiveControl <ILogControl>();

            if (logWindow == null)
            {
                e.Enabled = false;
                return;
            }

            SvnOrigin origin = EnumTools.GetSingle(logWindow.Origins);

            if (origin == null || !(origin.Target is SvnPathTarget))
            {
                e.Enabled = false;
                return;
            }

            int count = 0;

            foreach (ISvnLogItem item in e.Selection.GetSelection <ISvnLogItem>())
            {
                count++;

                if (count > 1)
                {
                    break;
                }
            }

            switch (e.Command)
            {
            case AnkhCommand.LogRevertTo:
                if (count == 1)
                {
                    return;
                }
                break;

            case AnkhCommand.LogRevertThisRevisions:
                if (count > 0)
                {
                    return;
                }
                break;
            }
            e.Enabled = false;
        }
Example #19
0
        public RepositoryExplorerItem(IAnkhServiceProvider context, SvnOrigin origin, RepositoryTreeNode tn)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            else if (tn == null)
            {
                throw new ArgumentNullException("tn");
            }

            _context = context;
            _origin  = origin;
            _tn      = tn;
            _name    = tn.Text;
        }
Example #20
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (FileCache != null && !string.IsNullOrEmpty(OriginPath))
            {
                SvnItem item = FileCache[OriginPath];

                if (item.IsVersioned)
                {
                    _baseOrigin = new SvnOrigin(item);
                }

                revisionPicker.Context   = Context;
                revisionPicker.Revision  = SvnRevision.Working;
                revisionPicker.SvnOrigin = _baseOrigin;
            }
        }
Example #21
0
        public RepositoryListItem(RepositoryListView view, SharpSvn.Remote.ISvnRepositoryListItem listItem, SvnOrigin dirOrigin, IFileIconMapper iconMapper)
            : base(view)
        {
            if (listItem == null)
                throw new ArgumentNullException("listItem");
            else if (dirOrigin == null)
                throw new ArgumentNullException("dirOrigin");

            SvnDirEntry entry = listItem.Entry;
            Uri entryUri = listItem.Uri;

            _entry = entry;
            _origin = new SvnOrigin(entryUri, dirOrigin);

            string name = SvnTools.GetFileName(entryUri);

            bool isFile = (entry.NodeKind == SvnNodeKind.File);

            string extension = isFile ? Path.GetExtension(name) : "";

            if (iconMapper != null)
            {
                if (isFile)
                    ImageIndex = iconMapper.GetIconForExtension(extension);
                else
                {
                    ImageIndex = iconMapper.DirectoryIcon;
                }
            }

            SvnLockInfo lockInfo = null;
            SvnListEventArgs lea = listItem as SvnListEventArgs;
            if (lea != null)
                lockInfo = lea.Lock;

            SetValues(
                name,
                IsFolder ? RepositoryStrings.ExplorerDirectoryName : view.Context.GetService<IFileIconMapper>().GetFileType(extension),
                entry.Revision.ToString(),
                entry.Author,
                IsFolder ? "" : entry.FileSize.ToString(),
                entry.Time.ToLocalTime().ToString("g"),
                (lockInfo != null) ? lockInfo.Owner : "");
        }
Example #22
0
        public AnkhRevisionType Resolve(SvnOrigin origin, AnkhRevisionType revision)
        {
            if (revision == null)
            {
                throw new ArgumentNullException("revision");
            }

            foreach (IAnkhRevisionProvider p in _providers)
            {
                AnkhRevisionType r = p.Resolve(origin, revision);

                if (r != null)
                {
                    return(r);
                }
            }

            return(Resolve(origin, revision.CurrentValue));
        }
Example #23
0
        private void browseButton_Click(object sender, EventArgs e)
        {
            using (RepositoryFolderBrowserDialog dlg = new RepositoryFolderBrowserDialog())
            {
                SvnOrigin from = SelectedTarget;

                if (from == null)
                {
                    return;
                }

                dlg.ShowFiles = true;

                SvnUriTarget ut = from.Target as SvnUriTarget;
                if (ut != null)
                {
                    dlg.SelectedUri = ut.Uri;
                }
                else
                {
                    SvnItem file = GetService <ISvnStatusCache>()[((SvnPathTarget)from.Target).FullPath];

                    if (file.Uri == null)
                    {
                        dlg.SelectedUri = from.RepositoryRoot;
                    }
                    else
                    {
                        dlg.SelectedUri = file.Uri;
                    }
                }

                if (dlg.ShowDialog(Context) == DialogResult.OK)
                {
                    Uri selectedUri = dlg.SelectedUri;

                    SvnOrigin o = new SvnOrigin(Context, selectedUri, null);

                    targetBox.Items.Add(o);
                    targetBox.SelectedItem = o;
                }
            }
        }
Example #24
0
        public void StartMergesMerged(IAnkhServiceProvider context, SvnOrigin target, SvnTarget source)
        {
            if (context == null)
            {
                throw new ArgumentNullException("context");
            }
            if (target == null)
            {
                throw new ArgumentNullException("target");
            }
            if (source == null)
            {
                throw new ArgumentNullException("source");
            }

            LogSource.Targets     = new SvnOrigin[] { new SvnOrigin(context, source, target.RepositoryRoot) }; // Must be from the same repository!
            LogSource.MergeTarget = target;
            Reset();
            revisionBox.Start(LogMode.MergesMerged);
        }
Example #25
0
        public override void OnUpdate(CommandUpdateEventArgs e)
        {
            base.OnUpdate(e);


            if (e.Enabled && e.Command == AnkhCommand.ViewInVsNet)
            {
                ISvnRepositoryItem    single   = EnumTools.GetSingle(e.Selection.GetSelection <ISvnRepositoryItem>());
                IAnkhSolutionSettings settings = e.GetService <IAnkhSolutionSettings>();

                SvnOrigin origin = single.Origin; // Checked in parent

                string ext = Path.GetExtension(origin.Target.FileName);

                if (!string.IsNullOrEmpty(ext) && settings.OpenFileFilter.IndexOf("*" + ext, StringComparison.OrdinalIgnoreCase) < 0)
                {
                    e.Enabled = false;
                }
            }
        }
Example #26
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);
        }
Example #27
0
        public void OnUpdate(CommandUpdateEventArgs e)
        {
            ISvnLogItem item = EnumTools.GetSingle(e.Selection.GetSelection <ISvnLogItem>());

            if (item != null)
            {
                ILogControl logWindow = e.Selection.GetActiveControl <ILogControl>();

                if (logWindow != null)
                {
                    SvnOrigin origin = EnumTools.GetSingle(logWindow.Origins);

                    if (origin != null)
                    {
                        SvnPathTarget pt = origin.Target as SvnPathTarget;

                        if (pt != null)
                        {
                            SvnItem svnItem = e.GetService <ISvnStatusCache>()[pt.FullPath];

                            if (svnItem != null && !svnItem.IsDirectory)
                            {
                                if (null == e.Selection.GetActiveControl <ILogControl>())
                                {
                                    e.Enabled = false;
                                }

                                return;
                            }
                        }
                    }
                }
            }

            e.Enabled = false;
        }
Example #28
0
        void UpdateForRevChanges(ILogControl logWindow, CommandUpdateEventArgs e)
        {
            SvnOrigin first = EnumTools.GetSingle(logWindow.Origins);

            if (first == null)
            {
                e.Enabled = false;
                return;
            }

            SvnPathTarget pt = first.Target as SvnPathTarget;

            if (pt != null)
            {
                if (e.GetService <ISvnStatusCache>()[pt.FullPath].IsDirectory)
                {
                    // We can't diff directories at this time
                    e.Enabled = false;
                    return;
                }
            }

            // Note: We can't have a local directory, but we can have a remote one.
        }
Example #29
0
 public override bool IsValidOn(SvnOrigin origin)
 {
     switch (_rev.RevisionType)
     {
         case SvnRevisionType.Base:
         case SvnRevisionType.Committed:
         case SvnRevisionType.Previous:
         case SvnRevisionType.Working:
             return origin.Target is SvnPathTarget;
         default:
             return base.IsValidOn(origin);
     }
 }
Example #30
0
 public AnkhRevisionType Resolve(SvnOrigin origin, AnkhRevisionType revision)
 {
     return Resolve(origin, revision.CurrentValue);
 }
Example #31
0
            public AnkhRevisionType Resolve(SvnOrigin origin, SharpSvn.SvnRevision revision)
            {
                if (revision == null)
                    throw new ArgumentNullException("revision");

                switch (revision.RevisionType)
                {
                    case SvnRevisionType.Head:
                        return _head;
                    case SvnRevisionType.Base:
                        return _base;
                    case SvnRevisionType.Committed:
                        return _committed;
                    case SvnRevisionType.Previous:
                        return _previous;
                    case SvnRevisionType.Working:
                        return _working;
                }

                return null;
            }
Example #32
0
            public ExplicitRevisionType(IAnkhServiceProvider context, SvnOrigin origin)
            {
                if (context == null)
                    throw new ArgumentNullException("context");
                else if (origin == null)
                    throw new ArgumentNullException("origin");

                _context = context;
                _origin = origin;
            }
Example #33
0
            public DateRevisionType(IAnkhServiceProvider context, SvnOrigin origin)
            {
                if (context == null)
                    throw new ArgumentNullException("context");
                else if (origin == null)
                    throw new ArgumentNullException("origin");

                _context = context;
                _origin = origin;
                _date = DateTime.Today;
            }
Example #34
0
        static void DoBlame(CommandEventArgs e, SvnOrigin item, SvnRevision revisionStart, SvnRevision revisionEnd, bool ignoreEols, SvnIgnoreSpacing ignoreSpacing, bool retrieveMergeInfo)
        {
            SvnWriteArgs wa = new SvnWriteArgs();
            wa.Revision = revisionEnd;

            SvnBlameArgs ba = new SvnBlameArgs();
            ba.Start = revisionStart;
            ba.End = revisionEnd;
            ba.IgnoreLineEndings = ignoreEols;
            ba.IgnoreSpacing = ignoreSpacing;
            ba.RetrieveMergedRevisions = retrieveMergeInfo;

            SvnTarget target = item.Target;

            IAnkhTempFileManager tempMgr = e.GetService<IAnkhTempFileManager>();
            string tempFile = tempMgr.GetTempFileNamed(target.FileName);

            Collection<SvnBlameEventArgs> blameResult = null;
            Dictionary<long, string> logMessages = new Dictionary<long, string>();

            ba.Notify += delegate(object sender, SvnNotifyEventArgs ee)
            {
                if (ee.Action == SvnNotifyAction.BlameRevision && ee.RevisionProperties != null)
                {
                    if (ee.RevisionProperties.Contains(SvnPropertyNames.SvnLog))
                        logMessages[ee.Revision] = ee.RevisionProperties[SvnPropertyNames.SvnLog].StringValue;
                }
            };

            bool retry = false;
            ProgressRunnerResult r = e.GetService<IProgressRunner>().RunModal(CommandStrings.Annotating, delegate(object sender, ProgressWorkerArgs ee)
            {
                using (FileStream fs = File.Create(tempFile))
                {
                    ee.Client.Write(target, fs, wa);
                }

                ba.SvnError +=
                    delegate(object errorSender, SvnErrorEventArgs errorEventArgs)
                    {
                        if (errorEventArgs.Exception is SvnClientBinaryFileException)
                        {
                            retry = true;
                            errorEventArgs.Cancel = true;
                        }
                    };
                ee.Client.GetBlame(target, ba, out blameResult);
            });

            if (retry)
            {
                using (AnkhMessageBox mb = new AnkhMessageBox(e.Context))
                {
                    if (DialogResult.Yes == mb.Show(
                                                CommandStrings.AnnotateBinaryFileContinueAnywayText,
                                                CommandStrings.AnnotateBinaryFileContinueAnywayTitle,
                                                MessageBoxButtons.YesNo, MessageBoxIcon.Information))
                    {
                        r = e.GetService<IProgressRunner>()
                            .RunModal(CommandStrings.Annotating,
                                      delegate(object sender, ProgressWorkerArgs ee)
                                      {
                                          ba.IgnoreMimeType = true;
                                          ee.Client.GetBlame(target, ba, out blameResult);
                                      });
                    }
                }
            }

            if (!r.Succeeded)
                return;

            AnnotateEditorControl annEditor = new AnnotateEditorControl();
            IAnkhEditorResolver er = e.GetService<IAnkhEditorResolver>();

            annEditor.Create(e.Context, tempFile);
            annEditor.LoadFile(tempFile);
            annEditor.AddLines(item, blameResult, logMessages);

            // Detect and set the language service
            Guid language;
            if (er.TryGetLanguageService(Path.GetExtension(target.FileName), out language))
            {
                // Extension is mapped -> user
                annEditor.SetLanguageService(language);
            }
            else if (blameResult != null && blameResult.Count > 0 && blameResult[0].Line != null)
            {
                // Extension is not mapped -> Check if this is xml (like project files)
                string line = blameResult[0].Line.Trim();

                if (line.StartsWith("<?xml")
                    || (line.StartsWith("<") && line.Contains("xmlns=\"http://schemas.microsoft.com/developer/msbuild/")))
                {
                    if (er.TryGetLanguageService(".xml", out language))
                    {
                        annEditor.SetLanguageService(language);
                    }
                }
            }
        }
Example #35
0
        public override void OnExecute(CommandEventArgs e)
        {
            ILastChangeInfo ci = e.GetService<ILastChangeInfo>();

            if (ci != null)
                ci.SetLastChange(null, null);

            SvnRevision rev;
            bool allowUnversionedObstructions = false;
            bool updateExternals = true;
            bool setDepthInfinity = true;

            IAnkhSolutionSettings settings = e.GetService<IAnkhSolutionSettings>();
            IFileStatusCache cache = e.GetService<IFileStatusCache>();
            IProjectFileMapper mapper = e.GetService<IProjectFileMapper>();
            Uri reposRoot = null;

            if (IsHeadCommand(e.Command) || e.DontPrompt)
                rev = SvnRevision.Head;
            else if (IsSolutionCommand(e.Command))
            {
                SvnItem projectItem = settings.ProjectRootSvnItem;

                Debug.Assert(projectItem != null, "Has item");

                using (UpdateDialog ud = new UpdateDialog())
                {
                    ud.ItemToUpdate = projectItem;
                    ud.Revision = SvnRevision.Head;

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

                    rev = ud.Revision;
                    allowUnversionedObstructions = ud.AllowUnversionedObstructions;
                    updateExternals = ud.UpdateExternals;
                    setDepthInfinity = ud.SetDepthInfinty;
                }
            }
            else if (IsFolderCommand(e.Command))
            {
                SvnItem dirItem = EnumTools.GetFirst(e.Selection.GetSelectedSvnItems(false));

                Debug.Assert(dirItem != null && dirItem.IsDirectory && dirItem.IsVersioned);

                using (UpdateDialog ud = new UpdateDialog())
                {
                    ud.Text = CommandStrings.UpdateFolder;
                    ud.FolderLabelText = CommandStrings.UpdateFolderLabel;
                    ud.ItemToUpdate = dirItem;
                    ud.Revision = SvnRevision.Head;

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

                    rev = ud.Revision;
                    allowUnversionedObstructions = ud.AllowUnversionedObstructions;
                    updateExternals = ud.UpdateExternals;
                    setDepthInfinity = ud.SetDepthInfinty;
                }
            }
            else
            {
                // We checked there was only a single repository to select a revision
                // from in OnUpdate, so we can suffice with only calculate the path

                SvnItem si = null;
                SvnOrigin origin = null;
                foreach (SvnProject p in GetSelectedProjects(e))
                {
                    ISvnProjectInfo pi = mapper.GetProjectInfo(p);
                    if (pi == null || pi.ProjectDirectory == null)
                        continue;

                    SvnItem item = cache[pi.ProjectDirectory];
                    if (!item.IsVersioned)
                        continue;

                    if (si == null && origin == null)
                    {
                        si = item;
                        origin = new SvnOrigin(item);
                        reposRoot = item.WorkingCopy.RepositoryRoot;
                    }
                    else
                    {
                        si = null;
                        string urlPath1 = origin.Uri.AbsolutePath;
                        string urlPath2 = item.Uri.AbsolutePath;

                        int i = 0;
                        while (i < urlPath1.Length && i < urlPath2.Length
                            && urlPath1[i] == urlPath2[i])
                        {
                            i++;
                        }

                        while (i > 0 && urlPath1[i - 1] != '/')
                            i--;

                        origin = new SvnOrigin(new Uri(origin.Uri, urlPath1.Substring(0, i)), origin.RepositoryRoot);
                    }
                }

                Debug.Assert(origin != null);

                using (UpdateDialog ud = new UpdateDialog())
                {
                    ud.Text = CommandStrings.UpdateProject;

                    if (si != null)
                        ud.ItemToUpdate = si;
                    else
                    {
                        ud.SvnOrigin = origin;
                        ud.SetMultiple(true);
                    }

                    ud.Revision = SvnRevision.Head;

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

                    rev = ud.Revision;
                    allowUnversionedObstructions = ud.AllowUnversionedObstructions;
                    updateExternals = ud.UpdateExternals;
                    setDepthInfinity = ud.SetDepthInfinty;
                }
            }

            Dictionary<string, SvnItem> itemsToUpdate = new Dictionary<string, SvnItem>(StringComparer.OrdinalIgnoreCase);
            Dictionary<string, List<string>> groups = new Dictionary<string, List<string>>(StringComparer.OrdinalIgnoreCase);

            // Get a list of all documents below the specified paths that are open in editors inside VS
            HybridCollection<string> lockPaths = new HybridCollection<string>(StringComparer.OrdinalIgnoreCase);
            IAnkhOpenDocumentTracker documentTracker = e.GetService<IAnkhOpenDocumentTracker>();

            foreach (SvnItem item in GetAllUpdateRoots(e))
            {
                // GetAllUpdateRoots can (and probably will) return duplicates!

                if (itemsToUpdate.ContainsKey(item.FullPath) || !item.IsVersioned)
                    continue;

                SvnWorkingCopy wc = item.WorkingCopy;

                if (!IsHeadCommand(e.Command) && reposRoot != null)
                {
                    // Specific revisions are only valid on a single repository!
                    if (wc != null && wc.RepositoryRoot != reposRoot)
                        continue;
                }

                List<string> inWc;

                if (!groups.TryGetValue(wc.FullPath, out inWc))
                {
                    inWc = new List<string>();
                    groups.Add(wc.FullPath, inWc);
                }

                inWc.Add(item.FullPath);
                itemsToUpdate.Add(item.FullPath, item);

                foreach (string file in documentTracker.GetDocumentsBelow(item.FullPath))
                {
                    if (!lockPaths.Contains(file))
                        lockPaths.Add(file);
                }
            }

            documentTracker.SaveDocuments(lockPaths); // Make sure all files are saved before updating/merging!

            using (DocumentLock lck = documentTracker.LockDocuments(lockPaths, DocumentLockType.NoReload))
            using (lck.MonitorChangesForReload())
            {
                SvnUpdateResult updateResult = null;

                ProgressRunnerArgs pa = new ProgressRunnerArgs();
                pa.CreateLog = true;

                string title;

                if (IsSolutionCommand(e.Command))
                    title = CommandStrings.UpdatingSolution;
                else if (IsFolderCommand(e.Command))
                    title = CommandStrings.UpdatingFolder;
                else
                    title = CommandStrings.UpdatingProject;

                e.GetService<IProgressRunner>().RunModal(title, pa,
                    delegate(object sender, ProgressWorkerArgs a)
                    {
                        PerformUpdate(e, a, rev, allowUnversionedObstructions, updateExternals, setDepthInfinity, groups.Values, out updateResult);
                    });

                if (ci != null && updateResult != null && IsSolutionCommand(e.Command))
                {
                    ci.SetLastChange("Updated to:", updateResult.Revision.ToString());
                }
            }
        }
Example #36
0
        /// <summary>
        /// Resolves the specified revision.
        /// </summary>
        /// <param name="origin"></param>
        /// <param name="revision">The revision.</param>
        /// <returns></returns>
        public AnkhRevisionType Resolve(SvnOrigin origin, SharpSvn.SvnRevision revision)
        {
            if (revision == null)
                throw new ArgumentNullException("revision");

            foreach (IAnkhRevisionProvider p in _providers)
            {
                AnkhRevisionType r = p.Resolve(origin, revision);

                if (r != null)
                    return r;
            }

            switch (revision.RevisionType)
            {
                case SvnRevisionType.Number:
                    ExplicitRevisionType ert = new ExplicitRevisionType(Context, origin);
                    ert.CurrentValue = revision;
                    return ert;
            }

            return null;
        }
Example #37
0
 public AnnotateSource(SvnBlameEventArgs blameArgs, SvnOrigin origin)
 {
     _args = blameArgs;
     _origin = origin;
 }
Example #38
0
        public override void OnExecute(CommandEventArgs e)
        {
            IAnkhServiceEvents ci = e.GetService <IAnkhServiceEvents>();

            if (ci != null)
            {
                ci.OnLastChanged(new LastChangedEventArgs(null, null));
            }

            SvnRevision rev;
            bool        allowUnversionedObstructions = false;
            bool        updateExternals  = true;
            bool        setDepthInfinity = true;

            IAnkhSolutionSettings settings = e.GetService <IAnkhSolutionSettings>();
            ISvnStatusCache       cache    = e.GetService <ISvnStatusCache>();
            IProjectFileMapper    mapper   = e.GetService <IProjectFileMapper>();
            Uri reposRoot = null;

            if (IsHeadCommand(e.Command) || e.DontPrompt)
            {
                rev = SvnRevision.Head;
            }
            else if (IsSolutionCommand(e.Command))
            {
                SvnItem projectItem = settings.ProjectRootSvnItem;

                Debug.Assert(projectItem != null, "Has item");

                using (UpdateDialog ud = new UpdateDialog())
                {
                    ud.ItemToUpdate = projectItem;
                    ud.Revision     = SvnRevision.Head;

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

                    rev = ud.Revision;
                    allowUnversionedObstructions = ud.AllowUnversionedObstructions;
                    updateExternals  = ud.UpdateExternals;
                    setDepthInfinity = ud.SetDepthInfinty;
                }
            }
            else if (IsFolderCommand(e.Command))
            {
                SvnItem dirItem = EnumTools.GetFirst(e.Selection.GetSelectedSvnItems(false));

                Debug.Assert(dirItem != null && dirItem.IsDirectory && dirItem.IsVersioned);

                using (UpdateDialog ud = new UpdateDialog())
                {
                    ud.Text            = CommandStrings.UpdateFolder;
                    ud.FolderLabelText = CommandStrings.UpdateFolderLabel;
                    ud.ItemToUpdate    = dirItem;
                    ud.Revision        = SvnRevision.Head;

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

                    rev = ud.Revision;
                    allowUnversionedObstructions = ud.AllowUnversionedObstructions;
                    updateExternals  = ud.UpdateExternals;
                    setDepthInfinity = ud.SetDepthInfinty;
                }
            }
            else
            {
                // We checked there was only a single repository to select a revision
                // from in OnUpdate, so we can suffice with only calculate the path

                SvnItem   si     = null;
                SvnOrigin origin = null;
                foreach (SccProject p in GetSelectedProjects(e))
                {
                    ISccProjectInfo pi = mapper.GetProjectInfo(p);
                    if (pi == null || pi.ProjectDirectory == null)
                    {
                        continue;
                    }

                    SvnItem item = cache[pi.ProjectDirectory];
                    if (!item.IsVersioned)
                    {
                        continue;
                    }

                    if (si == null && origin == null)
                    {
                        si        = item;
                        origin    = new SvnOrigin(item);
                        reposRoot = item.WorkingCopy.RepositoryRoot;
                    }
                    else
                    {
                        si = null;
                        string urlPath1 = origin.Uri.AbsolutePath;
                        string urlPath2 = item.Uri.AbsolutePath;

                        int i = 0;
                        while (i < urlPath1.Length && i < urlPath2.Length &&
                               urlPath1[i] == urlPath2[i])
                        {
                            i++;
                        }

                        while (i > 0 && urlPath1[i - 1] != '/')
                        {
                            i--;
                        }

                        origin = new SvnOrigin(new Uri(origin.Uri, urlPath1.Substring(0, i)), origin.RepositoryRoot);
                    }
                }

                Debug.Assert(origin != null);

                using (UpdateDialog ud = new UpdateDialog())
                {
                    ud.Text = CommandStrings.UpdateProject;

                    if (si != null)
                    {
                        ud.ItemToUpdate = si;
                    }
                    else
                    {
                        ud.SvnOrigin = origin;
                        ud.SetMultiple(true);
                    }

                    ud.Revision = SvnRevision.Head;

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

                    rev = ud.Revision;
                    allowUnversionedObstructions = ud.AllowUnversionedObstructions;
                    updateExternals  = ud.UpdateExternals;
                    setDepthInfinity = ud.SetDepthInfinty;
                }
            }

            Dictionary <string, SvnItem>     itemsToUpdate = new Dictionary <string, SvnItem>(StringComparer.OrdinalIgnoreCase);
            SortedList <string, UpdateGroup> groups        = new SortedList <string, UpdateGroup>(StringComparer.OrdinalIgnoreCase);

            // Get a list of all documents below the specified paths that are open in editors inside VS
            HybridCollection <string> lockPaths       = new HybridCollection <string>(StringComparer.OrdinalIgnoreCase);
            IAnkhOpenDocumentTracker  documentTracker = e.GetService <IAnkhOpenDocumentTracker>();

            foreach (SvnItem item in GetAllUpdateRoots(e))
            {
                // GetAllUpdateRoots can (and probably will) return duplicates!

                if (itemsToUpdate.ContainsKey(item.FullPath) || !item.IsVersioned)
                {
                    continue;
                }

                SvnWorkingCopy wc = item.WorkingCopy;

                if (!IsHeadCommand(e.Command) && reposRoot != null)
                {
                    // Specific revisions are only valid on a single repository!
                    if (wc != null && wc.RepositoryRoot != reposRoot)
                    {
                        continue;
                    }
                }

                UpdateGroup group;

                if (!groups.TryGetValue(wc.FullPath, out group))
                {
                    group = new UpdateGroup(wc.FullPath);
                    groups.Add(wc.FullPath, group);
                }

                group.Nodes.Add(item.FullPath);
                itemsToUpdate.Add(item.FullPath, item);

                foreach (string file in documentTracker.GetDocumentsBelow(item.FullPath))
                {
                    if (!lockPaths.Contains(file))
                    {
                        lockPaths.Add(file);
                    }
                }
            }

            documentTracker.SaveDocuments(lockPaths); // Make sure all files are saved before updating/merging!

            using (DocumentLock lck = documentTracker.LockDocuments(lockPaths, DocumentLockType.NoReload))
                using (lck.MonitorChangesForReload())
                {
                    SvnUpdateResult updateResult = null;

                    ProgressRunnerArgs pa = new ProgressRunnerArgs();
                    pa.CreateLog = true;

                    string title;

                    if (IsSolutionCommand(e.Command))
                    {
                        title = CommandStrings.UpdatingSolution;
                    }
                    else if (IsFolderCommand(e.Command))
                    {
                        title = CommandStrings.UpdatingFolder;
                    }
                    else
                    {
                        title = CommandStrings.UpdatingProject;
                    }

                    e.GetService <IProgressRunner>().RunModal(title, pa,
                                                              delegate(object sender, ProgressWorkerArgs a)
                    {
                        PerformUpdate(e, a, rev, allowUnversionedObstructions, updateExternals, setDepthInfinity, groups.Values, out updateResult);
                    });

                    if (ci != null && updateResult != null && IsSolutionCommand(e.Command))
                    {
                        ci.OnLastChanged(new LastChangedEventArgs(CommandStrings.UpdatedToTitle, updateResult.Revision.ToString()));
                    }
                }
        }
Example #39
0
        public override void OnExecute(CommandEventArgs e)
        {
            List <SvnOrigin> targets  = new List <SvnOrigin>();
            SvnRevision      startRev = SvnRevision.Zero;
            SvnRevision      endRev   = null;

            switch (e.Command)
            {
            case AnkhCommand.ItemAnnotate:
                endRev = SvnRevision.Working;
                foreach (SvnItem i in e.Selection.GetSelectedSvnItems(false))
                {
                    if (i.IsFile && i.IsVersioned && i.HasCopyableHistory)
                    {
                        targets.Add(new SvnOrigin(i));
                    }
                }
                break;

            case AnkhCommand.LogAnnotateRevision:
                foreach (ISvnLogChangedPathItem logItem in e.Selection.GetSelection <ISvnLogChangedPathItem>())
                {
                    targets.Add(logItem.Origin);
                    endRev = logItem.Revision;
                }
                break;

            case AnkhCommand.SvnNodeAnnotate:
                foreach (ISvnRepositoryItem item in e.Selection.GetSelection <ISvnRepositoryItem>())
                {
                    targets.Add(item.Origin);
                    endRev = item.Revision;
                }
                break;

            case AnkhCommand.DocumentAnnotate:
                //TryObtainBlock(e);
                targets.Add(new SvnOrigin(e.GetService <ISvnStatusCache>()[e.Selection.ActiveDocumentFilename]));
                endRev = SvnRevision.Working;
                break;
            }

            if (targets.Count == 0)
            {
                return;
            }

            bool             ignoreEols        = true;
            SvnIgnoreSpacing ignoreSpacing     = SvnIgnoreSpacing.IgnoreSpace;
            bool             retrieveMergeInfo = false;
            SvnOrigin        target;

            if ((!e.DontPrompt && !Shift) || e.PromptUser)
            {
                using (AnnotateDialog dlg = new AnnotateDialog())
                {
                    dlg.SetTargets(targets);
                    dlg.StartRevision = startRev;
                    dlg.EndRevision   = endRev;

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

                    target            = dlg.SelectedTarget;
                    startRev          = dlg.StartRevision;
                    endRev            = dlg.EndRevision;
                    ignoreEols        = dlg.IgnoreEols;
                    ignoreSpacing     = dlg.IgnoreSpacing;
                    retrieveMergeInfo = dlg.RetrieveMergeInfo;
                }
            }
            else
            {
                SvnItem one = EnumTools.GetFirst(e.Selection.GetSelectedSvnItems(false));

                if (one == null)
                {
                    return;
                }

                target = new SvnOrigin(one);
            }

            if (startRev == SvnRevision.Working || endRev == SvnRevision.Working && target.Target is SvnPathTarget)
            {
                IAnkhOpenDocumentTracker tracker = e.GetService <IAnkhOpenDocumentTracker>();
                if (tracker != null)
                {
                    tracker.SaveDocument(((SvnPathTarget)target.Target).FullPath);
                }
            }

            DoBlame(e, target, startRev, endRev, ignoreEols, ignoreSpacing, retrieveMergeInfo);
        }
Example #40
0
 public AnnotateSource(SvnBlameEventArgs blameArgs, SvnOrigin origin)
 {
     _args   = blameArgs;
     _origin = origin;
 }
        public override void OnExecute(CommandEventArgs e)
        {
            ThreadHelper.ThrowIfNotOnUIThread();

            Uri selectedUri = null;
            Uri rootUri     = null;

            bool addingProject = (e.Command == AnkhCommand.FileFileAddFromSubversion ||
                                  e.Command == AnkhCommand.FileSccAddFromSubversion);

            if (e.Argument is string && Uri.TryCreate((string)e.Argument, UriKind.Absolute, out selectedUri))
            {
            }
            else if (e.Argument is SvnOrigin)
            {
                SvnOrigin origin = (SvnOrigin)e.Argument;
                selectedUri = origin.Uri;
                rootUri     = origin.RepositoryRoot;
            }
            else if (e.Argument is Uri)
            {
                selectedUri = (Uri)e.Argument;
            }

            IAnkhSolutionSettings settings = e.GetService <IAnkhSolutionSettings>();

            if (e.PromptUser || selectedUri == null)
            {
                using (RepositoryOpenDialog dlg = new RepositoryOpenDialog())
                {
                    if (addingProject)
                    {
                        dlg.Text = CommandStrings.AddProjectFromSubversion;
                    }

                    dlg.Filter = settings.OpenProjectFilterName + "|" + settings.AllProjectExtensionsFilter + "|All Files (*.*)|*";

                    if (selectedUri != null)
                    {
                        dlg.SelectedUri = selectedUri;
                    }

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

                    selectedUri = dlg.SelectedUri;
                    rootUri     = dlg.SelectedRepositoryRoot;
                }
            }
            else if (rootUri == null)
            {
                if (!e.GetService <IProgressRunner>().RunModal(CommandStrings.RetrievingRepositoryRoot,
                                                               delegate(object sender, ProgressWorkerArgs a)
                {
                    rootUri = a.Client.GetRepositoryRoot(selectedUri);
                }).Succeeded)
                {
                    return;
                }
            }

            string defaultPath = settings.NewProjectLocation;

            if (addingProject)
            {
                IAnkhSolutionSettings ss = e.GetService <IAnkhSolutionSettings>();

                if (!string.IsNullOrEmpty(ss.ProjectRoot))
                {
                    defaultPath = ss.ProjectRoot;
                }
            }

            string name = Path.GetFileNameWithoutExtension(SvnTools.GetFileName(selectedUri));

            string newPath;
            int    n = 0;

            do
            {
                newPath = Path.Combine(defaultPath, name);
                if (n > 0)
                {
                    newPath += string.Format("({0})", n);
                }
                n++;
            }while (File.Exists(newPath) || Directory.Exists(newPath));

            using (CheckoutProject dlg = new CheckoutProject())
            {
                dlg.Context = e.Context;

                if (addingProject)
                {
                    dlg.Text = CommandStrings.AddProjectFromSubversion;
                }
                dlg.ProjectUri        = selectedUri;
                dlg.RepositoryRootUri = rootUri;
                dlg.SelectedPath      = newPath;
                dlg.SvnOrigin         = new SvnOrigin(selectedUri, rootUri);
                dlg.HandleCreated    += delegate
                {
                    FindRoot(e.Context, selectedUri, dlg);
                };

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

                if (!addingProject)
                {
                    OpenSolution(e, dlg);
                }
                else
                {
                    CheckOutAndOpenProject(e, dlg.ProjectTop, dlg.Revision, dlg.ProjectTop, dlg.SelectedPath, dlg.ProjectUri);
                }
            }
        }
Example #42
0
        public override void OnExecute(CommandEventArgs e)
        {
            List<SvnOrigin> targets = new List<SvnOrigin>();
            SvnRevision startRev = SvnRevision.Zero;
            SvnRevision endRev = null;
            switch (e.Command)
            {
                case AnkhCommand.ItemAnnotate:
                    endRev = SvnRevision.Base;
                    foreach (SvnItem i in e.Selection.GetSelectedSvnItems(false))
                    {
                        if (i.IsVersionable)
                            targets.Add(new SvnOrigin(i));
                    }
                    break;
                case AnkhCommand.LogAnnotateRevision:
                    foreach (ISvnLogChangedPathItem logItem in e.Selection.GetSelection<ISvnLogChangedPathItem>())
                    {
                        targets.Add(logItem.Origin);
                        endRev = logItem.Revision;
                    }
                    break;
                case AnkhCommand.SvnNodeAnnotate:
                    foreach (ISvnRepositoryItem item in e.Selection.GetSelection<ISvnRepositoryItem>())
                    {
                        targets.Add(item.Origin);
                        endRev = item.Revision;
                    }
                    break;
                case AnkhCommand.DocumentAnnotate:
                    targets.Add(new SvnOrigin(e.GetService<IFileStatusCache>()[e.Selection.ActiveDocumentFilename]));
                    endRev = SvnRevision.Base;
                    break;
            }

            if (targets.Count == 0)
                return;

            bool ignoreEols = true;
            SvnIgnoreSpacing ignoreSpacing = SvnIgnoreSpacing.IgnoreSpace;
            bool retrieveMergeInfo = false;
            SvnOrigin target;

            if ((!e.DontPrompt && !Shift) || e.PromptUser)
                using (AnnotateDialog dlg = new AnnotateDialog())
                {
                    dlg.SetTargets(targets);
                    dlg.StartRevision = startRev;
                    dlg.EndRevision = endRev;

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

                    target = dlg.SelectedTarget;
                    startRev = dlg.StartRevision;
                    endRev = dlg.EndRevision;
                    ignoreEols = dlg.IgnoreEols;
                    ignoreSpacing = dlg.IgnoreSpacing;
                    retrieveMergeInfo = dlg.RetrieveMergeInfo;
                }
            else
            {
                SvnItem one = EnumTools.GetFirst(e.Selection.GetSelectedSvnItems(false));

                if (one == null)
                    return;

                target = new SvnOrigin(one);
            }

            DoBlame(e, target, startRev, endRev, ignoreEols, ignoreSpacing, retrieveMergeInfo);
        }
Example #43
0
        public AnkhRevisionType Resolve(SvnOrigin origin, AnkhRevisionType revision)
        {
            if (revision == null)
                throw new ArgumentNullException("revision");

            foreach (IAnkhRevisionProvider p in _providers)
            {
                AnkhRevisionType r = p.Resolve(origin, revision);

                if (r != null)
                    return r;
            }

            return Resolve(origin, revision.CurrentValue);
        }
Example #44
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            if (FileCache != null && !string.IsNullOrEmpty(OriginPath))
            {
                SvnItem item = FileCache[OriginPath];

                if (item.IsVersioned)
                    _baseOrigin = new SvnOrigin(item);

                revisionPicker.Context = Context;
                revisionPicker.Revision = SvnRevision.Working;
                revisionPicker.SvnOrigin = _baseOrigin;
            }
        }
Example #45
0
        private void browseButton_Click(object sender, EventArgs e)
        {
            using (RepositoryFolderBrowserDialog dlg = new RepositoryFolderBrowserDialog())
            {
                SvnOrigin from = SelectedTarget;

                if (from == null)
                    return;

                dlg.ShowFiles = true;

                SvnUriTarget ut = from.Target as SvnUriTarget;
                if (ut != null)
                    dlg.SelectedUri = ut.Uri;
                else
                {
                    SvnItem file = GetService<IFileStatusCache>()[((SvnPathTarget)from.Target).FullPath];

                    if (file.Uri == null)
                        dlg.SelectedUri = from.RepositoryRoot;
                    else
                        dlg.SelectedUri = file.Uri;
                }

                if (dlg.ShowDialog(Context) == DialogResult.OK)
                {
                    Uri selectedUri = dlg.SelectedUri;

                    SvnOrigin o = new SvnOrigin(Context, selectedUri, null);

                    targetBox.Items.Add(o);
                    targetBox.SelectedItem = o;
                }
            }
        }
        private static void AutoOpenCommand(CommandEventArgs e, SvnOrigin origin)
        {
            IAnkhCommandService svc = e.GetService<IAnkhCommandService>();
            IAnkhSolutionSettings solutionSettings = e.GetService<IAnkhSolutionSettings>();

            if (svc == null || solutionSettings == null)
                return;

            // Ok, we can assume we have a file
            string filename = origin.Target.FileName;
            string ext = Path.GetExtension(filename);

            if (string.IsNullOrEmpty(ext))
            {
                // No extension -> Open as text
                svc.PostExecCommand(AnkhCommand.ViewInVsText);
                return;
            }

            foreach (string projectExt in solutionSettings.AllProjectExtensionsFilter.Split(';'))
            {
                if (projectExt.TrimStart('*').Trim().Equals(ext, StringComparison.OrdinalIgnoreCase))
                {
                    // We found a project or solution, use Open from Subversion to create a checkout

                    svc.PostExecCommand(AnkhCommand.FileFileOpenFromSubversion, origin);
                    return;
                }
            }

            bool odd = false;
            foreach (string block in solutionSettings.OpenFileFilter.Split('|'))
            {
                odd = !odd;
                if (odd)
                    continue;

                foreach (string itemExt in block.Split(';'))
                {
                    if (itemExt.TrimStart('*').Trim().Equals(ext, StringComparison.OrdinalIgnoreCase))
                    {
                        svc.PostExecCommand(AnkhCommand.ViewInVsNet);
                        return;
                    }
                }
            }

            // Ultimate fallback: Just ask the user what to do (don't trust the repository!)
            svc.PostExecCommand(AnkhCommand.ViewInWindowsWith);
        }
Example #47
0
        public void DoBlame(CommandEventArgs e,
                            SvnOrigin origin,
                            SvnRevision revisionStart,
                            SvnRevision revisionEnd,
                            bool ignoreEols,
                            SvnIgnoreSpacing ignoreSpacing,
                            bool retrieveMergeInfo)
        {
            // There are two SVN related operations:
            // [1] Getting the file at revisionEnd, which will be displayed in the editor
            // [2] Getting the blame information, which will be displayed in the margin

            // This is the parameter structure for [1] getting the file
            SvnWriteArgs wa = new SvnWriteArgs();

            wa.Revision = revisionEnd;

            // This is the parameter structure for [2] getting the blame information
            SvnBlameArgs ba = new SvnBlameArgs();

            ba.Start                   = revisionStart;
            ba.End                     = revisionEnd;
            ba.IgnoreLineEndings       = ignoreEols;
            ba.IgnoreSpacing           = ignoreSpacing;
            ba.RetrieveMergedRevisions = retrieveMergeInfo;

            SvnTarget target = origin.Target;

            // Can we make this an MEF service?
            IAnkhTempFileManager tempMgr = e.GetService <IAnkhTempFileManager>();
            string tempFile = tempMgr.GetTempFileNamed(target.FileName);

            Collection <SvnBlameEventArgs> blameResult = null;

            bool retry             = false;
            ProgressRunnerResult r = e.GetService <IProgressRunner>().RunModal("Annotating", delegate(object sender, ProgressWorkerArgs ee)
            {
                // Here we [1] get the file at revisionEnd
                using (FileStream fs = File.Create(tempFile))
                {
                    ee.Client.Write(target, fs, wa);
                }

                // Here we [2] get the blame information
                ba.SvnError +=
                    delegate(object errorSender, SvnErrorEventArgs errorEventArgs)
                {
                    if (errorEventArgs.Exception is SvnClientBinaryFileException)
                    {
                        retry = true;
                        errorEventArgs.Cancel = true;
                    }
                };
                ee.Client.GetBlame(target, ba, out blameResult);
            });

            if (retry)
            {
                using (AnkhMessageBox mb = new AnkhMessageBox(e.Context))
                {
                    // Move to resources later :)
                    if (DialogResult.Yes != mb.Show("You are trying to annotate a binary file. Are you sure you want to continue?",
                                                    "Binary file detected",
                                                    MessageBoxButtons.YesNo, MessageBoxIcon.Information))
                    {
                        return;
                    }

                    r = e.GetService <IProgressRunner>()
                        .RunModal("Annotating",
                                  delegate(object sender, ProgressWorkerArgs ee)
                    {
                        ba.IgnoreMimeType = true;
                        ee.Client.GetBlame(target, ba, out blameResult);
                    });
                }
            }

            if (!r.Succeeded)
            {
                return;
            }

            // Create a parameter struture and add it to our internal map.
            // Creating the actual view model class is now deferred to the GetModel method.
            var annParam = new AnnotateMarginParameters {
                Context = e.Context, Origin = origin, BlameResult = blameResult
            };

            _ViewModelMap.Add(tempFile, annParam);

            // Open the editor.
            // ToDo: Open files like resx as code.
            var dte = e.GetService <DTE> (typeof(SDTE));

            dte.ItemOperations.OpenFile(tempFile, EnvDTE.Constants.vsViewKindTextView);
        }