The function dvc-revlist-get-rev-at-point was too specific to tla, so it
was pared down and moved back to tla.el.

Its place is taken by dvc-revlist-get-revision-at-point, which takes the
revision structure at point without trying to modify it.  The reason for
this is that bzr's bzr-dvc-name-construct function returns the name of
the tree, which is completely useless as a revision ID.  So we leave it
to the caller to know what VCS they are dealing with.
---
Committed revision 3859b6a930249350fdd42fdfd9bca06d09e3a4f4
to <git://git.hcoop.net/git/mwolson/emacs/dvc.git>.

 lisp/bzr.el         |    5 +----
 lisp/dvc-revlist.el |   20 +++++++++-----------
 lisp/tla.el         |   20 ++++++++++++++++----
 3 files changed, 26 insertions(+), 19 deletions(-)

diff --git a/lisp/bzr.el b/lisp/bzr.el
index b4359b8..ac83c9c 100644
--- a/lisp/bzr.el
+++ b/lisp/bzr.el
@@ -394,12 +394,9 @@ This is done by looking at the 'You are missing ... 
revision(s):' string in the
   (save-excursion
     (not (re-search-backward "^You are missing [0-9]+ revision(s):" nil t))))
 
-;;TODO: should be integrated in dvc-revlist-get-rev-at-point
 (defun bzr-get-revision-at-point ()
   (int-to-string
-   (nth 2 (car (dvc-revision-get-data
-                (dvc-revlist-entry-patch-rev-id
-                 (nth 1 (ewoc-data (ewoc-locate dvc-revlist-cookie)))))))))
+   (nth 2 (dvc-revlist-get-revision-at-point))))
 
 (defun bzr-send-commit-notification ()
   "Send a commit notification email for the changelog entry at point.
diff --git a/lisp/dvc-revlist.el b/lisp/dvc-revlist.el
index 7b8d919..8997296 100644
--- a/lisp/dvc-revlist.el
+++ b/lisp/dvc-revlist.el
@@ -230,17 +230,15 @@ Function used to get the revision info at point")
   (when (fboundp dvc-get-revision-info-at-point-function)
     (funcall dvc-get-revision-info-at-point-function)))
 
-;; TODO: this is still tla-oriented.
-(defun dvc-revlist-get-rev-at-point ()
-  "Get archive/category--branch--version--revision--patch information.
-Returns nil if not on a revision list, or not on a revision entry in a
-revision list."
-  (let ((elem (ewoc-data (ewoc-locate dvc-revlist-cookie))))
-    (when (eq (car elem) 'entry-patch)
-      (let* ((full (tla--revision-revision
-                    (dvc-revlist-entry-patch-struct (nth 1 elem))))
-             (buffer-revision (tla--name-construct full)))
-        (list 'revision buffer-revision)))))
+(defun dvc-revlist-get-revision-at-point ()
+  "Retrieve the revision structure at point in a DVC revlist mode buffer."
+  (let* ((entry (dvc-revlist-entry-patch-rev-id
+                 (nth 1 (ewoc-data (ewoc-locate dvc-revlist-cookie)))))
+         (type (dvc-revision-get-type entry))
+         (data (dvc-revision-get-data entry)))
+    (case type
+      (revision (nth 0 data))
+      (t (error "No revision at point")))))
 
 (autoload 'dvc-revlog-revision "dvc-revlog")
 
diff --git a/lisp/tla.el b/lisp/tla.el
index aabe4de..4268b19 100644
--- a/lisp/tla.el
+++ b/lisp/tla.el
@@ -389,7 +389,7 @@ empty."
 Further call to `tla--name-read-insert-info-at-point-final' will
 actuall insert the value computed here."
   (setq tla-name-read-insert-info-at-point
-        (let ((raw-info (cadr (dvc-get-info-at-point)))
+        (let ((raw-info (tla--revision-get-revision-at-point))
               (b (dvc-cmenu-beginning (point)))
               (e (dvc-cmenu-end (point))))
           (when raw-info
@@ -8073,7 +8073,19 @@ Else it runs asynchronously."
   "tla-revisions"
   "Major mode to show Arch revision lists:
 \\{tla-revision-list-mode-map}."
-  (use-local-map tla-revision-list-mode-map))
+  (use-local-map tla-revision-list-mode-map)
+  (set (make-local-variable 'dvc-get-revision-info-at-point-function)
+       'tla--revision-get-revision-at-point))
+
+(defun tla--revision-get-revision-at-point ()
+  "Get archive/category--branch--version--revision--patch information.
+Returns nil if not on a revision list, or not on a revision entry in a
+revision list."
+  (let ((elem (ewoc-data (ewoc-locate dvc-revlist-cookie))))
+    (when (eq (car elem) 'entry-patch)
+      (let ((full (tla--revision-revision
+                   (dvc-revlist-entry-patch-struct (nth 1 elem)))))
+        (tla--name-construct full)))))
 
 (defun tla--revision-get-version-info-at-point ()
   "Get archive/category--branch--version--revision information.
@@ -8081,13 +8093,13 @@ Returns nil if not on a revision list, or not on a 
revision entry in a
 revision list."
   (list 'version
         (tla--name-mask (tla--name-split
-                         (cadr (dvc-revlist-get-rev-at-point))) t
+                         (tla--revision-get-revision-at-point)) t
                          t t t t)))
 
 (defun tla-revision-save-revision-to-kill-ring ()
   "Save the name of the current revision to the kill ring."
   (interactive)
-  (let ((rev (cadr (dvc-revlist-get-rev-at-point))))
+  (let ((rev (tla--revision-get-revision-at-point)))
     (unless rev
       (error "No revision at point"))
     (kill-new rev)
-- 
1.5.4.3


-- 
|       Michael Olson  |  FSF Associate Member #652     |
| http://mwolson.org/  |  Hobbies: Lisp, HCoop          |
| Projects: Emacs, Muse, ERC, EMMS, ErBot, DVC, Planner |
`-------------------------------------------------------'

_______________________________________________
Dvc-dev mailing list
[email protected]
https://mail.gna.org/listinfo/dvc-dev

Reply via email to