public void StartMergesMerged(IVisualGitServiceProvider context, GitItem target, string source)
        {
            if (target == null)
                throw new ArgumentNullException("target");

            GitOrigin origin = new GitOrigin(target);
            _origins = new GitOrigin[] { origin };
            UpdateTitle();
            logControl.StartMergesMerged(context, origin, source);
        }
Beispiel #2
0
 public AnnotateSource(GitBlameEventArgs blameArgs, GitOrigin origin)
 {
     _args = blameArgs;
     _origin = origin;
 }
        /// <summary>
        /// Resolves the specified revision.
        /// </summary>
        /// <param name="origin"></param>
        /// <param name="revision">The revision.</param>
        /// <returns></returns>
        public VisualGitRevisionType Resolve(GitOrigin origin, GitRevision revision)
        {
            if (revision == null)
                throw new ArgumentNullException("revision");

            foreach (IVisualGitRevisionProvider p in _providers)
            {
                VisualGitRevisionType r = p.Resolve(origin, revision);

                if (r != null)
                    return r;
            }

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

            return null;
        }
        public void StartLog(GitOrigin target, GitRevision start, GitRevision end)
        {
            if (target == null)
                throw new ArgumentNullException("target");

            StartLog(new GitOrigin[] { target }, start, end);
        }
 public VisualGitRevisionType Resolve(GitOrigin origin, VisualGitRevisionType revision)
 {
     return Resolve(origin, revision.CurrentValue);
 }
 public override bool IsValidOn(GitOrigin origin)
 {
     switch (_rev.RevisionType)
     {
         case GitRevisionType.Base:
         case GitRevisionType.Committed:
         case GitRevisionType.Previous:
         case GitRevisionType.Working:
             return true;
         default:
             return base.IsValidOn(origin);
     }
 }
            public ExplicitRevisionType(IVisualGitServiceProvider context, GitOrigin origin)
            {
                if (context == null)
                    throw new ArgumentNullException("context");
                else if (origin == null)
                    throw new ArgumentNullException("origin");

                _context = context;
                _origin = origin;
            }
            public VisualGitRevisionType Resolve(GitOrigin origin, GitRevision revision)
            {
                if (revision == null)
                    throw new ArgumentNullException("revision");

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

                return null;
            }
        public VisualGitRevisionType Resolve(GitOrigin origin, VisualGitRevisionType revision)
        {
            if (revision == null)
                throw new ArgumentNullException("revision");

            foreach (IVisualGitRevisionProvider p in _providers)
            {
                VisualGitRevisionType r = p.Resolve(origin, revision);

                if (r != null)
                    return r;
            }

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

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

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

                revisionPicker.Context = Context;
                revisionPicker.Revision = GitRevision.Working;
                revisionPicker.GitOrigin = _baseOrigin;
            }
        }
        public override void OnExecute(CommandEventArgs e)
        {
            List<GitOrigin> targets = new List<GitOrigin>();
            GitRevision endRev = null;
            switch (e.Command)
            {
                case VisualGitCommand.ItemAnnotate:
                    endRev = GitRevision.Base;
                    foreach (GitItem i in e.Selection.GetSelectedGitItems(false))
                    {
                        if (i.IsVersionable)
                            targets.Add(new GitOrigin(i));
                    }
                    break;
                case VisualGitCommand.LogAnnotateRevision:
                    foreach (IGitLogChangedPathItem logItem in e.Selection.GetSelection<IGitLogChangedPathItem>())
                    {
                        targets.Add(logItem.Origin);
                        endRev = logItem.Revision;
                    }
                    break;
                case VisualGitCommand.GitNodeAnnotate:
                    foreach (IGitRepositoryItem item in e.Selection.GetSelection<IGitRepositoryItem>())
                    {
                        targets.Add(item.Origin);
                        endRev = item.Revision;
                    }
                    break;
                case VisualGitCommand.DocumentAnnotate:
                    targets.Add(new GitOrigin(e.GetService<IFileStatusCache>()[e.Selection.ActiveDocumentFilename]));
                    endRev = GitRevision.Base;
                    break;
            }

            if (targets.Count == 0)
                return;

            GitIgnoreSpacing ignoreSpacing = GitIgnoreSpacing.IgnoreSpace;
            GitOrigin target;

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

                    dlg.EndRevision = endRev;

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

                    target = dlg.SelectedTarget;
                    endRev = dlg.EndRevision;
                    ignoreSpacing = dlg.IgnoreSpacing;
                }
            else
            {
                GitItem one = EnumTools.GetFirst(e.Selection.GetSelectedGitItems(false));

                if (one == null)
                    return;

                target = new GitOrigin(one);
            }

            DoBlame(e, target, endRev, ignoreSpacing);
        }
        static void DoBlame(CommandEventArgs e, GitOrigin item, GitRevision revisionEnd, GitIgnoreSpacing ignoreSpacing)
        {
            GitWriteArgs wa = new GitWriteArgs();
            wa.Revision = revisionEnd;

            GitBlameArgs ba = new GitBlameArgs();
            ba.End = revisionEnd;
            ba.IgnoreSpacing = ignoreSpacing;

            GitTarget target = item.Target;

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

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

            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);
                }
                try
                {
                    ee.Client.GetBlame(target, ba, out blameResult);
                }
                catch (GitClientBinaryFileException)
                {
                    retry = true;
                }
            });

            if (retry)
            {
                using (VisualGitMessageBox mb = new VisualGitMessageBox(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)
                                      {
                                          ee.Client.GetBlame(target, ba, out blameResult);
                                      });
                    }
                }
            }

            if (!r.Succeeded)
                return;

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

            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);
                    }
                }
            }
        }
Beispiel #13
0
 public LogViewerDialog(GitOrigin target)
     : this()
 {
     LogTarget = target;
 }