Beispiel #1
0
        public void ParseBlame(string fileName, int lineNumber)
        {
            CaseSensFileName = GetProperFilePathCapitalization(fileName);
            Revision         = 0;
            Author           = "unknown";

            try
            {
                using (var client = new SvnClient())
                {
                    client.Authentication.DefaultCredentials = new NetworkCredential("vivabuild", "#%tsargWV45!@^@gvtRSW");
                    SvnTarget target = SvnPathTarget.FromString(CaseSensFileName);
                    Collection <SvnBlameEventArgs> list;
                    client.GetBlame(target, out list);
                    int idx = lineNumber - 1;
                    if (0 <= idx && idx < list.Count)
                    {
                        Revision = list[idx].Revision;
                        Author   = list[idx].Author;
                    }
                }
            }
            catch (Exception)
            {
                ;
            }
            AddAuthor(Author);
        }
Beispiel #2
0
        public override Annotation[] GetAnnotations(Repository repo, FilePath file, SvnRevision revStart, SvnRevision revEnd)
        {
            if (file == FilePath.Null)
            {
                throw new ArgumentNullException();
            }

            var target         = new SvnPathTarget(file, SharpSvn.SvnRevision.Base);
            var data           = new MemoryStream();
            int numAnnotations = 0;

            client.Write(target, data);

            using (var reader = new StreamReader(data)) {
                reader.BaseStream.Seek(0, SeekOrigin.Begin);
                while (reader.ReadLine() != null)
                {
                    numAnnotations++;
                }
            }

            System.Collections.ObjectModel.Collection <SvnBlameEventArgs> list;
            var args = new SvnBlameArgs();

            args.Start = GetRevision(revStart);
            args.End   = GetRevision(revEnd);

            if (client.GetBlame(target, args, out list))
            {
                var annotations = new Annotation [numAnnotations];
                foreach (var annotation in list)
                {
                    if (annotation.LineNumber < annotations.Length)
                    {
                        annotations [(int)annotation.LineNumber] = new Annotation(annotation.Revision.ToString(),
                                                                                  annotation.Author, annotation.Time);
                    }
                }
                return(annotations);
            }
            return(new Annotation[0]);
        }