コード例 #1
0
ファイル: View.aspx.cs プロジェクト: wlshitou/svnquery
        protected void Page_Load(object sender, EventArgs e)
        {
            HitViewModel hitViewModel = ApplicationIndex.GetHitById(Context.Request.QueryString["id"]);
            string       path         = hitViewModel.Path;
            int          revision     = hitViewModel.Revision;

            // getting _properties from the index
            Title               = path.Substring(path.LastIndexOf('/') + 1);
            _header.InnerText   = path;
            _author.InnerText   = hitViewModel.Author;
            _modified.InnerText = hitViewModel.LastModification;
            if (hitViewModel.MaxSize > 0)
            {
                _size.InnerText = hitViewModel.Size;
            }
            else
            {
                _sizeRow.Visible = false;
            }
            _revisions.InnerText = hitViewModel.RevFirst + " - " + hitViewModel.RevLast;

            // getting _properties from subversion
            _message.InnerText = Svn.GetLogMessage(revision);

            if (path[0] == '$')
            {
                return;                 // Revision Log
            }
            bool binary = InitProperties(Svn.GetPathProperties(path, revision));

            if (hitViewModel.MaxSize > 512 * 1024)
            {
                _contentWarning.InnerText = "Content size is too big to display";
            }
            else if (binary)
            {
                _contentWarning.InnerText = "Content type is binary";
            }
            else if (hitViewModel.MaxSize > 0)
            {
                _content.InnerText = Svn.GetPathContent(path, revision, hitViewModel.MaxSize);

                var syntaxHighlighter = new SyntaxHighlightBrushMapper(path);
                if (syntaxHighlighter.IsAvailable)
                {
                    AddScriptInclude(syntaxHighlighter.GetScript());
                    AddStartupScript();
                    _content.Attributes.Add("class", syntaxHighlighter.GetClass());
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Fetches some more information from the repository for an item
        /// </summary>
        /// <param name="jobData"></param>
        void FetchJob(IndexJobData jobData)
        {
            if (!_args.SingleRevision || jobData.RevisionLast == Revision.Head) // don't fetch if this data would be deleted anyway
            {
                if (_args.Verbosity > 1)
                {
                    Console.WriteLine("Fetch          " + jobData.Path + "   " + jobData.RevisionFirst + ":" + jobData.RevisionLast);
                }

                jobData.Properties = _svn.GetPathProperties(jobData.Path, jobData.RevisionFirst);
                if (IsIndexable(jobData))
                {
                    jobData.Content = _svn.GetPathContent(jobData.Path, jobData.RevisionFirst, jobData.Info.Size);
                }
            }
            QueueIndexJob(jobData);
        }
コード例 #3
0
        public void ShowContent(ISvnApi svn)
        {
            if (Path[0] == '$')
            {
                ShowLogMessage(svn);
                return;
            }

            try
            {
                string path = GetTempPath();
                IOFile.WriteAllText(path, svn.GetPathContent(Path, Revision, SizeInBytes));
                Process.Start(Settings.Default.ViewWith, '"' + path + '"');
                Thread.Sleep(500); // starting the viewer application could take a while, therefore we display the wait cursor for at least half a second
            }
            catch (Exception x)
            {
                MessageBox.Show(Dump.ExceptionMessage(x), "Could not open file", MessageBoxButton.OK, MessageBoxImage.Warning);
            }
        }
コード例 #4
0
        public void GetPathContent_Revision17_Content()
        {
            var content = api.GetPathContent("/Folder/Second/first.txt", 17, 10);

            Assert.That(content, Is.EqualTo("hullebulle"));
        }