unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* vc-annotate with bzr
@ 2008-03-13 23:53 Dan Nicolaescu
  2008-03-14 19:40 ` Stefan Monnier
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Nicolaescu @ 2008-03-13 23:53 UTC (permalink / raw)
  To: emacs-devel


The vc-annotate display with bzr (i.e. the output of
vc-bzr-annotate-command) is not consistent with the output of other 
VC backends: the annotations don't start from the same column, so it is
hard to follow. 

Should't vc-annotate for bzr work like the other VC backends? (This will
simplify the code too).




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: vc-annotate with bzr
  2008-03-13 23:53 vc-annotate with bzr Dan Nicolaescu
@ 2008-03-14 19:40 ` Stefan Monnier
  2008-03-14 20:07   ` Dan Nicolaescu
  0 siblings, 1 reply; 3+ messages in thread
From: Stefan Monnier @ 2008-03-14 19:40 UTC (permalink / raw)
  To: Dan Nicolaescu; +Cc: emacs-devel

> The vc-annotate display with bzr (i.e. the output of
> vc-bzr-annotate-command) is not consistent with the output of other 
> VC backends: the annotations don't start from the same column, so it is
> hard to follow. 

I'm not sure what you mean, but if you refer to the fact that the
annotation takes a varying amount of space which breaks alignment, I've
just installed a fix for it in the 22 branch.


        Stefan


--- vc-bzr.el.~1.11.2.11.~	2008-01-06 20:18:57.000000000 -0500
+++ vc-bzr.el	2008-03-14 15:36:52.000000000 -0400
@@ -146,13 +146,19 @@
                 (vc-bzr-state file)     ; Some other unknown format?
               (let* ((relfile (file-relative-name file root))
                      (reldir (file-name-directory relfile)))
-                (re-search-forward
+                (when (re-search-forward
                  (concat "^\0"
-                         (if reldir (regexp-quote (directory-file-name reldir)))
+                               (if reldir (regexp-quote
+                                           (directory-file-name reldir)))
                          "\0"
                          (regexp-quote (file-name-nondirectory relfile))
                          "\0")
-                 nil t)))))))))
+                       nil t)
+                  ;; Make sure `bzr' agrees that this file is under Bzr's
+                  ;; control.  This is important because if `bzr' is not
+                  ;; installed vc-find-file may otherwise get an error in
+                  ;; the subsequent call to `vc-state'.
+                  (vc-bzr-state file))))))))))
 
 (defconst vc-bzr-state-words
   "added\\|ignored\\|kind changed\\|modified\\|removed\\|renamed\\|unknown"
@@ -430,7 +436,7 @@
     ;; to allow saving space by sharing the text properties.
     (setq vc-bzr-annotation-table (make-hash-table :test 'equal))
     (goto-char (point-min))
-    (while (re-search-forward "^\\( *[0-9]+\\) +\\(.+\\) +\\([0-9]\\{8\\}\\) |"
+    (while (re-search-forward "^\\( *[0-9]+ *\\) \\([^\n ]+\\) +\\([0-9]\\{8\\}\\) |"
                               nil t)
       (let* ((rev (match-string 1))
              (author (match-string 2))
@@ -446,7 +452,7 @@
         (insert tag " |")))))
 
 (defun vc-bzr-annotate-time ()
-  (when (re-search-forward "^ *[0-9]+ |" nil t)
+  (when (re-search-forward "^ *[0-9]+ +|" nil t)
     (let ((prop (get-text-property (line-beginning-position) 'help-echo)))
       (string-match "[0-9]+\\'" prop)
       (vc-annotate-convert-time




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: vc-annotate with bzr
  2008-03-14 19:40 ` Stefan Monnier
@ 2008-03-14 20:07   ` Dan Nicolaescu
  0 siblings, 0 replies; 3+ messages in thread
From: Dan Nicolaescu @ 2008-03-14 20:07 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

Stefan Monnier <monnier@iro.umontreal.ca> writes:

  > > The vc-annotate display with bzr (i.e. the output of
  > > vc-bzr-annotate-command) is not consistent with the output of other 
  > > VC backends: the annotations don't start from the same column, so it is
  > > hard to follow. 
  > 
  > I'm not sure what you mean, but if you refer to the fact that the
  > annotation takes a varying amount of space which breaks alignment, I've
  > just installed a fix for it in the 22 branch.

Yep, I am referring to the fact that the alignment is broken.  The
alignment is seems to be still broken on the 22 branch... 

My patch (vs trunk) does not edit the output of "bzr annotate", and does
not add any properties that are not really needed...

--- vc-bzr.el.~1.29.~	Fri Mar 14 00:57:48 2008
+++ vc-bzr.el	Fri Mar 14 13:00:40 2008
@@ -461,45 +461,26 @@
 Each line is tagged with the revision number, which has a `help-echo'
 property containing author and date information."
   (apply #'vc-bzr-command "annotate" buffer 0 file "--long" "--all"
-         (if revision (list "-r" revision)))
-  (with-current-buffer buffer
-    ;; Store the tags for the annotated source lines in a hash table
-    ;; to allow saving space by sharing the text properties.
-    (setq vc-bzr-annotation-table (make-hash-table :test 'equal))
-    (goto-char (point-min))
-    (while (re-search-forward "^\\( *[0-9]+\\) +\\(.+\\) +\\([0-9]\\{8\\}\\) |"
-                              nil t)
-      (let* ((rev (match-string 1))
-             (author (match-string 2))
-             (date (match-string 3))
-             (key (match-string 0))
-             (tag (gethash key vc-bzr-annotation-table)))
-        (unless tag
-          (setq tag (propertize rev 'help-echo (concat "Author: " author
-                                                       ", date: " date)
-                                'mouse-face 'highlight))
-          (puthash key tag vc-bzr-annotation-table))
-        (replace-match "")
-        (insert tag " |")))))
+         (when revision (list "-r" revision))))
 
 (defun vc-bzr-annotate-time ()
-  (when (re-search-forward "^ *[0-9]+ |" nil t)
-    (let ((prop (get-text-property (line-beginning-position) 'help-echo)))
-      (string-match "[0-9]+\\'" prop)
+  (when (re-search-forward "^[0-9]+.* \\([0-9]+ | \\)" nil t)
+    (goto-char (match-end 1))
+    (let ((str (buffer-substring-no-properties 
+		 (match-beginning 1) (match-end 1))))
       (vc-annotate-convert-time
        (encode-time 0 0 0
-                    (string-to-number (substring (match-string 0 prop) 6 8))
-                    (string-to-number (substring (match-string 0 prop) 4 6))
-                    (string-to-number (substring (match-string 0 prop) 0 4))
-                    )))))
+                    (string-to-number (substring str 6 8))
+                    (string-to-number (substring str 4 6))
+                    (string-to-number (substring str 0 4)))))))
 
 (defun vc-bzr-annotate-extract-revision-at-line ()
   "Return revision for current line of annoation buffer, or nil.
 Return nil if current line isn't annotated."
   (save-excursion
     (beginning-of-line)
-    (if (looking-at " *\\([0-9]+\\) | ")
-        (match-string-no-properties 1))))
+    (when (looking-at "\\([0-9.]+\\) ")
+      (match-string-no-properties 1))))
 
 (defun vc-bzr-command-discarding-stderr (command &rest args)
   "Execute shell command COMMAND (with ARGS); return its output and exitcode.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-03-14 20:07 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-13 23:53 vc-annotate with bzr Dan Nicolaescu
2008-03-14 19:40 ` Stefan Monnier
2008-03-14 20:07   ` Dan Nicolaescu

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).