1 ;;; planner-psvn.el --- psvn.el integration for the Emacs Planner
3 ;; Copyright (C) 2005 Stefan Reichör
5 ;; Author: Stefan Reichör <stefan@xsteve.at>
6 ;; Keywords: planner, psvn
8 ;; This file is free software; you can redistribute it and/or modify
9 ;; it under the terms of the GNU General Public License as published by
10 ;; the Free Software Foundation; either version 2, or (at your option)
13 ;; This file is distributed in the hope that it will be useful,
14 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 ;; GNU General Public License for more details.
18 ;; You should have received a copy of the GNU General Public License
19 ;; along with GNU Emacs; see the file COPYING. If not, write to
20 ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 ;; Boston, MA 02110-1301, USA.
25 ;; This file allows you to refer to your svn changesets easily from within
28 ;; Example: the changeset
29 ;; [[psvn://http://my.svn-repos.at/svn/project1/trunk@39][project1#39]]
30 ;; can be shown easily via psvn.
32 ;; Additionally there is functionality to generate a note for your
33 ;; commits via subversion, just set
34 ;; `planner-psvn-log-edit-notice-commit-function' to t.
38 ;; Seth Falcon provided a patch to write the note to planner-today
39 ;; rather than *temp*.muse.
41 ;; Yann Hodique helped port this to Muse.
48 (defgroup planner-psvn nil
49 "Planner options for the psvn integration."
50 :prefix
"planner-psvn-"
53 (defcustom planner-psvn-log-edit-include-files-flag
55 "Non-nil means include a list of committed files in the note."
59 (defcustom planner-psvn-log-edit-notice-commit-function nil
60 "Function that should return non-nil if this commit should be noted.
61 The function will be run in the log buffer."
63 (const :tag
"Always note commits" t
)
68 (defun planner-psvn-generate-url (repo-path revision
&optional link-prefix no-link-postfix
)
69 (planner-make-link (concat "psvn://" repo-path
"@" revision
)
73 (concat link-prefix revision
))
74 (concat "svn-rev#" revision
))))
77 (defun planner-annotation-from-psvn ()
78 "If called from a psvn *svn-log-view* buffer, return an annotation.
79 Suitable for use in `planner-annotation-functions'."
80 (when (eq major-mode
'svn-log-view-mode
)
81 (svn-status-parse-info t
)
82 (planner-psvn-generate-url (svn-status-base-info->url
)
83 (svn-log-revision-at-point))))
86 (defun planner-psvn-browse-url (url)
87 "If this is a psvn url, handle it."
88 (when (string-match "\\`psvn:/?/?\\(.+\\)@\\([0-9]+\\)" url
)
89 (let ((repo-path (match-string 1 url
))
90 (svn-rev (string-to-number (match-string 2 url
))))
91 (svn-run-svn nil t
'diff
"diff"
92 (concat repo-path
"@" (number-to-string (- svn-rev
1)))
93 (concat repo-path
"@" (number-to-string svn-rev
)))
94 (svn-status-diff-mode))
97 (defun planner-psvn-log-edit-extract-file-name (file-info)
98 (svn-status-line-info->filename file-info
))
101 (defun planner-psvn-log-edit-add-note ()
102 "Add a note describing the commit via psvn to the current planner page."
103 (when (if (functionp planner-psvn-log-edit-notice-commit-function
)
104 (funcall planner-psvn-log-edit-notice-commit-function
)
105 planner-psvn-log-edit-notice-commit-function
)
106 (svn-status-parse-info t
)
107 (save-window-excursion
108 (planner-create-note nil
)
110 (insert (concat " " (planner-psvn-generate-url
111 (svn-status-base-info->url
)
112 (number-to-string svn-status-commit-rev-number
)
113 (when svn-status-module-name
114 (concat svn-status-module-name
"#")))))
116 (when (and planner-psvn-log-edit-include-files-flag
117 svn-status-files-to-commit
)
119 (insert (mapconcat 'planner-psvn-log-edit-extract-file-name
120 svn-status-files-to-commit
" "))
123 (insert-buffer-substring "*svn-log-edit*"))))
125 (add-hook 'svn-log-edit-done-hook
'planner-psvn-log-edit-add-note
)
127 (planner-add-protocol "psvn:/?/?" 'planner-psvn-browse-url nil
)
128 (add-hook 'planner-annotation-functions
'planner-annotation-from-psvn
)
129 (custom-add-option 'planner-annotation-functions
'planner-annotation-from-psvn
)
131 (provide 'planner-psvn
)
133 ;;; planner-psvn.el ends here