示例#1
0
        public override Annotation[] GetAnnotations(FilePath repositoryPath)
        {
            List <Annotation> annotations = new List <Annotation> (Svn.GetAnnotations(this, repositoryPath, SvnRevision.First, SvnRevision.Base));
            Annotation        nextRev     = new Annotation(GettextCatalog.GetString("working copy"), "<uncommitted>", DateTime.MinValue);
            var baseDocument    = Mono.TextEditor.TextDocument.CreateImmutableDocument(GetBaseText(repositoryPath));
            var workingDocument = Mono.TextEditor.TextDocument.CreateImmutableDocument(File.ReadAllText(repositoryPath));

            // "SubversionException: blame of the WORKING revision is not supported"
            foreach (var hunk in baseDocument.Diff(workingDocument))
            {
                annotations.RemoveRange(hunk.RemoveStart - 1, hunk.Removed);
                for (int i = 0; i < hunk.Inserted; ++i)
                {
                    if (hunk.InsertStart + i >= annotations.Count)
                    {
                        annotations.Add(nextRev);
                    }
                    else
                    {
                        annotations.Insert(hunk.InsertStart - 1, nextRev);
                    }
                }
            }

            return(annotations.ToArray());
        }
        public override async Task <Annotation []> GetAnnotationsAsync(FilePath repositoryPath, Revision since, CancellationToken cancellationToken)
        {
            SvnRevision       sinceRev    = since != null ? (SvnRevision)since : null;
            List <Annotation> annotations = new List <Annotation> (Svn.GetAnnotations(this, repositoryPath, SvnRevision.First, sinceRev ?? SvnRevision.Base));
            Annotation        nextRev     = new Annotation(null, GettextCatalog.GetString("<uncommitted>"), DateTime.MinValue, null, GettextCatalog.GetString("working copy"));
            var baseDocument    = Mono.TextEditor.TextDocument.CreateImmutableDocument(await GetBaseTextAsync(repositoryPath, cancellationToken).ConfigureAwait(false));
            var workingDocument = Mono.TextEditor.TextDocument.CreateImmutableDocument(File.ReadAllText(repositoryPath));

            // "SubversionException: blame of the WORKING revision is not supported"
            if (sinceRev == null)
            {
                foreach (var hunk in baseDocument.Diff(workingDocument, includeEol: false))
                {
                    annotations.RemoveRange(hunk.RemoveStart - 1, hunk.Removed);
                    for (int i = 0; i < hunk.Inserted; ++i)
                    {
                        if (hunk.InsertStart + i >= annotations.Count)
                        {
                            annotations.Add(nextRev);
                        }
                        else
                        {
                            annotations.Insert(hunk.InsertStart - 1, nextRev);
                        }
                    }
                }
            }

            return(annotations.ToArray());
        }
示例#3
0
        public override Annotation[] GetAnnotations(FilePath localPath)
        {
            List <Annotation> annotations = new List <Annotation> (Svn.GetAnnotations(this, localPath, SvnRevision.First, SvnRevision.Base));
            Annotation        nextRev     = new Annotation(GettextCatalog.GetString("working copy"), "", DateTime.MinValue);
            var baseDocument    = new Mono.TextEditor.Document(File.ReadAllText(GetPathToBaseText(localPath)));
            var workingDocument = new Mono.TextEditor.Document(File.ReadAllText(localPath));

            // "SubversionException: blame of the WORKING revision is not supported"
            foreach (var hunk in baseDocument.Diff(workingDocument))
            {
                annotations.RemoveRange(hunk.InsertStart, hunk.Inserted);
                for (int i = 0; i < hunk.Inserted; ++i)
                {
                    annotations.Insert(hunk.InsertStart, nextRev);
                }
            }

            return(annotations.ToArray());
        }