1 ;;; psvn.el --- Subversion interface for emacs
2 ;; Copyright (C) 2002-2008 by Stefan Reichoer
4 ;; Author: Stefan Reichoer <stefan@xsteve.at>
7 ;; psvn.el is free software; you can redistribute it and/or modify
8 ;; it under the terms of the GNU General Public License as published by
9 ;; the Free Software Foundation; either version 2, or (at your option)
12 ;; psvn.el is distributed in the hope that it will be useful,
13 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
14 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 ;; GNU General Public License for more details.
17 ;; You should have received a copy of the GNU General Public License
18 ;; along with GNU Emacs; see the file COPYING. If not, write to
19 ;; the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 ;; Boston, MA 02111-1307, USA.
24 ;; psvn.el is tested with GNU Emacs 21.3 on windows, debian linux,
25 ;; freebsd5, red hat el4, ubuntu edgy with svn 1.4.0
27 ;; psvn.el needs at least svn 1.1.0
28 ;; if you upgrade to a higher version, you need to do a fresh checkout
30 ;; psvn.el is an interface for the revision control tool subversion
31 ;; (see http://subversion.tigris.org)
32 ;; psvn.el provides a similar interface for subversion as pcl-cvs for cvs.
33 ;; At the moment the following commands are implemented:
35 ;; M-x svn-status: run 'svn -status -v'
36 ;; M-x svn-examine (like pcl-cvs cvs-examine) is alias for svn-status
38 ;; and show the result in the svn-status-buffer-name buffer (normally: *svn-status*).
39 ;; If svn-status-verbose is set to nil, only "svn status" without "-v"
40 ;; is run. Currently you have to toggle this variable manually.
41 ;; This buffer uses svn-status mode in which the following keys are defined:
42 ;; g - svn-status-update: run 'svn status -v'
43 ;; M-s - svn-status-update: run 'svn status -v'
44 ;; C-u g - svn-status-update: run 'svn status -vu'
45 ;; = - svn-status-show-svn-diff run 'svn diff'
46 ;; l - svn-status-show-svn-log run 'svn log'
47 ;; i - svn-status-info run 'svn info'
48 ;; r - svn-status-revert run 'svn revert'
49 ;; X v - svn-status-resolved run 'svn resolved'
50 ;; U - svn-status-update-cmd run 'svn update'
51 ;; M-u - svn-status-update-cmd run 'svn update'
52 ;; c - svn-status-commit run 'svn commit'
53 ;; a - svn-status-add-file run 'svn add --non-recursive'
54 ;; A - svn-status-add-file-recursively run 'svn add'
55 ;; + - svn-status-make-directory run 'svn mkdir'
56 ;; R - svn-status-mv run 'svn mv'
57 ;; C - svn-status-cp run 'svn cp'
58 ;; D - svn-status-rm run 'svn rm'
59 ;; M-c - svn-status-cleanup run 'svn cleanup'
60 ;; k - svn-status-lock run 'svn lock'
61 ;; K - svn-status-unlock run 'svn unlock'
62 ;; b - svn-status-blame run 'svn blame'
63 ;; X e - svn-status-export run 'svn export'
64 ;; RET - svn-status-find-file-or-examine-directory
65 ;; ^ - svn-status-examine-parent
66 ;; ~ - svn-status-get-specific-revision
67 ;; E - svn-status-ediff-with-revision
68 ;; X X - svn-status-resolve-conflicts
69 ;; s - svn-status-show-process-buffer
70 ;; h - svn-status-pop-to-partner-buffer
71 ;; e - svn-status-toggle-edit-cmd-flag
72 ;; ? - svn-status-toggle-hide-unknown
73 ;; _ - svn-status-toggle-hide-unmodified
74 ;; m - svn-status-set-user-mark
75 ;; u - svn-status-unset-user-mark
76 ;; $ - svn-status-toggle-elide
77 ;; w - svn-status-copy-current-line-info
78 ;; DEL - svn-status-unset-user-mark-backwards
79 ;; * ! - svn-status-unset-all-usermarks
80 ;; * ? - svn-status-mark-unknown
81 ;; * A - svn-status-mark-added
82 ;; * M - svn-status-mark-modified
83 ;; * D - svn-status-mark-deleted
84 ;; * * - svn-status-mark-changed
85 ;; * . - svn-status-mark-by-file-ext
86 ;; * % - svn-status-mark-filename-regexp
87 ;; . - svn-status-goto-root-or-return
88 ;; f - svn-status-find-file
89 ;; o - svn-status-find-file-other-window
90 ;; C-o - svn-status-find-file-other-window-noselect
91 ;; v - svn-status-view-file-other-window
92 ;; I - svn-status-parse-info
93 ;; V - svn-status-svnversion
94 ;; P l - svn-status-property-list
95 ;; P s - svn-status-property-set
96 ;; P d - svn-status-property-delete
97 ;; P e - svn-status-property-edit-one-entry
98 ;; P i - svn-status-property-ignore-file
99 ;; P I - svn-status-property-ignore-file-extension
100 ;; P C-i - svn-status-property-edit-svn-ignore
101 ;; P k - svn-status-property-set-keyword-list
102 ;; P K i - svn-status-property-set-keyword-id
103 ;; P K d - svn-status-property-set-keyword-date
104 ;; P y - svn-status-property-set-eol-style
105 ;; P x - svn-status-property-set-executable
106 ;; P m - svn-status-property-set-mime-type
107 ;; H - svn-status-use-history
108 ;; x - svn-status-update-buffer
109 ;; q - svn-status-bury-buffer
111 ;; C-x C-j - svn-status-dired-jump
113 ;; The output in the buffer contains this header to ease reading
115 ;; FPH BASE CMTD Author em File
119 ;; BASE = local base revision
120 ;; CMTD = last committed revision
121 ;; Author = author of change
122 ;; em = "**" or "(Update Available)" [see `svn-status-short-mod-flag-p']
123 ;; if file can be updated
124 ;; File = path/filename
127 ;; To use psvn.el put the following line in your .emacs:
129 ;; Start the svn interface with M-x svn-status
131 ;; The latest version of psvn.el can be found at:
132 ;; http://www.xsteve.at/prg/emacs/psvn.el
133 ;; Or you can check it out from the subversion repository:
134 ;; svn co http://svn.collab.net/repos/svn/trunk/contrib/client-side/emacs emacs-svn
137 ;; * shortcut for svn propset svn:keywords "Date" psvn.el
138 ;; * docstrings for the functions
139 ;; * perhaps shortcuts for ranges, dates
140 ;; * when editing the command line - offer help from the svn client
141 ;; * finish svn-status-property-set
142 ;; * Add repository browser
143 ;; * Get rid of all byte-compiler warnings
144 ;; * SVK working copy support
145 ;; * multiple independent buffers in svn-status-mode
146 ;; There are "TODO" comments in other parts of this file as well.
148 ;; Overview over the implemented/not (yet) implemented svn sub-commands:
150 ;; * blame implemented
152 ;; * checkout (co) implemented
153 ;; * cleanup implemented
154 ;; * commit (ci) implemented
155 ;; * copy (cp) implemented
156 ;; * delete (del, remove, rm) implemented
157 ;; * diff (di) implemented
158 ;; * export implemented
160 ;; * import used (in svn-admin-create-trunk-directory)
161 ;; * info implemented
162 ;; * list (ls) implemented
163 ;; * lock implemented
166 ;; * mkdir implemented
167 ;; * move (mv, rename, ren) implemented
168 ;; * propdel (pdel) implemented
169 ;; * propedit (pedit, pe) not needed
170 ;; * propget (pget, pg) used (in svn-status-property-edit)
171 ;; * proplist (plist, pl) implemented
172 ;; * propset (pset, ps) used (in svn-prop-edit-do-it)
173 ;; * resolved implemented
174 ;; * revert implemented
175 ;; * status (stat, st) implemented
177 ;; * unlock implemented
178 ;; * update (up) implemented
180 ;; For the not yet implemented commands you should use the command line
181 ;; svn client. If there are user requests for any missing commands I will
182 ;; probably implement them.
184 ;; There is also limited support for the web-based software project management and bug/issue tracking system trac
185 ;; Trac ticket links can be enabled in the *svn-log* buffers when using the following:
186 ;; (setq svn-log-link-handlers '(trac-ticket-short))
188 ;; ---------------------------
189 ;; Frequently asked questions:
190 ;; ---------------------------
192 ;; Q1: I need support for user names with blanks/spaces
193 ;; A1: Add the user names to svn-user-names-including-blanks and set the
194 ;; svn-pre-parse-status-hook.
195 ;; The problem is, that the user names and the file names from the svn status
196 ;; output can both contain blanks. Blanks in file names are supported.
197 ;; the svn-user-names-including-blanks list is used to replace the spaces
198 ;; in the user names with - to overcome this problem
200 ;; Q2: My svn-update command it taking a really long time. How can I
201 ;; see what's going on?
202 ;; A2: In the *svn-status* buffer press "s".
204 ;; Q3: How do I enter a username and password?
205 ;; A3: In the *svn-status* buffer press "s", switch to the
206 ;; *svn-process* buffer and press enter. You will be prompted for
207 ;; username and password.
209 ;; Q4: What does "?", "M", and "C" in the first column of the
210 ;; *svn-status* buffer mean?
211 ;; A4: "?" means the file(s) is not under Subversion control
212 ;; "M" means you have a locally modified file
213 ;; "C" means there is a conflict
214 ;; "@$&#!" means someone is saying nasty things to you
217 ;; Comments / suggestions and bug reports are welcome!
222 ;; "svn-" is the package prefix used in psvn.el. There are also longer
223 ;; prefixes which clarify the code and help symbol completion, but they
224 ;; are not intended to prevent name clashes with other packages. All
225 ;; interactive commands meant to be used only in a specific mode should
226 ;; have names beginning with the name of that mode: for example,
227 ;; "svn-status-add-file" in "svn-status-mode". "psvn" should be used
228 ;; only in names of files, customization groups, and features. If SVK
229 ;; support is ever added, it should use "svn-svk-" when no existing
230 ;; prefix is applicable.
232 ;; Many of the variables marked as `risky-local-variable' are probably
233 ;; impossible to abuse, as the commands that read them are used only in
234 ;; buffers that are not visiting any files. Better safe than sorry.
240 (eval-when-compile (require 'dired
))
241 (eval-when-compile (require 'ediff-util
))
242 (eval-when-compile (require 'elp
))
243 (eval-when-compile (require 'pp
))
247 (require 'diff-mode
))
250 (defconst svn-psvn-revision
"$Id$"
251 "The revision number of psvn.")
253 ;;; user setable variables
254 (defcustom svn-status-verbose t
255 "*Add '-v' to svn status call.
256 This can be toggled with \\[svn-status-toggle-svn-verbose-flag]."
259 (defcustom svn-log-edit-file-name
"++svn-log++"
260 "*Name of a saved log file.
261 This can be either absolute, or relative to the default directory
262 of the `svn-log-edit-buffer-name' buffer."
265 (put 'svn-log-edit-file-name
'risky-local-variable t
)
266 (defcustom svn-log-edit-insert-files-to-commit t
267 "*Insert the filelist to commit in the *svn-log* buffer"
270 (defcustom svn-log-edit-show-diff-for-commit nil
271 "*Show the diff being committed when you run `svn-status-commit.'."
274 (defcustom svn-log-edit-use-log-edit-mode
275 (and (condition-case nil
(require 'log-edit
) (error nil
)) t
)
276 "*Use log-edit-mode as base for svn-log-edit-mode
277 This variable takes effect only when psvn.el is being loaded."
280 (defcustom svn-log-edit-paragraph-start
281 "$\\|[ \t]*$\\|##.*$\\|\\*.*:.*$\\|[ \t]+(.+):.*$"
282 "*Value used for `paragraph-start' in `svn-log-edit-buffer-name' buffer."
285 (defcustom svn-log-edit-paragraph-separate
"$\\|##.*$"
286 "*Value used for `paragraph-separate' in `svn-log-edit-buffer-name' buffer."
289 (defcustom svn-status-hide-unknown nil
290 "*Hide unknown files in `svn-status-buffer-name' buffer.
291 This can be toggled with \\[svn-status-toggle-hide-unknown]."
294 (defcustom svn-status-hide-unmodified nil
295 "*Hide unmodified files in `svn-status-buffer-name' buffer.
296 This can be toggled with \\[svn-status-toggle-hide-unmodified]."
299 (defcustom svn-status-sort-status-buffer t
300 "*Whether to sort the `svn-status-buffer-name' buffer.
302 Setting this variable to nil speeds up \\[M-x svn-status], however the
303 listing may then become incorrect.
305 This can be toggled with \\[svn-status-toggle-sort-status-buffer]."
309 (defcustom svn-status-ediff-delete-temporary-files nil
310 "*Whether to delete temporary ediff files. If set to ask, ask the user"
311 :type
'(choice (const t
)
316 (defcustom svn-status-changelog-style
'changelog
317 "*The changelog style that is used for `svn-file-add-to-changelog'.
319 'changelog: use `add-change-log-entry-other-window'
320 'svn-dev: use commit messages that are used by the svn developers
321 a function: This function is called to add a new entry to the changelog file.
323 :type
'(set (const changelog
)
327 (defcustom svn-status-unmark-files-after-list
'(commit revert
)
328 "*List of operations after which all user marks will be removed.
329 Possible values are: commit, revert."
330 :type
'(set (const commit
)
334 (defcustom svn-status-preserve-window-configuration t
335 "*Try to preserve the window configuration."
339 (defcustom svn-status-auto-revert-buffers t
340 "*Auto revert buffers that have changed on disk."
344 (defcustom svn-status-fancy-file-state-in-modeline t
345 "*Show a color dot in the modeline that describes the state of the current file."
349 (defcustom svn-status-negate-meaning-of-arg-commands
'()
350 "*List of operations that should use a negated meaning of the prefix argument.
351 The supported functions are `svn-status' and `svn-status-set-user-mark'."
352 :type
'(set (function-item svn-status
)
353 (function-item svn-status-set-user-mark
))
356 (defcustom svn-status-svn-executable
"svn"
357 "*The name of the svn executable.
358 This can be either absolute or looked up on `exec-path'."
359 ;; Don't use (file :must-match t). It doesn't know about `exec-path'.
362 (put 'svn-status-svn-executable
'risky-local-variable t
)
364 (defcustom svn-status-default-export-directory
"~/" "*The default directory that is suggested svn export."
368 (defcustom svn-status-svn-environment-var-list
'("LC_MESSAGES=C" "LC_ALL=")
369 "*A list of environment variables that should be set for that svn process.
370 Each element is either a string \"VARIABLE=VALUE\" which will be added to
371 the environment when svn is run, or just \"VARIABLE\" which causes that
372 variable to be entirely removed from the environment.
374 The default setting is '(\"LC_MESSAGES=C\" \"LC_ALL=\"). This ensures that the svn command
375 line client does not output localized strings. psvn.el relies on the english
377 :type
'(repeat string
)
379 (put 'svn-status-svn-environment-var-list
'risky-local-variable t
)
381 (defcustom svn-browse-url-function nil
382 ;; If the user hasn't changed `svn-browse-url-function', then changing
383 ;; `browse-url-browser-function' should affect psvn even after it has
385 "Function to display a Subversion related WWW page in a browser.
386 So far, this is used only for \"trac\" issue tracker integration.
387 By default, this is nil, which means use `browse-url-browser-function'.
388 Any non-nil value overrides that variable, with the same syntax."
389 ;; It would be nice to show the full list of browsers supported by
390 ;; browse-url, but (custom-variable-type 'browse-url-browser-function)
391 ;; returns just `function' if browse-url has not yet been loaded,
392 ;; and there seems to be no easy way to autoload browse-url when
393 ;; the custom-type of svn-browse-url-function is actually needed.
394 ;; So I'll only offer enough choices to cover all supported types.
395 :type
`(choice (const :tag
"Specified by `browse-url-browser-function'" nil
)
396 (function :value browse-url-default-browser
397 ;; In XEmacs 21.4.17, the `function' widget matches
398 ;; all objects. Constrain it here so that alists
399 ;; fall through to the next choice. Accept either
400 ;; a symbol (fbound or not) or a lambda expression.
401 :match
,(lambda (widget value
)
402 (or (symbolp value
) (functionp value
))))
403 (svn-alist :tag
"Regexp/function association list"
404 :key-type regexp
:value-type function
405 :value
(("." . browse-url-default-browser
))))
406 :link
'(emacs-commentary-link "browse-url")
408 ;; (put 'svn-browse-url-function 'risky-local-variable t)
409 ;; already implied by "-function" suffix
411 (defcustom svn-status-window-alist
412 '((diff "*svn-diff*") (log "*svn-log*") (info t
) (blame t
) (proplist t
) (update t
))
413 "An alist to specify which windows should be used for svn command outputs.
414 The following keys are supported: diff, log, info, blame, proplist, update.
415 The following values can be given:
416 nil ... show in `svn-process-buffer-name' buffer
417 t ... show in dedicated *svn-info* buffer
418 invisible ... don't show the buffer (eventually useful for update)
419 a string ... show in a buffer named string"
424 (const :tag
"Show in *svn-process* buffer" nil
)
425 (const :tag
"Show in dedicated *svn-info* buffer" t
)
426 (const :tag
"Don't show the output" invisible
)
427 (string :tag
"Show in a buffer named"))))
428 :options
'(diff log info blame proplist update
)
431 (defcustom svn-status-short-mod-flag-p t
432 "*Whether the mark for out of date files is short or long.
434 If this variable is is t, and a file is out of date (i.e., there is a newer
435 version in the repository than the working copy), then the file will
438 If this variable is nil, and the file is out of date then the longer phrase
439 \"(Update Available)\" is used.
441 In either case the mark gets the face
442 `svn-status-update-available-face', and will only be visible if
443 `\\[svn-status-update]' is run with a prefix argument"
444 :type
'(choice (const :tag
"Short \"**\"" t
)
445 (const :tag
"Long \"(Update Available)\"" nil
))
448 (defvar svn-status-debug-level
0 "The psvn.el debugging verbosity level.
449 The higher the number, the more debug messages are shown.
451 See `svn-status-message' for the meaning of values for that variable.")
453 (defvar svn-bookmark-list nil
"A list of locations for a quick access via `svn-status-via-bookmark'")
454 ;;(setq svn-bookmark-list '(("proj1" . "~/work/proj1")
455 ;; ("doc1" . "~/docs/doc1")))
457 (defvar svn-status-buffer-name
"*svn-status*" "Name for the svn status buffer")
458 (defvar svn-process-buffer-name
" *svn-process*" "Name for the svn process buffer")
459 (defvar svn-log-edit-buffer-name
"*svn-log-edit*" "Name for the svn log-edit buffer")
461 (defcustom svn-status-use-header-line
462 (if (boundp 'header-line-format
) t
'inline
)
463 "*Whether a header line should be used.
464 When t: Use the emacs header line
465 When 'inline: Insert the header line in the `svn-status-buffer-name' buffer
466 Otherwise: Don't display a header line"
467 :type
'(choice (const :tag
"Show column titles as a header line" t
)
468 (const :tag
"Insert column titles as text in the buffer" inline
)
469 (other :tag
"No column titles" nil
))
472 ;;; default arguments to pass to svn commands
473 ;; TODO: When customizing, an option menu or completion might be nice....
474 (defcustom svn-status-default-log-arguments
'("-v")
475 "*List of arguments to pass to svn log.
476 \(used in `svn-status-show-svn-log'; override these by giving prefixes\)."
477 :type
'(repeat string
)
479 (put 'svn-status-default-log-arguments
'risky-local-variable t
)
481 (defcustom svn-status-default-commit-arguments
'()
482 "*List of arguments to pass to svn commit.
483 If you don't like recursive commits, set this value to (\"-N\")
484 or mark the directory before committing it.
485 Do not put an empty string here, except as an argument of an option:
486 Subversion and the operating system may treat that as a file name
487 equivalent to \".\", so you would commit more than you intended."
488 :type
'(repeat string
)
490 (put 'svn-status-default-commit-arguments
'risky-local-variable t
)
492 (defcustom svn-status-default-diff-arguments
'("-x" "--ignore-eol-style")
493 "*A list of arguments that is passed to the svn diff command.
494 When the built in diff command is used,
495 the following options are available: --ignore-eol-style, --ignore-space-change,
496 --ignore-all-space, --ignore-eol-style.
497 The following setting ignores eol style changes and all white space changes:
498 '(\"-x\" \"--ignore-eol-style --ignore-all-space\")
500 If you'd like to suppress whitespace changes using the external diff command
501 use the following value:
502 '(\"--diff-cmd\" \"diff\" \"-x\" \"-wbBu\")
505 :type
'(repeat string
)
507 (put 'svn-status-default-diff-arguments
'risky-local-variable t
)
509 (defcustom svn-status-default-status-arguments
'()
510 "*A list of arguments that is passed to the svn status command.
511 The following options are available: --ignore-externals
514 :type
'(repeat string
)
516 (put 'svn-status-default-status-arguments
'risky-local-variable t
)
518 (defcustom svn-status-default-blame-arguments
'("-x" "--ignore-eol-style")
519 "*A list of arguments that is passed to the svn blame command.
520 See `svn-status-default-diff-arguments' for some examples."
521 :type
'(repeat string
)
524 (put 'svn-status-default-blame-arguments
'risky-local-variable t
)
526 (defvar svn-trac-project-root nil
527 "Path for an eventual existing trac issue tracker.
528 This can be set with \\[svn-status-set-trac-project-root].")
530 (defvar svn-status-module-name nil
531 "*A short name for the actual project.
532 This can be set with \\[svn-status-set-module-name].")
534 (defvar svn-status-branch-list nil
535 "*A list of known branches for the actual project
536 This can be set with \\[svn-status-set-branch-list].
538 The list contains full repository paths or shortcuts starting with \#
539 \# at the beginning is replaced by the repository url.
540 \#1\# has the special meaning that all paths below the given directory
541 will be considered for interactive selections.
543 A useful setting might be: '\(\"\#trunk\" \"\#1\#tags\" \"\#1\#branches\")")
545 (defvar svn-status-load-state-before-svn-status t
546 "*Whether to automatically restore state from ++psvn.state file before running svn-status.")
548 (defvar svn-log-link-handlers nil
"A list of link handlers in *svn-log* buffers.
549 These link handlers must be registered via `svn-log-register-link-handler'")
552 (defvar svn-status-mode-hook nil
"Hook run when entering `svn-status-mode'.")
553 (defvar svn-log-edit-mode-hook nil
"Hook run when entering `svn-log-edit-mode'.")
554 (defvar svn-log-edit-done-hook nil
"Hook run after commiting files via svn.")
555 ;; (put 'svn-log-edit-mode-hook 'risky-local-variable t)
556 ;; (put 'svn-log-edit-done-hook 'risky-local-variable t)
557 ;; already implied by "-hook" suffix
559 (defvar svn-post-process-svn-output-hook nil
"Hook that can be used to preprocess the output from svn.
560 The function `svn-status-remove-control-M' can be useful for that hook")
562 (when (eq system-type
'windows-nt
)
563 (add-hook 'svn-post-process-svn-output-hook
'svn-status-remove-control-M
))
565 (defvar svn-status-svn-process-coding-system
(when (boundp 'locale-coding-system
) locale-coding-system
)
566 "The coding system that is used for the svn command line client.
567 It is used in svn-run, if it is not nil.")
569 (defvar svn-status-svn-file-coding-system
'undecided-unix
570 "The coding system that is used to save files that are loaded as
571 parameter or data files via the svn command line client.
572 It is used in the following functions: `svn-prop-edit-do-it', `svn-log-edit-done'.
573 You could set it to 'utf-8")
575 (defcustom svn-status-use-ido-completion
576 (fboundp 'ido-completing-read
)
577 "*Use ido completion functionality."
581 (defvar svn-status-completing-read-function
582 (if svn-status-use-ido-completion
'ido-completing-read
'completing-read
))
584 ;;; experimental features
585 (defvar svn-status-track-user-input nil
"Track user/password queries.
586 This feature is implemented via a process filter.
587 It is an experimental feature.")
589 (defvar svn-status-refresh-info nil
"Whether `svn-status-update-buffer' should call `svn-status-parse-info'.")
593 "Subversion interface for Emacs."
596 (defgroup psvn-faces nil
603 (defconst svn-xemacsp
(featurep 'xemacs
))
606 (require 'overlay nil t
)))
608 (defcustom svn-status-display-full-path nil
609 "Specifies how the filenames look like in the listing.
610 If t, their full path name will be displayed, else only the filename."
614 (defcustom svn-status-prefix-key
[(control x
) (meta s
)]
615 "Prefix key for the psvn commands in the global keymap."
616 :type
'(choice (const [(control x
) ?v ?S
])
619 (const [(control x
) ?v
])
620 (const [(control x
) ?V
])
623 :set
(lambda (var value
)
625 (global-unset-key (symbol-value var
)))
627 (global-set-key (symbol-value var
) 'svn-global-keymap
)))
629 (defcustom svn-admin-default-create-directory
"~/"
630 "*The default directory that is suggested for `svn-admin-create'."
634 (defvar svn-status-custom-hide-function nil
635 "A function that receives a line-info and decides whether to hide that line.
636 See psvn.el for an example function.")
637 ;; (put 'svn-status-custom-hide-function 'risky-local-variable t)
638 ;; already implied by "-function" suffix
641 ;; Use the normally used mode for files ending in .~HEAD~, .~BASE~, ...
642 (add-to-list 'auto-mode-alist
'("\\.~?\\(HEAD\\|BASE\\|PREV\\)~?\\'" ignore t
))
644 ;;; internal variables
645 (defvar svn-status-directory-history nil
"List of visited svn working directories.")
646 (defvar svn-process-cmd nil
)
647 (defvar svn-status-info nil
)
648 (defvar svn-status-filename-to-buffer-position-cache
(make-hash-table :test
'equal
:weakness t
))
649 (defvar svn-status-base-info nil
"The parsed result from the svn info command.")
650 (defvar svn-status-initial-window-configuration nil
)
651 (defvar svn-status-default-column
23)
652 (defvar svn-status-default-revision-width
4)
653 (defvar svn-status-default-author-width
9)
654 (defvar svn-status-line-format
" %c%c%c %4s %4s %-9s")
655 (defvar svn-start-of-file-list-line-number
0)
656 (defvar svn-status-files-to-commit nil
657 "List of files to commit at `svn-log-edit-done'.
658 This is always set together with `svn-status-recursive-commit'.")
659 (defvar svn-status-recursive-commit nil
660 "Non-nil if the next commit should be recursive.
661 This is always set together with `svn-status-files-to-commit'.")
662 (defvar svn-log-edit-update-log-entry nil
663 "Revision number whose log entry is being edited.
664 This is nil if the log entry is for a new commit.")
665 (defvar svn-status-pre-commit-window-configuration nil
)
666 (defvar svn-status-pre-propedit-window-configuration nil
)
667 (defvar svn-status-head-revision nil
)
668 (defvar svn-status-root-return-info nil
)
669 (defvar svn-status-property-edit-must-match-flag nil
)
670 (defvar svn-status-propedit-property-name nil
"The property name for the actual svn propset command")
671 (defvar svn-status-propedit-file-list nil
)
672 (defvar svn-status-mode-line-process
"")
673 (defvar svn-status-mode-line-process-status
"")
674 (defvar svn-status-mode-line-process-edit-flag
"")
675 (defvar svn-status-edit-svn-command nil
)
676 (defvar svn-status-update-previous-process-output nil
)
677 (defvar svn-pre-run-asynch-recent-keys nil
)
678 (defvar svn-pre-run-mode-line-process nil
)
679 (defvar svn-status-temp-dir
682 (when (boundp 'temporary-file-directory
) temporary-file-directory
) ;emacs
683 ;; XEmacs 21.4.17 can return "/tmp/kalle" from (temp-directory).
684 ;; `file-name-as-directory' adds a slash so we can append a file name.
685 (when (fboundp 'temp-directory
) (file-name-as-directory (temp-directory)))
686 "/tmp/")) "The directory that is used to store temporary files for psvn.")
687 ;; Because `temporary-file-directory' is not a risky local variable in
688 ;; GNU Emacs 22.0.51, we don't mark `svn-status-temp-dir' as such either.
689 (defvar svn-temp-suffix
(make-temp-name "."))
690 (put 'svn-temp-suffix
'risky-local-variable t
)
691 (defvar svn-status-temp-file-to-remove nil
)
692 (put 'svn-status-temp-file-to-remove
'risky-local-variable t
)
693 (defvar svn-status-temp-arg-file
(concat svn-status-temp-dir
"svn.arg" svn-temp-suffix
))
694 (put 'svn-status-temp-arg-file
'risky-local-variable t
)
695 (defvar svn-status-options nil
)
696 (defvar svn-status-remote
)
697 (defvar svn-status-commit-rev-number nil
)
698 (defvar svn-status-update-rev-number nil
)
699 (defvar svn-status-operated-on-dot nil
)
700 (defvar svn-status-last-commit-author nil
)
701 (defvar svn-status-elided-list nil
)
702 (defvar svn-status-last-output-buffer-name nil
"The buffer name for the buffer that holds the output from the last executed svn command")
703 (defvar svn-status-pre-run-svn-buffer nil
)
704 (defvar svn-status-update-list nil
)
705 (defvar svn-transient-buffers
)
706 (defvar svn-ediff-windows
)
707 (defvar svn-ediff-result
)
708 (defvar svn-status-last-diff-options nil
)
709 (defvar svn-status-blame-file-name nil
)
710 (defvar svn-admin-last-repository-dir nil
"The last repository url for various operations.")
711 (defvar svn-last-cmd-ring
(make-ring 30) "Ring that holds the last executed svn commands (for debugging purposes)")
712 (defvar svn-status-cached-version-string nil
)
713 (defvar svn-client-version nil
"The version number of the used svn client")
714 (defvar svn-status-get-line-information-for-file nil
)
715 (defvar svn-status-base-dir-cache
(make-hash-table :test
'equal
:weakness nil
))
716 (defvar svn-log-registered-link-handlers
(make-hash-table :test
'eql
:weakness nil
))
718 (defvar svn-status-partner-buffer nil
"The partner buffer for this svn related buffer")
719 (make-variable-buffer-local 'svn-status-partner-buffer
)
721 ;; Emacs 21 defines these in ediff-init.el but it seems more robust
722 ;; to just declare the variables here than try to load that file.
723 ;; It is Ediff's job to declare these as risky-local-variable if needed.
724 (defvar ediff-buffer-A
)
725 (defvar ediff-buffer-B
)
726 (defvar ediff-buffer-C
)
727 (defvar ediff-quit-hook
)
729 ;; Ditto for log-edit.el.
730 (defvar log-edit-initial-files
)
731 (defvar log-edit-callback
)
732 (defvar log-edit-listfun
)
734 ;; Ediff does not use this variable in GNU Emacs 20.7, GNU Emacs 21.4,
735 ;; nor XEmacs 21.4.17. However, pcl-cvs (a.k.a. pcvs) does.
736 ;; TODO: Check if this should be moved into the "svn-" namespace.
737 (defvar ediff-after-quit-destination-buffer
)
739 ;; That is an example for the svn-status-custom-hide-function:
740 ;; Note: For many cases it is a better solution to ignore files or
741 ;; file extensions via the svn-ignore properties (on P i, P I)
742 ;; (setq svn-status-custom-hide-function 'svn-status-hide-pyc-files)
743 ;; (defun svn-status-hide-pyc-files (info)
744 ;; "Hide all pyc files in the `svn-status-buffer-name' buffer."
745 ;; (let* ((fname (svn-status-line-info->filename-nondirectory info))
746 ;; (fname-len (length fname)))
747 ;; (and (> fname-len 4) (string= (substring fname (- fname-len 4)) ".pyc"))))
750 (defface svn-status-marked-face
751 '((((type tty
) (class color
)) (:foreground
"green" :weight light
))
752 (((class color
) (background light
)) (:foreground
"green3"))
753 (((class color
) (background dark
)) (:foreground
"palegreen2"))
755 "Face to highlight the mark for user marked files in svn status buffers."
758 (defface svn-status-marked-popup-face
759 '((((type tty
) (class color
)) (:foreground
"green" :weight light
))
760 (((class color
) (background light
)) (:foreground
"green3"))
761 (((class color
) (background dark
)) (:foreground
"palegreen2"))
763 "Face to highlight the actual file, if a popup menu is activated."
766 (defface svn-status-update-available-face
767 '((((type tty
) (class color
)) (:foreground
"magenta" :weight light
))
768 (((class color
) (background light
)) (:foreground
"magenta"))
769 (((class color
) (background dark
)) (:foreground
"yellow"))
771 "Face used to highlight the 'out of date' mark.
772 \(i.e., the mark used when there is a newer version in the repository
773 than the working copy.\)
775 See also `svn-status-short-mod-flag-p'."
778 ;based on cvs-filename-face
779 (defface svn-status-directory-face
780 '((((type tty
) (class color
)) (:foreground
"lightblue" :weight light
))
781 (((class color
) (background light
)) (:foreground
"blue4"))
782 (((class color
) (background dark
)) (:foreground
"lightskyblue1"))
784 "Face for directories in *svn-status* buffers.
785 See `svn-status--line-info->directory-p' for what counts as a directory."
788 ;based on font-lock-comment-face
789 (defface svn-status-filename-face
790 '((((class color
) (background light
)) (:foreground
"chocolate"))
791 (((class color
) (background dark
)) (:foreground
"beige")))
792 "Face for non-directories in *svn-status* buffers.
793 See `svn-status--line-info->directory-p' for what counts as a directory."
796 ;not based on anything, may be horribly ugly!
797 (defface svn-status-symlink-face
798 '((((class color
) (background light
)) (:foreground
"cornflower blue"))
799 (((class color
) (background dark
)) (:foreground
"cyan")))
800 "Face for symlinks in *svn-status* buffers.
802 This is the face given to the actual link (i.e., the versioned item),
803 the target of the link gets either `svn-status-filename-face' or
804 `svn-status-directory-face'."
807 ;based on font-lock-warning-face
808 (defface svn-status-locked-face
810 (:weight bold
:foreground
"Red")))
811 "Face for the phrase \"[ LOCKED ]\" `svn-status-buffer-name' buffers."
814 ;based on vhdl-font-lock-directive-face
815 (defface svn-status-switched-face
818 (:foreground
"CadetBlue"))
821 (:foreground
"Aquamarine"))
823 (:bold t
:italic t
)))
824 "Face for the phrase \"(switched)\" non-directories in svn status buffers."
828 (defface svn-status-blame-highlight-face
829 '((((type tty
) (class color
)) (:foreground
"green" :weight light
))
830 (((class color
) (background light
)) (:foreground
"green3"))
831 (((class color
) (background dark
)) (:foreground
"palegreen2"))
833 "Default face for highlighting a line in svn status blame mode."
835 (defface svn-status-blame-highlight-face
836 '((t :inherit highlight
))
837 "Default face for highlighting a line in svn status blame mode."
840 (defface svn-status-blame-rev-number-face
841 '((((class color
) (background light
)) (:foreground
"DarkGoldenrod"))
842 (((class color
) (background dark
)) (:foreground
"LightGoldenrod"))
843 (t (:weight bold
:slant italic
)))
844 "Face to highlight revision numbers in the svn-blame mode."
847 (defvar svn-highlight t
)
848 ;; stolen from PCL-CVS
849 (defun svn-add-face (str face
&optional keymap
)
850 "Return string STR decorated with the specified FACE.
851 If `svn-highlight' is nil then just return STR."
853 ;; Do not use `list*'; cl.el might not have been loaded. We could
854 ;; put (require 'cl) at the top but let's try to manage without.
855 (add-text-properties 0 (length str
)
857 mouse-face highlight
)
858 ;; 18.10.2004: the keymap parameter is not used (yet) in psvn.el
860 ;; `(mouse-face highlight
861 ;; local-map ,keymap)))
865 (defun svn-status-maybe-add-face (condition text face
)
866 "If CONDITION then add FACE to TEXT.
867 Else return TEXT unchanged."
869 (svn-add-face text face
)
872 (defun svn-status-choose-face-to-add (condition text face1 face2
)
873 "If CONDITION then add FACE1 to TEXT, else add FACE2 to TEXT."
875 (svn-add-face text face1
)
876 (svn-add-face text face2
)))
878 (defun svn-status-maybe-add-string (condition string face
)
879 "If CONDITION then return STRING decorated with FACE.
880 Otherwise, return \"\"."
882 (svn-add-face string face
)
887 (defalias 'svn-point-at-eol
888 (if (fboundp 'point-at-eol
) 'point-at-eol
'line-end-position
))
889 (defalias 'svn-point-at-bol
890 (if (fboundp 'point-at-bol
) 'point-at-bol
'line-beginning-position
))
891 (defalias 'svn-read-directory-name
892 (if (fboundp 'read-directory-name
) 'read-directory-name
'read-file-name
))
895 (if (not (fboundp 'gethash
))
897 (defalias 'svn-puthash
(if (fboundp 'puthash
) 'puthash
'cl-puthash
))
900 (if (fboundp 'line-number-at-pos
)
901 (defalias 'svn-line-number-at-pos
'line-number-at-pos
)
902 (defun svn-line-number-at-pos (&optional pos
)
903 "Return (narrowed) buffer line number at position POS.
904 If POS is nil, use current buffer location."
905 (let ((opoint (or pos
(point))) start
)
907 (goto-char (point-min))
911 (1+ (count-lines start
(point)))))))
914 ;; Evaluate the defsubst at compile time, so that the byte compiler
915 ;; knows the definition and can inline calls. It cannot detect the
916 ;; defsubst automatically from within the if form.
918 (if (fboundp 'match-string-no-properties
)
919 (defalias 'svn-match-string-no-properties
'match-string-no-properties
)
920 (defsubst svn-match-string-no-properties
(match)
921 (buffer-substring-no-properties (match-beginning match
) (match-end match
)))))
923 ;; XEmacs 21.4.17 does not have an `alist' widget. Define a replacement.
924 ;; To find out whether the `alist' widget exists, we cannot check just
925 ;; (get 'alist 'widget-type), because GNU Emacs 21.4 defines it in
926 ;; "wid-edit.el", which is not preloaded; it will be autoloaded when
927 ;; `widget-create' is called. Instead, we call `widgetp', which is
928 ;; also autoloaded from "wid-edit.el". XEmacs 21.4.17 does not have
929 ;; `widgetp' either, so we check that first.
930 (if (and (fboundp 'widgetp
) (widgetp 'alist
))
931 (define-widget 'svn-alist
'alist
932 "An association list.
933 Use this instead of `alist', for XEmacs 21.4 compatibility.")
934 (define-widget 'svn-alist
'list
935 "An association list.
936 Use this instead of `alist', for XEmacs 21.4 compatibility."
937 :convert-widget
'svn-alist-convert-widget
938 :tag
"Association List"
941 (defun svn-alist-convert-widget (widget)
942 (let* ((value-type (widget-get widget
:value-type
))
943 (option-widgets (loop for option in
(widget-get widget
:options
)
944 collect
`(cons :format
"%v"
945 (const :format
"%t: %v\n"
949 (widget-put widget
:args
950 `(,@(when option-widgets
951 `((set :inline t
:format
"%v"
953 (editable-list :inline t
955 ,(widget-get widget
:key-type
)
959 ;; process launch functions
960 (defvar svn-call-process-function
(if (fboundp 'process-file
) 'process-file
'call-process
))
961 (defvar svn-start-process-function
(if (fboundp 'start-file-process
) 'start-file-process
'start-process
))
966 (defvar svn-global-keymap nil
"Global keymap for psvn.el.
967 To bind this to a different key, customize `svn-status-prefix-key'.")
968 (put 'svn-global-keymap
'risky-local-variable t
)
969 (when (not svn-global-keymap
)
970 (setq svn-global-keymap
(make-sparse-keymap))
971 (define-key svn-global-keymap
(kbd "v") 'svn-status-version
)
972 (define-key svn-global-keymap
(kbd "s") 'svn-status-this-directory
)
973 (define-key svn-global-keymap
(kbd "b") 'svn-status-via-bookmark
)
974 (define-key svn-global-keymap
(kbd "h") 'svn-status-use-history
)
975 (define-key svn-global-keymap
(kbd "u") 'svn-status-update-cmd
)
976 (define-key svn-global-keymap
(kbd "=") 'svn-status-show-svn-diff
)
977 (define-key svn-global-keymap
(kbd "f =") 'svn-file-show-svn-diff
)
978 (define-key svn-global-keymap
(kbd "f e") 'svn-file-show-svn-ediff
)
979 (define-key svn-global-keymap
(kbd "f l") 'svn-status-show-svn-log
)
980 (define-key svn-global-keymap
(kbd "f b") 'svn-status-blame
)
981 (define-key svn-global-keymap
(kbd "f a") 'svn-file-add-to-changelog
)
982 (define-key svn-global-keymap
(kbd "c") 'svn-status-commit
)
983 (define-key svn-global-keymap
(kbd "S") 'svn-status-switch-to-status-buffer
)
984 (define-key svn-global-keymap
(kbd "o") 'svn-status-pop-to-status-buffer
))
986 (defvar svn-status-diff-mode-map
()
987 "Keymap used in `svn-status-diff-mode' for additional commands that are not defined in diff-mode.")
988 (put 'svn-status-diff-mode-map
'risky-local-variable t
) ;for Emacs 20.7
990 (when (not svn-status-diff-mode-map
)
991 (setq svn-status-diff-mode-map
(copy-keymap diff-mode-shared-map
))
992 (define-key svn-status-diff-mode-map
[?g
] 'revert-buffer
)
993 (define-key svn-status-diff-mode-map
[?s
] 'svn-status-pop-to-status-buffer
)
994 (define-key svn-status-diff-mode-map
[?c
] 'svn-status-diff-pop-to-commit-buffer
)
995 (define-key svn-status-diff-mode-map
[?w
] 'svn-status-diff-save-current-defun-as-kill
))
997 (defvar svn-global-trac-map
()
998 "Subkeymap used in `svn-global-keymap' for trac issue tracker commands.")
999 (put 'svn-global-trac-map
'risky-local-variable t
) ;for Emacs 20.7
1000 (when (not svn-global-trac-map
)
1001 (setq svn-global-trac-map
(make-sparse-keymap))
1002 (define-key svn-global-trac-map
(kbd "w") 'svn-trac-browse-wiki
)
1003 (define-key svn-global-trac-map
(kbd "t") 'svn-trac-browse-timeline
)
1004 (define-key svn-global-trac-map
(kbd "m") 'svn-trac-browse-roadmap
)
1005 (define-key svn-global-trac-map
(kbd "s") 'svn-trac-browse-source
)
1006 (define-key svn-global-trac-map
(kbd "r") 'svn-trac-browse-report
)
1007 (define-key svn-global-trac-map
(kbd "i") 'svn-trac-browse-ticket
)
1008 (define-key svn-global-trac-map
(kbd "c") 'svn-trac-browse-changeset
)
1009 (define-key svn-global-keymap
(kbd "t") svn-global-trac-map
))
1011 ;; The setter of `svn-status-prefix-key' makes a binding in the global
1012 ;; map refer to the `svn-global-keymap' symbol, rather than directly
1013 ;; to the keymap. Emacs then implicitly uses the symbol-function.
1014 ;; This has the advantage that `describe-bindings' (C-h b) can show
1015 ;; the name of the keymap and link to its documentation.
1016 (defalias 'svn-global-keymap svn-global-keymap
)
1017 ;; `defalias' of GNU Emacs 21.4 doesn't allow a docstring argument.
1018 (put 'svn-global-keymap
'function-documentation
1019 '(documentation-property 'svn-global-keymap
'variable-documentation t
))
1022 ;; named after SVN_WC_ADM_DIR_NAME in svn_wc.h
1023 (defun svn-wc-adm-dir-name ()
1024 "Return the name of the \".svn\" subdirectory or equivalent."
1025 (if (and (eq system-type
'windows-nt
)
1026 (getenv "SVN_ASP_DOT_NET_HACK"))
1030 (defun svn-log-edit-file-name (&optional curdir
)
1031 "Get the name of the saved log edit file
1032 If curdir, return `svn-log-edit-file-name'
1033 Otherwise position svn-log-edit-file-name in the root directory of this working copy"
1035 svn-log-edit-file-name
1036 (concat (svn-status-base-dir) svn-log-edit-file-name
)))
1038 (defun svn-status-message (level &rest args
)
1039 "If LEVEL is lower than `svn-status-debug-level' print ARGS using `message'.
1041 Guideline for numbers:
1042 1 - error messages, 3 - non-serious error messages, 5 - messages for things
1043 that take a long time, 7 - not very important messages on stuff, 9 - messages
1045 (if (<= level svn-status-debug-level
)
1046 (apply 'message args
)))
1048 (defun svn-status-flatten-list (list)
1049 "Flatten any lists within ARGS, so that there are no sublists."
1050 (loop for item in list
1051 if
(listp item
) nconc
(svn-status-flatten-list item
)
1054 (defun svn-status-window-line-position (w)
1055 "Return the window line at point for window W, or nil if W is nil."
1056 (svn-status-message 3 "About to count lines; selected window is %s" (selected-window))
1057 (and w
(count-lines (window-start w
) (point))))
1060 (defun svn-checkout (repos-url path
)
1061 "Run svn checkout REPOS-URL PATH."
1062 (interactive (list (read-string "Checkout from repository Url: ")
1063 (svn-read-directory-name "Checkout to directory: ")))
1064 (svn-run t t
'checkout
"checkout" repos-url
(expand-file-name path
)))
1066 ;;;###autoload (defalias 'svn-examine 'svn-status)
1067 (defalias 'svn-examine
'svn-status
)
1070 (defun svn-status (dir &optional arg
)
1071 "Examine the status of Subversion working copy in directory DIR.
1072 If ARG is -, allow editing of the parameters. One could add -N to
1073 run svn status non recursively to make it faster.
1074 For every other non nil ARG pass the -u argument to `svn status', which
1075 asks svn to connect to the repository and check to see if there are updates
1078 If there is no .svn directory, examine if there is CVS and run
1079 `cvs-examine'. Otherwise ask if to run `dired'."
1080 (interactive (list (svn-read-directory-name "SVN status directory: "
1081 nil default-directory nil
)
1082 current-prefix-arg
))
1083 (let ((svn-dir (format "%s%s"
1084 (file-name-as-directory dir
)
1085 (svn-wc-adm-dir-name)))
1086 (cvs-dir (format "%sCVS" (file-name-as-directory dir
))))
1088 ((file-directory-p svn-dir
)
1089 (setq arg
(svn-status-possibly-negate-meaning-of-arg arg
'svn-status
))
1090 (svn-status-1 dir arg
))
1091 ((and (file-directory-p cvs-dir
)
1092 (fboundp 'cvs-examine
))
1093 (cvs-examine dir nil
))
1099 "is not Subversion controlled (missing %s "
1101 "Run dired instead? ")
1103 (svn-wc-adm-dir-name)))
1106 (defvar svn-status-display-new-status-buffer nil
)
1107 (defun svn-status-1 (dir &optional arg
)
1108 "Examine DIR. See `svn-status' for more information."
1109 (unless (file-directory-p dir
)
1110 (error "%s is not a directory" dir
))
1111 (setq dir
(file-name-as-directory dir
))
1112 (when svn-status-load-state-before-svn-status
1113 (unless (string= dir
(car svn-status-directory-history
))
1114 (let ((default-directory dir
)) ;otherwise svn-status-base-dir looks in the wrong place
1115 (svn-status-load-state t
))))
1116 (setq svn-status-directory-history
(delete dir svn-status-directory-history
))
1117 (add-to-list 'svn-status-directory-history dir
)
1118 (if (string= (buffer-name) svn-status-buffer-name
)
1119 (setq svn-status-display-new-status-buffer nil
)
1120 (setq svn-status-display-new-status-buffer t
)
1121 ;;(message "psvn: Saving initial window configuration")
1122 (setq svn-status-initial-window-configuration
1123 (current-window-configuration)))
1124 (let* ((cur-buf (current-buffer))
1125 (status-buf (get-buffer-create svn-status-buffer-name
))
1126 (proc-buf (get-buffer-create svn-process-buffer-name
))
1127 (want-edit (eq arg
'-
))
1128 (status-option (if want-edit
1129 (if svn-status-verbose
"-v" "")
1130 (if svn-status-verbose
1133 (svn-status-edit-svn-command
1134 (or want-edit svn-status-edit-svn-command
)))
1136 (set-buffer status-buf
)
1137 (setq default-directory dir
)
1138 (set-buffer proc-buf
)
1139 (setq default-directory dir
1140 svn-status-remote
(when arg t
))
1141 (set-buffer cur-buf
)
1142 (svn-run t t
'status
"status" svn-status-default-status-arguments status-option
))))
1144 (defun svn-status-this-directory (arg)
1145 "Run `svn-status' for the `default-directory'"
1147 (svn-status default-directory arg
))
1149 (defun svn-status-use-history ()
1150 "Interactively select a different directory from `svn-status-directory-history'."
1152 (let* ((in-status-buffer (eq major-mode
'svn-status-mode
))
1153 (hist (if in-status-buffer
(cdr svn-status-directory-history
) svn-status-directory-history
))
1154 (dir (funcall svn-status-completing-read-function
"svn-status on directory: " hist
))
1155 (svn-status-buffer (get-buffer svn-status-buffer-name
))
1156 (svn-buffer-available (and svn-status-buffer
1157 (with-current-buffer svn-status-buffer-name
(string= default-directory dir
)))))
1158 (if (file-directory-p dir
)
1159 (if svn-buffer-available
1160 (svn-status-switch-to-status-buffer)
1161 (unless svn-status-refresh-info
1162 (setq svn-status-refresh-info
'once
))
1164 (error "%s is not a directory" dir
))))
1166 (defun svn-had-user-input-since-asynch-run ()
1167 (not (equal (recent-keys) svn-pre-run-asynch-recent-keys
)))
1169 (defun svn-process-environment ()
1170 "Construct the environment for the svn process.
1171 It is a combination of `svn-status-svn-environment-var-list' and
1172 the usual `process-environment'."
1173 ;; If there are duplicate elements in `process-environment', then GNU
1174 ;; Emacs 21.4 guarantees that the first one wins; but GNU Emacs 20.7
1175 ;; and XEmacs 21.4.17 don't document what happens. We'll just remove
1176 ;; any duplicates ourselves, then. This also gives us an opportunity
1177 ;; to handle the "VARIABLE" syntax that none of them supports.
1178 (loop with found
= '()
1179 for elt in
(append svn-status-svn-environment-var-list
1180 process-environment
)
1181 for has-value
= (string-match "=" elt
)
1182 for name
= (substring elt
0 has-value
)
1183 unless
(member name found
)
1184 do
(push name found
)
1188 (defun svn-run (run-asynchron clear-process-buffer cmdtype
&rest arglist
)
1189 "Run svn with arguments ARGLIST.
1191 If RUN-ASYNCHRON is t then run svn asynchronously.
1193 If CLEAR-PROCESS-BUFFER is t then erase the contents of the
1194 `svn-process-buffer-name' buffer before commencing.
1196 CMDTYPE is a symbol such as 'mv, 'revert, or 'add, representing the
1199 ARGLIST is a list of arguments \(which must include the command name,
1200 for example: '(\"revert\" \"file1\"\)
1201 ARGLIST is flattened and any every nil value is discarded.
1203 If the variable `svn-status-edit-svn-command' is non-nil then the user
1204 can edit ARGLIST before running svn.
1206 The hook svn-pre-run-hook allows to monitor/modify the ARGLIST."
1207 (setq arglist
(svn-status-flatten-list arglist
))
1208 (if (eq (process-status "svn") nil
)
1210 (when svn-status-edit-svn-command
1211 (setq arglist
(append
1212 (list (car arglist
))
1214 (read-from-minibuffer
1215 (format "svn %s flags: " (car arglist
))
1216 (mapconcat 'identity
(cdr arglist
) " ")))))
1217 (when (eq svn-status-edit-svn-command t
)
1218 (svn-status-toggle-edit-cmd-flag t
))
1219 (message "svn-run %s: %S" cmdtype arglist
))
1220 (run-hooks 'svn-pre-run-hook
)
1221 (unless (eq mode-line-process
'svn-status-mode-line-process
)
1222 (setq svn-pre-run-mode-line-process mode-line-process
)
1223 (setq mode-line-process
'svn-status-mode-line-process
))
1224 (setq svn-status-pre-run-svn-buffer
(current-buffer))
1225 (let* ((proc-buf (get-buffer-create svn-process-buffer-name
))
1226 (svn-exe svn-status-svn-executable
)
1228 (when (listp (car arglist
))
1229 (setq arglist
(car arglist
)))
1231 (set-buffer proc-buf
)
1232 (unless (file-executable-p default-directory
)
1233 (message "psvn: workaround in %s needed: %s no longer exists" (current-buffer) default-directory
)
1234 (cd (expand-file-name "~")))
1235 (setq buffer-read-only nil
)
1236 (buffer-disable-undo)
1238 (if clear-process-buffer
1239 (delete-region (point-min) (point-max))
1240 (goto-char (point-max)))
1241 (setq svn-process-cmd cmdtype
)
1242 (setq svn-status-last-commit-author nil
)
1243 (setq svn-status-mode-line-process-status
(format " running %s" cmdtype
))
1244 (svn-status-update-mode-line)
1246 (ring-insert svn-last-cmd-ring
(list (current-time-string) arglist default-directory
))
1249 ;;(message "running asynchron: %s %S" svn-exe arglist)
1250 (setq svn-pre-run-asynch-recent-keys
(recent-keys))
1251 (let ((process-environment (svn-process-environment))
1252 (process-connection-type nil
))
1253 ;; Communicate with the subprocess via pipes rather
1254 ;; than via a pseudoterminal, so that if the svn+ssh
1255 ;; scheme is being used, SSH will not ask for a
1256 ;; passphrase via stdio; psvn.el is currently unable
1257 ;; to answer such prompts. Instead, SSH will run
1258 ;; x11-ssh-askpass if possible. If Emacs is being
1259 ;; run on a TTY without $DISPLAY, this will fail; in
1260 ;; such cases, the user should start ssh-agent and
1261 ;; then run ssh-add explicitly.
1262 (setq svn-proc
(apply svn-start-process-function
"svn" proc-buf svn-exe arglist
)))
1263 (when svn-status-svn-process-coding-system
1264 (set-process-coding-system svn-proc svn-status-svn-process-coding-system
1265 svn-status-svn-process-coding-system
))
1266 (set-process-sentinel svn-proc
'svn-process-sentinel
)
1267 (when svn-status-track-user-input
1268 (set-process-filter svn-proc
'svn-process-filter
)))
1269 ;;(message "running synchron: %s %S" svn-exe arglist)
1270 (let ((process-environment (svn-process-environment)))
1271 ;; `call-process' ignores `process-connection-type' and
1272 ;; never opens a pseudoterminal.
1273 (apply svn-call-process-function svn-exe nil proc-buf nil arglist
))
1274 (setq svn-status-last-output-buffer-name svn-process-buffer-name
)
1275 (run-hooks 'svn-post-process-svn-output-hook
)
1276 (setq svn-status-mode-line-process-status
"")
1277 (svn-status-update-mode-line)
1278 (when svn-pre-run-mode-line-process
1279 (setq mode-line-process svn-pre-run-mode-line-process
)
1280 (setq svn-pre-run-mode-line-process nil
))))))
1281 (error "You can only run one svn process at once!")))
1283 (defun svn-process-sentinel-fixup-path-seperators ()
1284 "Convert all path separators to UNIX style.
1285 \(This is a no-op unless `system-type' is windows-nt\)"
1286 (when (eq system-type
'windows-nt
)
1288 (goto-char (point-min))
1289 (while (search-forward "\\" nil t
)
1290 (replace-match "/")))))
1292 (defun svn-process-sentinel (process event
)
1293 ;;(princ (format "Process: %s had the event `%s'" process event)))
1295 (let ((act-buf (current-buffer)))
1296 (when svn-pre-run-mode-line-process
1297 (with-current-buffer svn-status-pre-run-svn-buffer
1298 (setq mode-line-process svn-pre-run-mode-line-process
))
1299 (setq svn-pre-run-mode-line-process nil
))
1300 (set-buffer (process-buffer process
))
1301 (setq svn-status-mode-line-process-status
"")
1302 (svn-status-update-mode-line)
1303 (cond ((string= event
"finished\n")
1304 (run-hooks 'svn-post-process-svn-output-hook
)
1305 (cond ((eq svn-process-cmd
'status
)
1306 ;;(message "svn status finished")
1307 (svn-process-sentinel-fixup-path-seperators)
1308 (svn-parse-status-result)
1309 (svn-status-apply-elide-list)
1310 (when svn-status-update-previous-process-output
1311 (set-buffer (process-buffer process
))
1312 (delete-region (point-min) (point-max))
1313 (insert "Output from svn command:\n")
1314 (insert svn-status-update-previous-process-output
)
1315 (goto-char (point-min))
1316 (setq svn-status-update-previous-process-output nil
))
1317 (when svn-status-update-list
1318 ;; (message "Using svn-status-update-list: %S" svn-status-update-list)
1320 (svn-status-update-with-command-list svn-status-update-list
))
1321 (setq svn-status-update-list nil
))
1322 (when svn-status-display-new-status-buffer
1323 (set-window-configuration svn-status-initial-window-configuration
)
1324 (if (svn-had-user-input-since-asynch-run)
1325 (message "svn status finished")
1326 (switch-to-buffer svn-status-buffer-name
))))
1327 ((eq svn-process-cmd
'log
)
1328 (svn-status-show-process-output 'log t
)
1329 (pop-to-buffer svn-status-last-output-buffer-name
)
1332 (unless (looking-at "Changed paths:")
1334 (font-lock-fontify-buffer)
1335 (message "svn log finished"))
1336 ((eq svn-process-cmd
'info
)
1337 (svn-status-show-process-output 'info t
)
1338 (message "svn info finished"))
1339 ((eq svn-process-cmd
'ls
)
1340 (svn-status-show-process-output 'info t
)
1341 (message "svn ls finished"))
1342 ((eq svn-process-cmd
'diff
)
1343 (svn-status-activate-diff-mode)
1344 (message "svn diff finished"))
1345 ((eq svn-process-cmd
'parse-info
)
1346 (svn-status-parse-info-result))
1347 ((eq svn-process-cmd
'blame
)
1348 (svn-status-show-process-output 'blame t
)
1349 (when svn-status-pre-run-svn-buffer
1350 (with-current-buffer svn-status-pre-run-svn-buffer
1351 (unless (eq major-mode
'svn-status-mode
)
1352 (let ((src-line-number (svn-line-number-at-pos)))
1353 (pop-to-buffer (get-buffer svn-status-last-output-buffer-name
))
1354 (goto-line src-line-number
)))))
1355 (with-current-buffer (get-buffer svn-status-last-output-buffer-name
)
1356 (svn-status-activate-blame-mode))
1357 (message "svn blame finished"))
1358 ((eq svn-process-cmd
'commit
)
1359 (svn-process-sentinel-fixup-path-seperators)
1360 (svn-status-remove-temp-file-maybe)
1361 (when (member 'commit svn-status-unmark-files-after-list
)
1362 (svn-status-unset-all-usermarks))
1363 (svn-status-update-with-command-list (svn-status-parse-commit-output))
1364 (svn-revert-some-buffers)
1365 (run-hooks 'svn-log-edit-done-hook
)
1366 (setq svn-status-files-to-commit nil
1367 svn-status-recursive-commit nil
)
1368 (if (null svn-status-commit-rev-number
)
1369 (message "No revision to commit.")
1370 (message "svn: Committed revision %s." svn-status-commit-rev-number
)))
1371 ((eq svn-process-cmd
'update
)
1372 (svn-status-show-process-output 'update t
)
1373 (setq svn-status-update-list
(svn-status-parse-update-output))
1374 (svn-revert-some-buffers)
1376 (if (car svn-status-update-rev-number
)
1377 (message "svn: Updated to revision %s." (cadr svn-status-update-rev-number
))
1378 (message "svn: At revision %s." (cadr svn-status-update-rev-number
))))
1379 ((eq svn-process-cmd
'add
)
1380 (svn-status-update-with-command-list (svn-status-parse-ar-output))
1381 (message "svn add finished"))
1382 ((eq svn-process-cmd
'lock
)
1384 (message "svn lock finished"))
1385 ((eq svn-process-cmd
'unlock
)
1387 (message "svn unlock finished"))
1388 ((eq svn-process-cmd
'mkdir
)
1390 (message "svn mkdir finished"))
1391 ((eq svn-process-cmd
'revert
)
1392 (when (member 'revert svn-status-unmark-files-after-list
)
1393 (svn-status-unset-all-usermarks))
1394 (svn-revert-some-buffers)
1396 (message "svn revert finished"))
1397 ((eq svn-process-cmd
'resolved
)
1399 (message "svn resolved finished"))
1400 ((eq svn-process-cmd
'rm
)
1401 (svn-status-update-with-command-list (svn-status-parse-ar-output))
1402 (message "svn rm finished"))
1403 ((eq svn-process-cmd
'cleanup
)
1404 (message "svn cleanup finished"))
1405 ((eq svn-process-cmd
'proplist
)
1406 (svn-status-show-process-output 'proplist t
)
1407 (message "svn proplist finished"))
1408 ((eq svn-process-cmd
'checkout
)
1409 (svn-status default-directory
))
1410 ((eq svn-process-cmd
'proplist-parse
)
1411 (svn-status-property-parse-property-names))
1412 ((eq svn-process-cmd
'propset
)
1413 (svn-status-remove-temp-file-maybe)
1414 (if (member svn-status-propedit-property-name
'("svn:keywords"))
1415 (svn-status-update-with-command-list (svn-status-parse-property-output))
1416 (svn-status-update)))
1417 ((eq svn-process-cmd
'propdel
)
1418 (svn-status-update))))
1419 ((string= event
"killed\n")
1420 (message "svn process killed"))
1421 ((string-match "exited abnormally" event
)
1422 (while (accept-process-output process
0 100))
1423 ;; find last error message and show it.
1424 (goto-char (point-max))
1425 (if (re-search-backward "^svn: \\(.*\\)" nil t
)
1426 (svn-process-handle-error (match-string 1))
1427 (message "svn failed: %s" event
)))
1429 (message "svn process had unknown event: %s" event
))
1430 (svn-status-show-process-output nil t
))))
1432 (defvar svn-process-handle-error-msg nil
)
1433 (defun svn-process-handle-error (error-msg)
1434 (let ((svn-process-handle-error-msg error-msg
))
1435 (electric-helpify 'svn-process-help-with-error-msg
)))
1437 (defun svn-process-help-with-error-msg ()
1439 (let ((help-msg (cadr (assoc svn-process-handle-error-msg
1440 '(("Cannot non-recursively commit a directory deletion"
1441 "Please unmark all files and position point at the directory you would like to remove.\nThen run commit again."))))))
1444 (with-output-to-temp-buffer (help-buffer)
1445 (princ (format "svn failed: %s\n\n%s" svn-process-handle-error-msg help-msg
))))
1446 (message "svn failed: %s" svn-process-handle-error-msg
))))
1449 (defun svn-process-filter (process str
)
1450 "Track the svn process output and ask user questions in the minibuffer when appropriate."
1451 (save-window-excursion
1452 (set-buffer svn-process-buffer-name
)
1453 ;;(message "svn-process-filter: %s" str)
1454 (goto-char (point-max))
1457 (goto-char (svn-point-at-bol))
1458 (when (looking-at "Password for '\\(.+\\)': ")
1459 ;(svn-status-show-process-buffer)
1460 (let ((passwd (read-passwd
1461 (format "Enter svn password for %s: " (match-string 1)))))
1462 (svn-process-send-string-and-newline passwd t
)))
1463 (when (looking-at "Username: ")
1464 (let ((user-name (read-string "Username for svn operation: ")))
1465 (svn-process-send-string-and-newline user-name
)))
1466 (when (looking-at "(R)eject, accept (t)emporarily or accept (p)ermanently")
1467 (svn-status-show-process-buffer)
1468 (let ((answer (read-string "(R)eject, accept (t)emporarily or accept (p)ermanently? ")))
1469 (svn-process-send-string (substring answer
0 1)))))))
1471 (defun svn-revert-some-buffers (&optional tree
)
1472 "Reverts all buffers visiting a file in TREE that aren't modified.
1473 To be run after a commit, an update or a merge."
1475 (let ((tree (or (svn-status-base-dir) tree
)))
1476 (dolist (buffer (buffer-list))
1477 (with-current-buffer buffer
1478 (when (not (buffer-modified-p))
1479 (let ((file (buffer-file-name)))
1481 (let ((root (svn-status-base-dir (file-name-directory file
)))
1482 (point-pos (point)))
1485 ;; buffer is modified and in the tree TREE.
1486 svn-status-auto-revert-buffers
)
1487 (when svn-status-fancy-file-state-in-modeline
1488 (svn-status-update-modeline))
1489 ;; (message "svn-revert-some-buffers: %s %s" (buffer-file-name) (verify-visited-file-modtime (current-buffer)))
1490 ;; Keep the buffer if the file doesn't exist
1491 (when (and (file-exists-p file
) (not (verify-visited-file-modtime (current-buffer))))
1493 (goto-char point-pos
)))))))))))
1495 (defun svn-parse-rev-num (str)
1496 (if (and str
(stringp str
)
1497 (save-match-data (string-match "^[0-9]+" str
)))
1498 (string-to-number str
)
1501 (defsubst svn-status-make-ui-status
()
1502 "Make a ui-status structure for a file in a svn working copy.
1503 The initial values in the structure returned by this function
1504 are good for a file or directory that the user hasn't seen before.
1506 The ui-status structure keeps track of how the file or directory
1507 should be displayed in svn-status mode. Updating the svn-status
1508 buffer from the working copy preserves the ui-status if possible.
1509 User commands modify this structure; each file or directory must
1510 thus have its own copy.
1512 Currently, the ui-status is a list (USER-MARK USER-ELIDE).
1513 USER-MARK is non-nil iff the user has marked the file or directory,
1514 typically with `svn-status-set-user-mark'. To read USER-MARK,
1515 call `svn-status-line-info->has-usermark'.
1516 USER-ELIDE is non-nil iff the user has elided the file or directory
1517 from the svn-status buffer, typically with `svn-status-toggle-elide'.
1518 To read USER-ELIDE, call `svn-status-line-info->user-elide'.
1520 Call `svn-status-line-info->ui-status' to access the whole ui-status
1524 (defun svn-status-make-dummy-dirs (dir-list old-ui-information
)
1525 "Calculate additionally necessary directories that were not shown in the output
1527 ;; (message "svn-status-make-dummy-dirs %S" dir-list)
1530 (dolist (dir dir-list
)
1531 (setq base-dir
(file-name-directory dir
))
1533 ;;(message "dir: %S dir-list: %S, base-dir: %S" dir dir-list base-dir)
1534 (setq candidate
(replace-regexp-in-string "/+$" "" base-dir
))
1535 (setq base-dir
(file-name-directory candidate
))
1536 ;; (message "dir: %S, candidate: %S" dir candidate)
1537 (add-to-list 'dir-list candidate
))))
1538 ;; (message "svn-status-make-dummy-dirs %S" dir-list)
1539 (append (mapcar (lambda (dir)
1540 (svn-status-make-line-info
1542 (gethash dir old-ui-information
)))
1546 (defun svn-status-make-line-info (&optional
1550 local-rev last-change-rev
1558 "Create a new line-info from the given arguments
1559 Anything left nil gets a sensible default.
1560 nb: LOCKED-MARK refers to the kind of locks you get after an error,
1561 LOCKED-REPO-MARK is the kind managed with `svn lock'"
1562 (list (or ui
(svn-status-make-ui-status))
1567 (or last-change-rev ?
)
1576 (defvar svn-user-names-including-blanks nil
"A list of svn user names that include blanks.
1577 To add support for the names \"feng shui\" and \"mister blank\", place the following in your .emacs:
1578 (setq svn-user-names-including-blanks '(\"feng shui\" \"mister blank\"))
1579 (add-hook 'svn-pre-parse-status-hook 'svn-status-parse-fixup-user-names-including-blanks)
1581 ;;(setq svn-user-names-including-blanks '("feng shui" "mister blank"))
1582 ;;(add-hook 'svn-pre-parse-status-hook 'svn-status-parse-fixup-user-names-including-blanks)
1584 (defun svn-status-parse-fixup-user-names-including-blanks ()
1585 "Helper function to allow user names that include blanks.
1586 Add this function to the `svn-pre-parse-status-hook'. The variable
1587 `svn-user-names-including-blanks' must be configured to hold all user names that contain
1588 blanks. This function replaces the blanks with '-' to allow further processing with
1589 the usual parsing functionality in `svn-parse-status-result'."
1590 (when svn-user-names-including-blanks
1591 (goto-char (point-min))
1592 (let ((search-string (concat " \\(" (mapconcat 'concat svn-user-names-including-blanks
"\\|") "\\) ")))
1595 (while (re-search-forward search-string
(point-max) t
)
1596 (replace-match (replace-regexp-in-string " " "-" (match-string 1)) nil nil nil
1)))))))
1598 (defun svn-parse-status-result ()
1599 "Parse the `svn-process-buffer-name' buffer.
1600 The results are used to build the `svn-status-info' variable."
1601 (setq svn-status-head-revision nil
)
1603 (let ((old-ui-information (svn-status-ui-information-hash-table))
1607 (svn-wc-locked-mark)
1608 (svn-repo-locked-mark)
1609 (svn-with-history-mark)
1617 (revision-width svn-status-default-revision-width
)
1618 (author-width svn-status-default-author-width
)
1619 (svn-marks-length (if svn-status-verbose
1620 (if svn-status-remote
1622 (if svn-status-remote
1626 (externals-map (make-hash-table :test
'equal
))
1627 (skip-double-external-dir-entry-name nil
))
1628 (set-buffer svn-process-buffer-name
)
1629 (setq svn-status-info nil
)
1630 (run-hooks 'svn-pre-parse-status-hook
)
1631 (goto-char (point-min))
1632 (while (< (point) (point-max))
1634 ((= (svn-point-at-eol) (svn-point-at-bol)) ;skip blank lines
1636 ((looking-at "Status against revision:[ ]+\\([0-9]+\\)")
1637 ;; the above message appears for the main listing plus once for each svn:externals entry
1638 (unless svn-status-head-revision
1639 (setq svn-status-head-revision
(match-string 1))))
1640 ((looking-at "Performing status on external item at '\\(.*\\)'")
1641 ;; The *next* line has info about the directory named in svn:externals
1642 ;; [ie the directory in (match-string 1)]
1643 ;; we should parse it, and merge the info with what we have already know
1644 ;; but for now just ignore the line completely
1646 ;; Actually, this seems to not always be the case
1647 ;; I have an example where we are in an svn:external which
1648 ;; is itself inside a svn:external, this need not be true:
1649 ;; the next line is not 'X dir' but just 'dir', so we
1650 ;; actually need to parse that line, or the results will
1652 ;; so we should merge lines 'X dir' with ' dir', but for now
1653 ;; we just leave both in the results
1655 ;; My attempt to merge the lines uses skip-double-external-dir-entry-name
1656 ;; and externals-map
1657 (setq skip-double-external-dir-entry-name
(svn-match-string-no-properties 1))
1658 ;; (message "Going to skip %s" skip-double-external-dir-entry-name)
1660 ((looking-at "--- Changelist") ; skip svn changelist header lines
1661 ;; See: http://svn.collab.net/repos/svn/trunk/notes/changelist-design.txt
1664 (setq svn-marks
(buffer-substring (point) (+ (point) svn-marks-length
))
1665 svn-file-mark
(elt svn-marks
0) ; 1st column - M,A,C,D,G,? etc
1666 svn-property-mark
(elt svn-marks
1) ; 2nd column - M,C (properties)
1667 svn-wc-locked-mark
(elt svn-marks
2) ; 3rd column - L or blank
1668 svn-with-history-mark
(elt svn-marks
3) ; 4th column - + or blank
1669 svn-switched-mark
(elt svn-marks
4) ; 5th column - S or blank
1670 svn-repo-locked-mark
(elt svn-marks
5)) ; 6th column - K,O,T,B or blank
1671 (when svn-status-remote
1672 (setq svn-update-mark
(elt svn-marks
7))) ; 8th column - * or blank
1673 (when (eq svn-property-mark ?\
) (setq svn-property-mark nil
))
1674 (when (eq svn-wc-locked-mark ?\
) (setq svn-wc-locked-mark nil
))
1675 (when (eq svn-with-history-mark ?\
) (setq svn-with-history-mark nil
))
1676 (when (eq svn-switched-mark ?\
) (setq svn-switched-mark nil
))
1677 (when (eq svn-update-mark ?\
) (setq svn-update-mark nil
))
1678 (when (eq svn-repo-locked-mark ?\
) (setq svn-repo-locked-mark nil
))
1679 (forward-char svn-marks-length
)
1680 (skip-chars-forward " ")
1681 ;; (message "after marks: '%s'" (buffer-substring (point) (line-end-position)))
1683 ((looking-at "\\([-?]\\|[0-9]+\\) +\\([-?]\\|[0-9]+\\) +\\([^ ]+\\) *\\(.+\\)$")
1684 (setq local-rev
(svn-parse-rev-num (match-string 1))
1685 last-change-rev
(svn-parse-rev-num (match-string 2))
1686 author
(match-string 3)
1687 path
(match-string 4)))
1688 ((looking-at "\\([-?]\\|[0-9]+\\) +\\([^ ]+\\)$")
1689 (setq local-rev
(svn-parse-rev-num (match-string 1))
1692 path
(match-string 2)))
1693 ((looking-at "\\(.*\\)")
1694 (setq path
(match-string 1)
1697 author
(if (eq svn-file-mark ?X
) "" "?"))) ;clear author of svn:externals dirs
1699 (error "Unknown status line format")))
1700 (unless path
(setq path
"."))
1701 (setq dir
(file-name-directory path
))
1702 (if (and (not svn-status-verbose
) dir
)
1703 (let ((dirname (directory-file-name dir
)))
1704 (if (not (member dirname dir-set
))
1705 (setq dir-set
(cons dirname dir-set
)))))
1706 (if (and skip-double-external-dir-entry-name
(string= skip-double-external-dir-entry-name path
))
1707 ;; merge this entry to a previous saved one
1708 (let ((info (gethash path externals-map
)))
1709 ;; (message "skip-double-external-dir-entry-name: %s - path: %s" skip-double-external-dir-entry-name path)
1712 (svn-status-line-info->set-localrev info local-rev
)
1713 (svn-status-line-info->set-lastchangerev info last-change-rev
)
1714 (svn-status-line-info->set-author info author
)
1715 (svn-status-message 3 "merging entry for %s to %s" path info
)
1716 (setq skip-double-external-dir-entry-name nil
))
1717 (message "psvn: %s not handled correct, please report this case." path
)))
1718 (setq svn-status-info
1719 (cons (svn-status-make-line-info path
1720 (gethash path old-ui-information
)
1728 svn-with-history-mark
1730 svn-repo-locked-mark
1731 nil
) ;;psvn-extra-info
1733 (when (eq svn-file-mark ?X
)
1734 (svn-puthash (match-string 1) (car svn-status-info
) externals-map
)
1735 (svn-status-message 3 "found external: %s %S" (match-string 1) (car svn-status-info
)))
1736 (setq revision-width
(max revision-width
1737 (length (number-to-string local-rev
))
1738 (length (number-to-string last-change-rev
))))
1739 (setq author-width
(max author-width
(length author
)))))
1741 (unless svn-status-verbose
1742 (setq svn-status-info
(svn-status-make-dummy-dirs dir-set
1743 old-ui-information
)))
1744 (setq svn-status-default-column
1745 (+ 6 revision-width revision-width author-width
1746 (if svn-status-short-mod-flag-p
3 0)))
1747 (setq svn-status-line-format
(format " %%c%%c%%c %%%ds %%%ds %%-%ds"
1751 (setq svn-status-info
(nreverse svn-status-info
))
1752 (when svn-status-sort-status-buffer
1753 (setq svn-status-info
(sort svn-status-info
'svn-status-sort-predicate
))))))
1755 ;;(string-lessp "." "%") => nil
1756 ;(svn-status-sort-predicate '(t t t ".") '(t t t "%")) => t
1757 (defun svn-status-sort-predicate (a b
)
1758 "Return t if A should appear before B in the `svn-status-buffer-name' buffer.
1759 A and B must be line-info's."
1760 (string-lessp (concat (svn-status-line-info->full-path a
) "/")
1761 (concat (svn-status-line-info->full-path b
) "/")))
1763 (defun svn-status-remove-temp-file-maybe ()
1764 "Remove any (no longer required) temporary files created by psvn.el."
1765 (when svn-status-temp-file-to-remove
1766 (when (file-exists-p svn-status-temp-file-to-remove
)
1767 (delete-file svn-status-temp-file-to-remove
))
1768 (when (file-exists-p svn-status-temp-arg-file
)
1769 (delete-file svn-status-temp-arg-file
))
1770 (setq svn-status-temp-file-to-remove nil
)))
1772 (defun svn-status-remove-control-M ()
1773 "Remove ^M at end of line in the whole buffer."
1775 (let ((buffer-read-only nil
))
1778 (goto-char (point-min))
1779 (while (re-search-forward "\r$" (point-max) t
)
1780 (replace-match "" nil nil
))))))
1783 ;;(easy-menu-add-item nil '("tools") ["SVN Status" svn-status t] "PCL-CVS")
1784 (easy-menu-add-item nil
'("tools") ["SVN Status" svn-status t
])
1785 (error (message "psvn: could not install menu")))
1787 (defvar svn-status-mode-map
() "Keymap used in `svn-status-mode' buffers.")
1788 (put 'svn-status-mode-map
'risky-local-variable t
) ;for Emacs 20.7
1789 (defvar svn-status-mode-mark-map
()
1790 "Subkeymap used in `svn-status-mode' for mark commands.")
1791 (put 'svn-status-mode-mark-map
'risky-local-variable t
) ;for Emacs 20.7
1792 (defvar svn-status-mode-property-map
()
1793 "Subkeymap used in `svn-status-mode' for property commands.")
1794 (put 'svn-status-mode-property-map
'risky-local-variable t
) ;for Emacs 20.7
1795 (defvar svn-status-mode-options-map
()
1796 "Subkeymap used in `svn-status-mode' for option commands.")
1797 (put 'svn-status-mode-options-map
'risky-local-variable t
) ;for Emacs 20.7
1798 (defvar svn-status-mode-trac-map
()
1799 "Subkeymap used in `svn-status-mode' for trac issue tracker commands.")
1800 (put 'svn-status-mode-trac-map
'risky-local-variable t
) ;for Emacs 20.7
1801 (defvar svn-status-mode-extension-map
()
1802 "Subkeymap used in `svn-status-mode' for some seldom used commands.")
1803 (put 'svn-status-mode-extension-map
'risky-local-variable t
) ;for Emacs 20.7
1804 (defvar svn-status-mode-branch-map
()
1805 "Subkeymap used in `svn-status-mode' for branching commands.")
1806 (put 'svn-status-mode-extension-map
'risky-local-variable t
) ;for Emacs 20.7
1808 (when (not svn-status-mode-map
)
1809 (setq svn-status-mode-map
(make-sparse-keymap))
1810 (suppress-keymap svn-status-mode-map
)
1811 ;; Don't use (kbd "<return>"); it's unreachable with GNU Emacs 21.3 on a TTY.
1812 (define-key svn-status-mode-map
(kbd "RET") 'svn-status-find-file-or-examine-directory
)
1813 (define-key svn-status-mode-map
(kbd "<mouse-2>") 'svn-status-mouse-find-file-or-examine-directory
)
1814 (define-key svn-status-mode-map
(kbd "^") 'svn-status-examine-parent
)
1815 (define-key svn-status-mode-map
(kbd "s") 'svn-status-show-process-buffer
)
1816 (define-key svn-status-mode-map
(kbd "h") 'svn-status-pop-to-partner-buffer
)
1817 (define-key svn-status-mode-map
(kbd "f") 'svn-status-find-files
)
1818 (define-key svn-status-mode-map
(kbd "o") 'svn-status-find-file-other-window
)
1819 (define-key svn-status-mode-map
(kbd "C-o") 'svn-status-find-file-other-window-noselect
)
1820 (define-key svn-status-mode-map
(kbd "v") 'svn-status-view-file-other-window
)
1821 (define-key svn-status-mode-map
(kbd "e") 'svn-status-toggle-edit-cmd-flag
)
1822 (define-key svn-status-mode-map
(kbd "g") 'svn-status-update
)
1823 (define-key svn-status-mode-map
(kbd "M-s") 'svn-status-update
) ;; PCL-CVS compatibility
1824 (define-key svn-status-mode-map
(kbd "q") 'svn-status-bury-buffer
)
1825 (define-key svn-status-mode-map
(kbd "x") 'svn-status-redraw-status-buffer
)
1826 (define-key svn-status-mode-map
(kbd "H") 'svn-status-use-history
)
1827 (define-key svn-status-mode-map
(kbd "m") 'svn-status-set-user-mark
)
1828 (define-key svn-status-mode-map
(kbd "u") 'svn-status-unset-user-mark
)
1829 ;; This matches a binding of `dired-unmark-all-files' in `dired-mode-map'
1830 ;; of both GNU Emacs and XEmacs. It seems unreachable with XEmacs on
1831 ;; TTY, but if that's a problem then its Dired needs fixing too.
1832 ;; Or you could just use "*!".
1833 (define-key svn-status-mode-map
"\M-\C-?" 'svn-status-unset-all-usermarks
)
1834 ;; The key that normally deletes characters backwards should here
1835 ;; instead unmark files backwards. In GNU Emacs, that would be (kbd
1836 ;; "DEL") aka [?\177], but XEmacs treats those as [(delete)] and
1837 ;; would bind a key that normally deletes forwards. [(backspace)]
1838 ;; is unreachable with GNU Emacs on a tty. Try to recognize the
1839 ;; dialect and act accordingly.
1841 ;; XEmacs has a `delete-forward-p' function that checks the
1842 ;; `delete-key-deletes-forward' option. We don't use those, for two
1843 ;; reasons: psvn.el may be loaded before user customizations, and
1844 ;; XEmacs allows simultaneous connections to multiple devices with
1845 ;; different keyboards.
1846 (define-key svn-status-mode-map
1847 (if (member (kbd "DEL") '([(delete)] [delete]))
1848 [(backspace)] ; XEmacs
1849 (kbd "DEL")) ; GNU Emacs
1850 'svn-status-unset-user-mark-backwards)
1851 (define-key svn-status-mode-map (kbd "$") 'svn-status-toggle-elide)
1852 (define-key svn-status-mode-map (kbd "w") 'svn-status-copy-current-line-info)
1853 (define-key svn-status-mode-map (kbd ".") 'svn-status-goto-root-or-return)
1854 (define-key svn-status-mode-map (kbd "I") 'svn-status-parse-info)
1855 (define-key svn-status-mode-map (kbd "V") 'svn-status-svnversion)
1856 (define-key svn-status-mode-map (kbd "?") 'svn-status-toggle-hide-unknown)
1857 (define-key svn-status-mode-map (kbd "_") 'svn-status-toggle-hide-unmodified)
1858 (define-key svn-status-mode-map (kbd "a") 'svn-status-add-file)
1859 (define-key svn-status-mode-map (kbd "A") 'svn-status-add-file-recursively)
1860 (define-key svn-status-mode-map (kbd "+") 'svn-status-make-directory)
1861 (define-key svn-status-mode-map (kbd "R") 'svn-status-mv)
1862 (define-key svn-status-mode-map (kbd "C") 'svn-status-cp)
1863 (define-key svn-status-mode-map (kbd "D") 'svn-status-rm)
1864 (define-key svn-status-mode-map (kbd "c") 'svn-status-commit)
1865 (define-key svn-status-mode-map (kbd "M-c") 'svn-status-cleanup)
1866 (define-key svn-status-mode-map (kbd "k") 'svn-status-lock)
1867 (define-key svn-status-mode-map (kbd "K") 'svn-status-unlock)
1868 (define-key svn-status-mode-map (kbd "U") 'svn-status-update-cmd)
1869 (define-key svn-status-mode-map (kbd "M-u") 'svn-status-update-cmd)
1870 (define-key svn-status-mode-map (kbd "r") 'svn-status-revert)
1871 (define-key svn-status-mode-map (kbd "l") 'svn-status-show-svn-log)
1872 (define-key svn-status-mode-map (kbd "i") 'svn-status-info)
1873 (define-key svn-status-mode-map (kbd "b") 'svn-status-blame)
1874 (define-key svn-status-mode-map (kbd "=") 'svn-status-show-svn-diff)
1875 ;; [(control ?=)] is unreachable on TTY, but you can use "*u" instead.
1876 ;; (Is the "u" mnemonic for something?)
1877 (define-key svn-status-mode-map (kbd "C-=") 'svn-status-show-svn-diff-for-marked-files)
1878 (define-key svn-status-mode-map (kbd "~") 'svn-status-get-specific-revision)
1879 (define-key svn-status-mode-map (kbd "E") 'svn-status-ediff-with-revision)
1881 (define-key svn-status-mode-map (kbd "n") 'svn-status-next-line)
1882 (define-key svn-status-mode-map (kbd "p") 'svn-status-previous-line)
1883 (define-key svn-status-mode-map (kbd "<down>") 'svn-status-next-line)
1884 (define-key svn-status-mode-map (kbd "<up>") 'svn-status-previous-line)
1885 (define-key svn-status-mode-map (kbd "C-x C-j") 'svn-status-dired-jump)
1886 (define-key svn-status-mode-map [down-mouse-3] 'svn-status-popup-menu)
1887 (setq svn-status-mode-mark-map (make-sparse-keymap))
1888 (define-key svn-status-mode-map (kbd "*") svn-status-mode-mark-map)
1889 (define-key svn-status-mode-mark-map (kbd "!") 'svn-status-unset-all-usermarks)
1890 (define-key svn-status-mode-mark-map (kbd "?") 'svn-status-mark-unknown)
1891 (define-key svn-status-mode-mark-map (kbd "A") 'svn-status-mark-added)
1892 (define-key svn-status-mode-mark-map (kbd "M") 'svn-status-mark-modified)
1893 (define-key svn-status-mode-mark-map (kbd "D") 'svn-status-mark-deleted)
1894 (define-key svn-status-mode-mark-map (kbd "*") 'svn-status-mark-changed)
1895 (define-key svn-status-mode-mark-map (kbd ".") 'svn-status-mark-by-file-ext)
1896 (define-key svn-status-mode-mark-map (kbd "%") 'svn-status-mark-filename-regexp)
1897 (define-key svn-status-mode-mark-map (kbd "u") 'svn-status-show-svn-diff-for-marked-files))
1898 (when (not svn-status-mode-property-map)
1899 (setq svn-status-mode-property-map (make-sparse-keymap))
1900 (define-key svn-status-mode-property-map (kbd "l") 'svn-status-property-list)
1901 (define-key svn-status-mode-property-map (kbd "s") 'svn-status-property-set)
1902 (define-key svn-status-mode-property-map (kbd "d") 'svn-status-property-delete)
1903 (define-key svn-status-mode-property-map (kbd "e") 'svn-status-property-edit-one-entry)
1904 (define-key svn-status-mode-property-map (kbd "i") 'svn-status-property-ignore-file)
1905 (define-key svn-status-mode-property-map (kbd "I") 'svn-status-property-ignore-file-extension)
1906 ;; XEmacs 21.4.15 on TTY (vt420) converts `C-i' to `TAB',
1907 ;; which [(control ?i)] won't match. Handle it separately.
1908 ;; On GNU Emacs, the following two forms bind the same key,
1909 ;; reducing clutter in `where-is'.
1910 (define-key svn-status-mode-property-map [(control ?i)] 'svn-status-property-edit-svn-ignore)
1911 (define-key svn-status-mode-property-map (kbd "TAB") 'svn-status-property-edit-svn-ignore)
1912 (define-key svn-status-mode-property-map (kbd "k") 'svn-status-property-set-keyword-list)
1913 (define-key svn-status-mode-property-map (kbd "Ki") 'svn-status-property-set-keyword-id)
1914 (define-key svn-status-mode-property-map (kbd "Kd") 'svn-status-property-set-keyword-date)
1915 (define-key svn-status-mode-property-map (kbd "y") 'svn-status-property-set-eol-style)
1916 (define-key svn-status-mode-property-map (kbd "x") 'svn-status-property-set-executable)
1917 (define-key svn-status-mode-property-map (kbd "m") 'svn-status-property-set-mime-type)
1918 ;; TODO: Why is `svn-status-select-line' in `svn-status-mode-property-map'?
1919 (define-key svn-status-mode-property-map (kbd "RET") 'svn-status-select-line)
1920 (define-key svn-status-mode-map (kbd "P") svn-status-mode-property-map))
1921 (when (not svn-status-mode-extension-map)
1922 (setq svn-status-mode-extension-map (make-sparse-keymap))
1923 (define-key svn-status-mode-extension-map (kbd "v") 'svn-status-resolved)
1924 (define-key svn-status-mode-extension-map (kbd "X") 'svn-status-resolve-conflicts)
1925 (define-key svn-status-mode-extension-map (kbd "e") 'svn-status-export)
1926 (define-key svn-status-mode-map (kbd "X") svn-status-mode-extension-map))
1927 (when (not svn-status-mode-options-map)
1928 (setq svn-status-mode-options-map (make-sparse-keymap))
1929 (define-key svn-status-mode-options-map (kbd "s") 'svn-status-save-state)
1930 (define-key svn-status-mode-options-map (kbd "l") 'svn-status-load-state)
1931 (define-key svn-status-mode-options-map (kbd "x") 'svn-status-toggle-sort-status-buffer)
1932 (define-key svn-status-mode-options-map (kbd "v") 'svn-status-toggle-svn-verbose-flag)
1933 (define-key svn-status-mode-options-map (kbd "f") 'svn-status-toggle-display-full-path)
1934 (define-key svn-status-mode-options-map (kbd "t") 'svn-status-set-trac-project-root)
1935 (define-key svn-status-mode-options-map (kbd "n") 'svn-status-set-module-name)
1936 (define-key svn-status-mode-options-map (kbd "c") 'svn-status-set-changelog-style)
1937 (define-key svn-status-mode-options-map (kbd "b") 'svn-status-set-branch-list)
1938 (define-key svn-status-mode-map (kbd "O") svn-status-mode-options-map))
1939 (when (not svn-status-mode-trac-map)
1940 (setq svn-status-mode-trac-map (make-sparse-keymap))
1941 (define-key svn-status-mode-trac-map (kbd "w") 'svn-trac-browse-wiki)
1942 (define-key svn-status-mode-trac-map (kbd "t") 'svn-trac-browse-timeline)
1943 (define-key svn-status-mode-trac-map (kbd "m") 'svn-trac-browse-roadmap)
1944 (define-key svn-status-mode-trac-map (kbd "r") 'svn-trac-browse-report)
1945 (define-key svn-status-mode-trac-map (kbd "s") 'svn-trac-browse-source)
1946 (define-key svn-status-mode-trac-map (kbd "i") 'svn-trac-browse-ticket)
1947 (define-key svn-status-mode-trac-map (kbd "c") 'svn-trac-browse-changeset)
1948 (define-key svn-status-mode-map (kbd "T") svn-status-mode-trac-map))
1949 (when (not svn-status-mode-branch-map)
1950 (setq svn-status-mode-branch-map (make-sparse-keymap))
1951 (define-key svn-status-mode-branch-map (kbd "d") 'svn-branch-diff)
1952 (define-key svn-status-mode-map (kbd "B") svn-status-mode-branch-map))
1954 (easy-menu-define svn-status-mode-menu svn-status-mode-map
1955 "'svn-status-mode' menu"
1957 ["svn status" svn-status-update t]
1958 ["svn update" svn-status-update-cmd t]
1959 ["svn commit" svn-status-commit t]
1960 ["svn log" svn-status-show-svn-log t]
1961 ["svn info" svn-status-info t]
1962 ["svn blame" svn-status-blame t]
1964 ["svn diff current file" svn-status-show-svn-diff t]
1965 ["svn diff marked files" svn-status-show-svn-diff-for-marked-files t]
1966 ["svn ediff current file" svn-status-ediff-with-revision t]
1967 ["svn resolve conflicts" svn-status-resolve-conflicts]
1969 ["svn cat ..." svn-status-get-specific-revision t]
1970 ["svn add" svn-status-add-file t]
1971 ["svn add recursively" svn-status-add-file-recursively t]
1972 ["svn mkdir..." svn-status-make-directory t]
1973 ["svn mv..." svn-status-mv t]
1974 ["svn cp..." svn-status-cp t]
1975 ["svn rm..." svn-status-rm t]
1976 ["svn export..." svn-status-export t]
1977 ["Up Directory" svn-status-examine-parent t]
1978 ["Elide Directory" svn-status-toggle-elide t]
1979 ["svn revert" svn-status-revert t]
1980 ["svn resolved" svn-status-resolved t]
1981 ["svn cleanup" svn-status-cleanup t]
1982 ["svn lock" svn-status-lock t]
1983 ["svn unlock" svn-status-unlock t]
1984 ["Show Process Buffer" svn-status-show-process-buffer t]
1986 ["diff" svn-branch-diff t]
1987 ["Set Branch list" svn-status-set-branch-list t]
1990 ["svn proplist" svn-status-property-list t]
1991 ["Set Multiple Properties..." svn-status-property-set t]
1992 ["Edit One Property..." svn-status-property-edit-one-entry t]
1993 ["svn propdel..." svn-status-property-delete t]
1995 ["svn:ignore File..." svn-status-property-ignore-file t]
1996 ["svn:ignore File Extension..." svn-status-property-ignore-file-extension t]
1997 ["Edit svn:ignore Property" svn-status-property-edit-svn-ignore t]
1999 ["Edit svn:keywords List" svn-status-property-set-keyword-list t]
2000 ["Add/Remove Id to/from svn:keywords" svn-status-property-set-keyword-id t]
2001 ["Add/Remove Date to/from svn:keywords" svn-status-property-set-keyword-date t]
2003 ["Select svn:eol-style" svn-status-property-set-eol-style t]
2004 ["Set svn:executable" svn-status-property-set-executable t]
2005 ["Set svn:mime-type" svn-status-property-set-mime-type t]
2008 ["Save Options" svn-status-save-state t]
2009 ["Load Options" svn-status-load-state t]
2010 ["Set Trac project root" svn-status-set-trac-project-root t]
2011 ["Set Short module name" svn-status-set-module-name t]
2012 ["Set Changelog style" svn-status-set-changelog-style t]
2013 ["Set Branch list" svn-status-set-branch-list t]
2014 ["Sort the *svn-status* buffer" svn-status-toggle-sort-status-buffer
2015 :style toggle :selected svn-status-sort-status-buffer]
2016 ["Use -v for svn status calls" svn-status-toggle-svn-verbose-flag
2017 :style toggle :selected svn-status-verbose]
2018 ["Display full path names" svn-status-toggle-display-full-path
2019 :style toggle :selected svn-status-display-full-path]
2022 ["Browse wiki" svn-trac-browse-wiki t]
2023 ["Browse timeline" svn-trac-browse-timeline t]
2024 ["Browse roadmap" svn-trac-browse-roadmap t]
2025 ["Browse source" svn-trac-browse-source t]
2026 ["Browse report" svn-trac-browse-report t]
2027 ["Browse ticket" svn-trac-browse-ticket t]
2028 ["Browse changeset" svn-trac-browse-changeset t]
2029 ["Set Trac project root" svn-status-set-trac-project-root t]
2032 ["Edit Next SVN Cmd Line" svn-status-toggle-edit-cmd-flag t]
2033 ["Work Directory History..." svn-status-use-history t]
2035 ["Mark" svn-status-set-user-mark t]
2036 ["Unmark" svn-status-unset-user-mark t]
2037 ["Unmark all" svn-status-unset-all-usermarks t]
2039 ["Mark/Unmark unknown" svn-status-mark-unknown t]
2040 ["Mark/Unmark added" svn-status-mark-added t]
2041 ["Mark/Unmark modified" svn-status-mark-modified t]
2042 ["Mark/Unmark deleted" svn-status-mark-deleted t]
2043 ["Mark/Unmark modified/added/deleted" svn-status-mark-changed t]
2044 ["Mark/Unmark filename by extension" svn-status-mark-by-file-ext t]
2045 ["Mark/Unmark filename by regexp" svn-status-mark-filename-regexp t]
2047 ["Hide Unknown" svn-status-toggle-hide-unknown
2048 :style toggle :selected svn-status-hide-unknown]
2049 ["Hide Unmodified" svn-status-toggle-hide-unmodified
2050 :style toggle :selected svn-status-hide-unmodified]
2051 ["Show Client versions" svn-status-version t]
2052 ["Prepare bug report" svn-prepare-bug-report t]
2055 (defvar svn-status-file-popup-menu-list
2056 '(["open" svn-status-find-file-other-window t]
2057 ["svn diff" svn-status-show-svn-diff t]
2058 ["svn commit" svn-status-commit t]
2059 ["svn log" svn-status-show-svn-log t]
2060 ["svn blame" svn-status-blame t]
2061 ["mark" svn-status-set-user-mark t]
2062 ["unmark" svn-status-unset-user-mark t]
2063 ["svn add" svn-status-add-file t]
2064 ["svn add recursively" svn-status-add-file-recursively t]
2065 ["svn mv..." svn-status-mv t]
2066 ["svn rm..." svn-status-rm t]
2067 ["svn lock" svn-status-lock t]
2068 ["svn unlock" svn-status-unlock t]
2069 ["svn info" svn-status-info t]
2070 ) "A list of menu entries for `svn-status-popup-menu'")
2072 ;; extend svn-status-file-popup-menu-list via:
2073 ;; (add-to-list 'svn-status-file-popup-menu-list ["commit" svn-status-commit t])
2075 (defun svn-status-popup-menu (event)
2076 "Display a file specific popup menu"
2078 (mouse-set-point event)
2079 (let* ((line-info (svn-status-get-line-information))
2080 (name (svn-status-line-info->filename line-info)))
2082 (easy-menu-define svn-status-actual-popup-menu nil nil
2083 (append (list name) svn-status-file-popup-menu-list))
2084 (svn-status-face-set-temporary-during-popup
2085 'svn-status-marked-popup-face (svn-point-at-bol) (svn-point-at-eol)
2086 svn-status-actual-popup-menu))))
2088 (defun svn-status-face-set-temporary-during-popup (face begin end menu &optional prefix)
2089 "Put FACE on BEGIN and END in the buffer during Popup MENU.
2090 PREFIX is passed to `popup-menu'."
2094 (setq o (make-overlay begin end))
2095 (overlay-put o 'face face)
2097 (popup-menu menu prefix))
2098 (delete-overlay o))))
2100 (defun svn-status-mode ()
2101 "Major mode used by psvn.el to display the output of \"svn status\".
2103 The Output has the following format:
2104 FPH BASE CMTD Author em File
2108 BASE = local base revision
2109 CMTD = last committed revision
2110 Author = author of change
2111 em = \"**\" or \"(Update Available)\" [see `svn-status-short-mod-flag-p']
2112 if file can be updated
2113 File = path/filename
2115 The following keys are defined:
2116 \\{svn-status-mode-map}"
2118 (kill-all-local-variables)
2120 (use-local-map svn-status-mode-map)
2121 (easy-menu-add svn-status-mode-menu)
2123 (setq major-mode 'svn-status-mode)
2124 (setq mode-name "svn-status")
2125 (setq mode-line-process 'svn-status-mode-line-process)
2126 (run-hooks 'svn-status-mode-hook)
2127 (let ((view-read-only nil))
2128 (toggle-read-only 1)))
2130 (defun svn-status-update-mode-line ()
2131 (setq svn-status-mode-line-process
2132 (concat svn-status-mode-line-process-edit-flag svn-status-mode-line-process-status))
2133 (force-mode-line-update))
2135 (defun svn-status-bury-buffer (arg)
2136 "Bury the buffers used by psvn.el
2138 `svn-status-buffer-name'
2139 `svn-process-buffer-name'
2140 `svn-log-edit-buffer-name'
2144 When called with a prefix argument, ARG, switch back to the window configuration that was
2145 in use before `svn-status' was called."
2148 (when svn-status-initial-window-configuration
2149 (set-window-configuration svn-status-initial-window-configuration)))
2151 (let ((bl `(,svn-log-edit-buffer-name "*svn-property-edit*" "*svn-log*" "*svn-info*" ,svn-process-buffer-name)))
2153 (when (get-buffer (car bl))
2154 (bury-buffer (car bl)))
2156 (when (string= (buffer-name) svn-status-buffer-name)
2159 (defun svn-status-save-some-buffers (&optional tree)
2160 "Save all buffers visiting a file in TREE.
2161 If TREE is not given, try `svn-status-base-dir' as TREE."
2163 ;; (message "svn-status-save-some-buffers: tree1: %s" tree)
2165 (tree (or (svn-status-base-dir)
2167 ;; (message "svn-status-save-some-buffers: tree2: %s" tree)
2169 (error "Not in a svn project tree"))
2170 (dolist (buffer (buffer-list))
2171 (with-current-buffer buffer
2172 (when (buffer-modified-p)
2173 (let ((file (buffer-file-name)))
2175 (let ((root (svn-status-base-dir (file-name-directory file))))
2176 ;; (message "svn-status-save-some-buffers: file: %s, root: %s" file root)
2179 ;; buffer is modified and in the tree TREE.
2180 (or (y-or-n-p (concat "Save buffer " (buffer-name) "? "))
2182 (save-buffer))))))))
2185 (defun svn-status-find-files ()
2186 "Open selected file(s) for editing.
2187 See `svn-status-marked-files' for what counts as selected."
2189 (let ((fnames (mapcar 'svn-status-line-info->full-path (svn-status-marked-files))))
2190 (mapc 'find-file fnames)))
2193 (defun svn-status-find-file-other-window ()
2194 "Open the file in the other window for editing."
2196 (svn-status-ensure-cursor-on-file)
2197 (find-file-other-window (svn-status-line-info->filename
2198 (svn-status-get-line-information))))
2200 (defun svn-status-find-file-other-window-noselect ()
2201 "Open the file in the other window for editing, but don't select it."
2203 (svn-status-ensure-cursor-on-file)
2205 (find-file-noselect (svn-status-line-info->filename
2206 (svn-status-get-line-information)))))
2208 (defun svn-status-view-file-other-window ()
2209 "Open the file in the other window for viewing."
2211 (svn-status-ensure-cursor-on-file)
2212 (view-file-other-window (svn-status-line-info->filename
2213 (svn-status-get-line-information))))
2215 (defun svn-status-find-file-or-examine-directory ()
2216 "If point is on a directory, run `svn-status' on that directory.
2217 Otherwise run `find-file'."
2219 (svn-status-ensure-cursor-on-file)
2220 (let ((line-info (svn-status-get-line-information)))
2221 (if (svn-status-line-info->directory-p line-info)
2222 (svn-status (svn-status-line-info->full-path line-info))
2223 (find-file (svn-status-line-info->filename line-info)))))
2225 (defun svn-status-examine-parent ()
2226 "Run `svn-status' on the parent of the current directory."
2228 (svn-status (expand-file-name "../")))
2230 (defun svn-status-mouse-find-file-or-examine-directory (event)
2231 "Move point to where EVENT occurred, and do `svn-status-find-file-or-examine-directory'
2232 EVENT could be \"mouse clicked\" or similar."
2234 (mouse-set-point event)
2235 (svn-status-find-file-or-examine-directory))
2237 (defun svn-status-line-info->ui-status (line-info)
2238 "Return the ui-status structure of LINE-INFO.
2239 See `svn-status-make-ui-status' for information about the ui-status."
2242 (defun svn-status-line-info->has-usermark (line-info) (nth 0 (nth 0 line-info)))
2243 (defun svn-status-line-info->user-elide (line-info) (nth 1 (nth 0 line-info)))
2245 (defun svn-status-line-info->filemark (line-info) (nth 1 line-info))
2246 (defun svn-status-line-info->propmark (line-info) (nth 2 line-info))
2247 (defun svn-status-line-info->filename (line-info) (nth 3 line-info))
2248 (defun svn-status-line-info->filename-nondirectory (line-info)
2249 (file-name-nondirectory (svn-status-line-info->filename line-info)))
2250 (defun svn-status-line-info->localrev (line-info)
2251 (if (>= (nth 4 line-info) 0)
2254 (defun svn-status-line-info->lastchangerev (line-info)
2255 "Return the last revision in which LINE-INFO was modified."
2256 (let ((l (nth 5 line-info)))
2257 (if (and l (>= l 0))
2260 (defun svn-status-line-info->author (line-info)
2261 "Return the last author that changed the item that is represented in LINE-INFO."
2263 (defun svn-status-line-info->update-available (line-info)
2264 "Return whether LINE-INFO is out of date.
2265 In other words, whether there is a newer version available in the
2266 repository than the working copy."
2268 (defun svn-status-line-info->locked (line-info)
2269 "Return whether LINE-INFO represents a locked file.
2270 This is column three of the `svn status' output.
2271 The result will be nil or \"L\".
2272 \(A file becomes locked when an operation is interupted; run \\[svn-status-cleanup]'
2275 (defun svn-status-line-info->historymark (line-info)
2276 "Mark from column four of output from `svn status'.
2277 This will be nil unless the file is scheduled for addition with
2278 history, when it will be \"+\"."
2280 (defun svn-status-line-info->switched (line-info)
2281 "Return whether LINE-INFO is switched relative to its parent.
2282 This is column five of the output from `svn status'.
2283 The result will be nil or \"S\"."
2285 (defun svn-status-line-info->repo-locked (line-info)
2286 "Return whether LINE-INFO contains some locking information.
2287 This is column six of the output from `svn status'.
2288 The result will be \"K\", \"O\", \"T\", \"B\" or nil."
2290 (defun svn-status-line-info->psvn-extra-info (line-info)
2291 "Return a list of extra information for psvn associated with LINE-INFO.
2292 This list holds currently only one element:
2293 * The action after a commit or update."
2296 (defun svn-status-line-info->is-visiblep (line-info)
2297 "Return whether the line is visible or not"
2298 (or (not (or (svn-status-line-info->hide-because-unknown line-info)
2299 (svn-status-line-info->hide-because-unmodified line-info)
2300 (svn-status-line-info->hide-because-custom-hide-function line-info)
2301 (svn-status-line-info->hide-because-user-elide line-info)))
2302 (svn-status-line-info->update-available line-info) ;; show the line, if an update is available
2303 (svn-status-line-info->psvn-extra-info line-info) ;; show the line, if there is some extra info displayed on this line
2306 (defun svn-status-line-info->hide-because-unknown (line-info)
2307 (and svn-status-hide-unknown
2308 (eq (svn-status-line-info->filemark line-info) ??)))
2310 (defun svn-status-line-info->hide-because-custom-hide-function (line-info)
2311 (and svn-status-custom-hide-function
2312 (apply svn-status-custom-hide-function (list line-info))))
2314 (defun svn-status-line-info->hide-because-unmodified (line-info)
2315 ;;(message " %S %S %S %S - %s" svn-status-hide-unmodified (svn-status-line-info->propmark line-info) ?_
2316 ;; (svn-status-line-info->filemark line-info) (svn-status-line-info->filename line-info))
2317 (and svn-status-hide-unmodified
2318 (and (or (eq (svn-status-line-info->filemark line-info) ?_)
2319 (eq (svn-status-line-info->filemark line-info) ? ))
2320 (or (eq (svn-status-line-info->propmark line-info) ?_)
2321 (eq (svn-status-line-info->propmark line-info) ? )
2322 (eq (svn-status-line-info->propmark line-info) nil)))))
2324 (defun svn-status-line-info->hide-because-user-elide (line-info)
2325 (eq (svn-status-line-info->user-elide line-info) t))
2327 (defun svn-status-line-info->show-user-elide-continuation (line-info)
2328 (eq (svn-status-line-info->user-elide line-info) 'directory))
2330 ;; modify the line-info
2331 (defun svn-status-line-info->set-filemark (line-info value)
2332 (setcar (nthcdr 1 line-info) value))
2334 (defun svn-status-line-info->set-propmark (line-info value)
2335 (setcar (nthcdr 2 line-info) value))
2337 (defun svn-status-line-info->set-localrev (line-info value)
2338 (setcar (nthcdr 4 line-info) value))
2340 (defun svn-status-line-info->set-author (line-info value)
2341 (setcar (nthcdr 6 line-info) value))
2343 (defun svn-status-line-info->set-lastchangerev (line-info value)
2344 (setcar (nthcdr 5 line-info) value))
2346 (defun svn-status-line-info->set-repo-locked (line-info value)
2347 (setcar (nthcdr 11 line-info) value))
2349 (defun svn-status-line-info->set-psvn-extra-info (line-info value)
2350 (setcar (nthcdr 12 line-info) value))
2352 (defun svn-status-copy-current-line-info (arg)
2353 "Copy the current file name at point, using `svn-status-copy-filename-as-kill'.
2354 If no file is at point, copy everything starting from ':' to the end of line."
2356 (if (svn-status-get-line-information)
2357 (svn-status-copy-filename-as-kill arg)
2359 (goto-char (svn-point-at-bol))
2360 (when (looking-at ".+?: *\\(.+\\)$")
2361 (kill-new (svn-match-string-no-properties 1))
2362 (message "Copied: %s" (svn-match-string-no-properties 1))))))
2364 (defun svn-status-copy-filename-as-kill (arg)
2365 "Copy the actual file name to the kill-ring.
2366 When called with the prefix argument 0, use the full path name."
2368 (let ((str (if (eq arg 0)
2369 (svn-status-line-info->full-path (svn-status-get-line-information))
2370 (svn-status-line-info->filename (svn-status-get-line-information)))))
2372 (message "Copied %s" str)))
2374 (defun svn-status-get-child-directories (&optional dir)
2375 "Return a list of subdirectories for DIR"
2377 (let ((this-dir (concat (expand-file-name (or dir (svn-status-line-info->filename (svn-status-get-line-information)))) "/"))
2380 ;;(message "this-dir %S" this-dir)
2381 (dolist (line-info svn-status-info)
2382 (when (svn-status-line-info->directory-p line-info)
2383 (setq test-dir (svn-status-line-info->full-path line-info))
2384 (when (string= (file-name-directory test-dir) this-dir)
2385 (add-to-list 'sub-dir-list (file-relative-name (svn-status-line-info->full-path line-info)) t))))
2388 (defun svn-status-toggle-elide (arg)
2389 "Toggle eliding of the current file or directory.
2390 When called with a prefix argument, toggle the hiding of all subdirectories for the current directory."
2393 (let ((cur-line (svn-status-line-info->filename (svn-status-get-line-information))))
2394 (when (svn-status-line-info->user-elide (svn-status-get-line-information))
2395 (svn-status-toggle-elide nil))
2396 (dolist (dir-name (svn-status-get-child-directories))
2397 (svn-status-goto-file-name dir-name)
2398 (svn-status-toggle-elide nil))
2399 (svn-status-goto-file-name cur-line))
2400 (let ((st-info svn-status-info)
2402 (test (svn-status-line-info->filename (svn-status-get-line-information)))
2407 (if (member test svn-status-elided-list)
2408 (setq svn-status-elided-list (delete test svn-status-elided-list))
2409 (add-to-list 'svn-status-elided-list test))
2410 (when (string= test ".")
2412 (setq len-test (length test))
2414 (setq fname (svn-status-line-info->filename (car st-info)))
2415 (setq len-fname (length fname))
2416 (when (and (>= len-fname len-test)
2417 (string= (substring fname 0 len-test) test))
2418 (setq elide-mark new-elide-mark)
2419 (when (or (string= fname ".")
2420 (and (= len-fname len-test) (svn-status-line-info->directory-p (car st-info))))
2421 (message "Elided directory %s and all its files." fname)
2422 (setq new-elide-mark (not (svn-status-line-info->user-elide (car st-info))))
2423 (setq elide-mark (if new-elide-mark 'directory nil)))
2424 ;;(message "elide-mark: %S member: %S" elide-mark (member fname svn-status-elided-list))
2425 (when (and (member fname svn-status-elided-list) (not elide-mark))
2426 (setq svn-status-elided-list (delete fname svn-status-elided-list)))
2427 (setcar (nthcdr 1 (svn-status-line-info->ui-status (car st-info))) elide-mark))
2428 (setq st-info (cdr st-info))))
2429 ;;(message "svn-status-elided-list: %S" svn-status-elided-list)
2430 (svn-status-update-buffer)))
2432 (defun svn-status-apply-elide-list ()
2433 "Elide files/directories according to `svn-status-elided-list'."
2435 (let ((st-info svn-status-info)
2443 (setq fname (svn-status-line-info->filename (car st-info)))
2444 (setq len-fname (length fname))
2445 (setq elided-list svn-status-elided-list)
2446 (setq elide-mark nil)
2448 (setq test (car elided-list))
2449 (when (string= test ".")
2451 (setq len-test (length test))
2452 (when (and (>= len-fname len-test)
2453 (string= (substring fname 0 len-test) test))
2455 (when (or (string= fname ".")
2456 (and (= len-fname len-test) (svn-status-line-info->directory-p (car st-info))))
2457 (setq elide-mark 'directory)))
2458 (setq elided-list (cdr elided-list)))
2459 ;;(message "fname: %s elide-mark: %S" fname elide-mark)
2460 (setcar (nthcdr 1 (svn-status-line-info->ui-status (car st-info))) elide-mark)
2461 (setq st-info (cdr st-info))))
2462 (svn-status-update-buffer))
2464 (defun svn-status-update-with-command-list (cmd-list)
2466 (set-buffer svn-status-buffer-name)
2470 (fname (svn-status-line-info->filename (svn-status-get-line-information)))
2472 (column (current-column)))
2473 (setq cmd-list (sort cmd-list '(lambda (item1 item2) (string-lessp (car item1) (car item2)))))
2475 (unless st-info (setq st-info svn-status-info))
2476 ;;(message "%S" (caar cmd-list))
2478 (while (and (not found) st-info)
2479 (setq found (string= (caar cmd-list) (svn-status-line-info->filename (car st-info))))
2480 ;;(message "found: %S" found)
2481 (unless found (setq st-info (cdr st-info))))
2483 (svn-status-message 3 "psvn: continue to search for %s" (caar cmd-list))
2484 (setq st-info svn-status-info)
2485 (while (and (not found) st-info)
2486 (setq found (string= (caar cmd-list) (svn-status-line-info->filename (car st-info))))
2487 (unless found (setq st-info (cdr st-info)))))
2489 ;;update the info line
2491 (setq action (cadar cmd-list))
2492 ;;(message "found %s, action: %S" (caar cmd-list) action)
2493 (svn-status-annotate-status-buffer-entry action (car st-info)))
2494 (svn-status-message 3 "psvn: did not find %s" (caar cmd-list)))
2495 (setq cmd-list (cdr cmd-list)))
2498 (goto-char fname-pos)
2499 (svn-status-goto-file-name fname)
2500 (goto-char (+ column (svn-point-at-bol))))
2501 (goto-char (+ (next-overlay-change (point-min)) svn-status-default-column))))))
2503 (defun svn-status-annotate-status-buffer-entry (action line-info)
2505 (svn-status-goto-file-name (svn-status-line-info->filename line-info))
2506 (when (and (member action '(committed added))
2507 svn-status-commit-rev-number)
2508 (svn-status-line-info->set-localrev line-info svn-status-commit-rev-number)
2509 (svn-status-line-info->set-lastchangerev line-info svn-status-commit-rev-number))
2510 (when svn-status-last-commit-author
2511 (svn-status-line-info->set-author line-info svn-status-last-commit-author))
2512 (svn-status-line-info->set-psvn-extra-info line-info (list action))
2513 (cond ((equal action 'committed)
2514 (setq tag-string " <committed>")
2515 (when (member (svn-status-line-info->repo-locked line-info) '(?K))
2516 (svn-status-line-info->set-repo-locked line-info nil)))
2517 ((equal action 'added)
2518 (setq tag-string " <added>"))
2519 ((equal action 'deleted)
2520 (setq tag-string " <deleted>"))
2521 ((equal action 'replaced)
2522 (setq tag-string " <replaced>"))
2523 ((equal action 'updated)
2524 (setq tag-string " <updated>"))
2525 ((equal action 'updated-props)
2526 (setq tag-string " <updated-props>"))
2527 ((equal action 'conflicted)
2528 (setq tag-string " <conflicted>")
2529 (svn-status-line-info->set-filemark line-info ?C))
2530 ((equal action 'merged)
2531 (setq tag-string " <merged>"))
2532 ((equal action 'propset)
2533 ;;(setq tag-string " <propset>")
2534 (svn-status-line-info->set-propmark line-info svn-status-file-modified-after-save-flag))
2535 ((equal action 'added-wc)
2536 (svn-status-line-info->set-filemark line-info ?A)
2537 (svn-status-line-info->set-localrev line-info 0))
2538 ((equal action 'deleted-wc)
2539 (svn-status-line-info->set-filemark line-info ?D))
2541 (error "Unknown action '%s for %s" action (svn-status-line-info->filename line-info))))
2542 (when (and tag-string (not (member action '(conflicted merged))))
2543 (svn-status-line-info->set-filemark line-info ? )
2544 (svn-status-line-info->set-propmark line-info ? ))
2545 (let ((buffer-read-only nil))
2546 (delete-region (svn-point-at-bol) (svn-point-at-eol))
2547 (svn-insert-line-in-status-buffer line-info)
2550 (insert tag-string))
2555 ;; (svn-status-update-with-command-list '(("++ideas" committed) ("a.txt" committed) ("alf")))
2556 ;; (svn-status-update-with-command-list (svn-status-parse-commit-output))
2558 (defun svn-status-parse-commit-output ()
2559 "Parse the output of svn commit.
2560 Return a list that is suitable for `svn-status-update-with-command-list'"
2562 (set-buffer svn-process-buffer-name)
2567 (goto-char (point-min))
2568 (setq svn-status-commit-rev-number nil)
2569 (setq skip nil) ; set to t whenever we find a line not about a committed file
2570 (while (< (point) (point-max))
2571 (cond ((= (svn-point-at-eol) (svn-point-at-bol)) ;skip blank lines
2573 ((looking-at "Sending")
2574 (setq action 'committed))
2575 ((looking-at "Adding")
2576 (setq action 'added))
2577 ((looking-at "Deleting")
2578 (setq action 'deleted))
2579 ((looking-at "Replacing")
2580 (setq action 'replaced))
2581 ((looking-at "Transmitting file data")
2583 ((looking-at "Committed revision \\([0-9]+\\)")
2584 (setq svn-status-commit-rev-number
2585 (string-to-number (svn-match-string-no-properties 1)))
2587 (t ;; this should never be needed(?)
2588 (setq action 'unknown)))
2589 (unless skip ;found an interesting line
2591 (when svn-status-operated-on-dot
2592 ;; when the commit used . as argument, delete the trailing directory
2593 ;; from the svn output
2594 (search-forward "/" nil t))
2595 (setq file-name (buffer-substring-no-properties (point) (svn-point-at-eol)))
2596 (unless svn-status-last-commit-author
2597 (setq svn-status-last-commit-author (car (svn-status-info-for-path (expand-file-name (concat default-directory file-name))))))
2598 (setq result (cons (list file-name action)
2603 ;;(svn-status-parse-commit-output)
2604 ;;(svn-status-annotate-status-buffer-entry)
2606 (defun svn-status-parse-ar-output ()
2607 "Parse the output of svn add|remove.
2608 Return a list that is suitable for `svn-status-update-with-command-list'"
2610 (set-buffer svn-process-buffer-name)
2615 (goto-char (point-min))
2616 (while (< (point) (point-max))
2617 (cond ((= (svn-point-at-eol) (svn-point-at-bol)) ;skip blank lines
2620 (setq action 'added-wc))
2622 (setq action 'deleted-wc))
2623 (t ;; this should never be needed(?)
2624 (setq action 'unknown)))
2625 (unless skip ;found an interesting line
2627 (setq name (buffer-substring-no-properties (point) (svn-point-at-eol)))
2628 (setq result (cons (list name action)
2633 ;; (svn-status-parse-ar-output)
2634 ;; (svn-status-update-with-command-list (svn-status-parse-ar-output))
2636 (defun svn-status-parse-update-output ()
2637 "Parse the output of svn update.
2638 Return a list that is suitable for `svn-status-update-with-command-list'"
2640 (set-buffer svn-process-buffer-name)
2641 (setq svn-status-update-rev-number nil)
2646 (goto-char (point-min))
2647 (while (< (point) (point-max))
2648 (cond ((= (svn-point-at-eol) (svn-point-at-bol)) ;skip blank lines
2650 ((looking-at "Updated to revision \\([0-9]+\\)")
2651 (setq svn-status-update-rev-number
2652 (list t (string-to-number (svn-match-string-no-properties 1))))
2654 ((looking-at "At revision \\([0-9]+\\)")
2655 (setq svn-status-update-rev-number
2656 (list nil (string-to-number (svn-match-string-no-properties 1))))
2659 (setq action 'updated))
2661 (setq action 'added))
2664 ;;(setq action 'deleted)) ;;deleted files are not displayed in the svn status output.
2666 (setq action 'conflicted))
2668 (setq action 'merged))
2671 (setq action 'updated-props))
2673 (t ;; this should never be needed(?)
2674 (setq action (concat "parse-update: '"
2675 (buffer-substring-no-properties (point) (+ 2 (point))) "'"))))
2676 (unless skip ;found an interesting line
2678 (setq name (buffer-substring-no-properties (point) (svn-point-at-eol)))
2679 (setq result (cons (list name action)
2684 ;; (svn-status-parse-update-output)
2685 ;; (svn-status-update-with-command-list (svn-status-parse-update-output))
2687 (defun svn-status-parse-property-output ()
2688 "Parse the output of svn propset.
2689 Return a list that is suitable for `svn-status-update-with-command-list'"
2691 (set-buffer svn-process-buffer-name)
2693 (dolist (line (split-string (buffer-substring-no-properties (point-min) (point-max)) "\n"))
2695 (when (string-match "property '\\(.+\\)' set on '\\(.+\\)'" line)
2696 ;;(message "property %s - file %s" (match-string 1 line) (match-string 2 line))
2697 (setq result (cons (list (match-string 2 line) 'propset) result))))
2700 ;; (svn-status-parse-property-output)
2701 ;; (svn-status-update-with-command-list (svn-status-parse-property-output))
2704 (defun svn-status-line-info->symlink-p (line-info)
2705 "Return non-nil if LINE-INFO refers to a symlink, nil otherwise.
2706 The value is the name of the file to which it is linked. \(See
2709 On win32 systems this won't work, even though symlinks are supported
2710 by subversion on such systems."
2711 ;; on win32 would need to see how svn does symlinks
2712 (file-symlink-p (svn-status-line-info->filename line-info)))
2714 (defun svn-status-line-info->directory-p (line-info)
2715 "Return t if LINE-INFO refers to a directory, nil otherwise.
2716 Symbolic links to directories count as directories (see `file-directory-p')."
2717 (file-directory-p (svn-status-line-info->filename line-info)))
2719 (defun svn-status-line-info->full-path (line-info)
2720 "Return the full path of the file represented by LINE-INFO."
2722 (svn-status-line-info->filename line-info)))
2724 ;;Not convinced that this is the fastest way, but...
2725 (defun svn-status-count-/ (string)
2726 "Return number of \"/\"'s in STRING."
2729 (while (setq last (string-match "/" string (1+ last)))
2733 (defun svn-insert-line-in-status-buffer (line-info)
2734 "Format LINE-INFO and insert the result in the current buffer."
2735 (let ((usermark (if (svn-status-line-info->has-usermark line-info) "*" " "))
2736 (update-available (if (svn-status-line-info->update-available line-info)
2737 (svn-add-face (if svn-status-short-mod-flag-p
2739 " (Update Available)")
2740 'svn-status-update-available-face)
2741 (if svn-status-short-mod-flag-p " " "")))
2742 (filename ;; <indentation>file or /path/to/file
2744 (if (or svn-status-display-full-path
2745 svn-status-hide-unmodified)
2747 (let ((dir-name (file-name-as-directory
2748 (svn-status-line-info->directory-containing-line-info
2750 (if (and (<= 2 (length dir-name))
2751 (= ?. (aref dir-name 0))
2752 (= ?/ (aref dir-name 1)))
2753 (substring dir-name 2)
2755 'svn-status-directory-face)
2756 ;; showing all files, so add indentation
2757 (make-string (* 2 (svn-status-count-/
2758 (svn-status-line-info->filename line-info)))
2760 ;;symlinks get a different face
2761 (let ((target (svn-status-line-info->symlink-p line-info)))
2764 ;; name gets symlink-face, target gets file/directory face
2766 (svn-add-face (svn-status-line-info->filename-nondirectory line-info)
2767 'svn-status-symlink-face)
2769 (svn-status-choose-face-to-add
2770 ;; TODO: could use different faces for
2771 ;; unversioned targets and broken symlinks?
2772 (svn-status-line-info->directory-p line-info)
2774 'svn-status-directory-face
2775 'svn-status-filename-face))
2776 ;; else target is not a link
2777 (svn-status-choose-face-to-add
2778 (svn-status-line-info->directory-p line-info)
2779 (svn-status-line-info->filename-nondirectory line-info)
2780 'svn-status-directory-face
2781 'svn-status-filename-face)))
2783 (elide-hint (if (svn-status-line-info->show-user-elide-continuation line-info) " ..." "")))
2784 (svn-puthash (svn-status-line-info->filename line-info)
2786 svn-status-filename-to-buffer-position-cache)
2787 (insert (svn-status-maybe-add-face
2788 (svn-status-line-info->has-usermark line-info)
2790 (format svn-status-line-format
2791 (svn-status-line-info->filemark line-info)
2792 (or (svn-status-line-info->propmark line-info) ? )
2793 (or (svn-status-line-info->historymark line-info) ? )
2794 (or (svn-status-line-info->localrev line-info) "")
2795 (or (svn-status-line-info->lastchangerev line-info) "")
2796 (svn-status-line-info->author line-info))
2797 (when svn-status-short-mod-flag-p update-available)
2799 (unless svn-status-short-mod-flag-p update-available)
2800 (svn-status-maybe-add-string (svn-status-line-info->locked line-info)
2801 " [ LOCKED ]" 'svn-status-locked-face)
2802 (svn-status-maybe-add-string (svn-status-line-info->repo-locked line-info)
2803 (let ((flag (svn-status-line-info->repo-locked line-info)))
2804 (cond ((eq flag ?K) " [ REPO-LOCK-HERE ]")
2805 ((eq flag ?O) " [ REPO-LOCK-OTHER ]")
2806 ((eq flag ?T) " [ REPO-LOCK-STOLEN ]")
2807 ((eq flag ?B) " [ REPO-LOCK-BROKEN ]")
2808 (t " [ REPO-LOCK-UNKNOWN ]")))
2809 'svn-status-locked-face)
2810 (svn-status-maybe-add-string (svn-status-line-info->switched line-info)
2811 " (switched)" 'svn-status-switched-face)
2813 'svn-status-marked-face)
2816 (defun svn-status-redraw-status-buffer ()
2817 "Redraw the `svn-status-buffer-name' buffer.
2818 Additionally clear the psvn-extra-info field in all line-info lists."
2820 (dolist (line-info svn-status-info)
2821 (svn-status-line-info->set-psvn-extra-info line-info nil))
2822 (svn-status-update-buffer))
2824 (defun svn-status-update-buffer ()
2825 "Update the `svn-status-buffer-name' buffer, using `svn-status-info'.
2826 This function does not access the repository."
2828 ;(message "buffer-name: %s" (buffer-name))
2829 (unless (string= (buffer-name) svn-status-buffer-name)
2830 (set-buffer svn-status-buffer-name))
2832 (when svn-status-refresh-info
2833 (when (eq svn-status-refresh-info 'once)
2834 (setq svn-status-refresh-info nil))
2835 (svn-status-parse-info t))
2836 (let ((st-info svn-status-info)
2837 (buffer-read-only nil)
2840 (unmodified-count 0) ;how many unmodified files are hidden
2841 (unknown-count 0) ;how many unknown files are hidden
2842 (custom-hide-count 0) ;how many files are hidden via svn-status-custom-hide-function
2843 (marked-count 0) ;how many files are elided
2844 (user-elide-count 0)
2846 (fname (svn-status-line-info->filename (svn-status-get-line-information)))
2848 (window-line-pos (svn-status-window-line-position (get-buffer-window (current-buffer))))
2849 (header-line-string)
2850 (column (current-column)))
2851 (delete-region (point-min) (point-max))
2853 ;; Insert all files and directories
2855 (setq start-pos (point))
2856 (cond ((or (svn-status-line-info->has-usermark (car st-info)) first-line)
2857 ;; Show a marked file and the "." always
2858 (svn-insert-line-in-status-buffer (car st-info))
2859 (setq first-line nil))
2860 ((svn-status-line-info->update-available (car st-info))
2861 (svn-insert-line-in-status-buffer (car st-info)))
2862 ((and svn-status-custom-hide-function
2863 (apply svn-status-custom-hide-function (list (car st-info))))
2864 (setq custom-hide-count (1+ custom-hide-count)))
2865 ((svn-status-line-info->hide-because-user-elide (car st-info))
2866 (setq user-elide-count (1+ user-elide-count)))
2867 ((svn-status-line-info->hide-because-unknown (car st-info))
2868 (setq unknown-count (1+ unknown-count)))
2869 ((svn-status-line-info->hide-because-unmodified (car st-info))
2870 (setq unmodified-count (1+ unmodified-count)))
2872 (svn-insert-line-in-status-buffer (car st-info))))
2873 (when (svn-status-line-info->has-usermark (car st-info))
2874 (setq marked-count (+ marked-count 1)))
2875 (setq overlay (make-overlay start-pos (point)))
2876 (overlay-put overlay 'svn-info (car st-info))
2877 (setq st-info (cdr st-info)))
2878 ;; Insert status information at the buffer beginning
2879 (goto-char (point-min))
2880 (insert (format "svn status for directory %s%s\n"
2882 (if svn-status-head-revision (format " (status against revision: %s)"
2883 svn-status-head-revision)
2885 (when svn-status-module-name
2886 (insert (format "Project name: %s\n" svn-status-module-name)))
2887 (when svn-status-branch-list
2888 (insert (format "Branches: %s\n" svn-status-branch-list)))
2889 (when svn-status-base-info
2890 (insert (concat "Repository Root: " (svn-status-base-info->repository-root) "\n"))
2891 (insert (concat "Repository Url: " (svn-status-base-info->url) "\n")))
2892 (when svn-status-hide-unknown
2894 (format "%d Unknown file(s) are hidden - press `?' to toggle hiding\n"
2896 (when svn-status-hide-unmodified
2898 (format "%d Unmodified file(s) are hidden - press `_' to toggle hiding\n"
2900 (when (> custom-hide-count 0)
2902 (format "%d file(s) are hidden via the svn-status-custom-hide-function\n"
2903 custom-hide-count)))
2904 (when (> user-elide-count 0)
2905 (insert (format "%d file(s) elided\n" user-elide-count)))
2906 (insert (format "%d file(s) marked\n" marked-count))
2907 (setq header-line-string (concat (format svn-status-line-format
2908 70 80 72 "BASE" "CMTD" "Author")
2909 (if svn-status-short-mod-flag-p "em " "")
2911 (cond ((eq svn-status-use-header-line t)
2912 (setq header-line-format (concat " " header-line-string)))
2913 ((eq svn-status-use-header-line 'inline)
2914 (insert "\n " header-line-string "\n")))
2915 (setq svn-start-of-file-list-line-number (+ (count-lines (point-min) (point)) 1))
2918 (goto-char fname-pos)
2919 (svn-status-goto-file-name fname)
2920 (goto-char (+ column (svn-point-at-bol)))
2921 (when window-line-pos
2922 (recenter window-line-pos)))
2923 (goto-char (+ (next-overlay-change (point-min)) svn-status-default-column)))))
2925 (defun svn-status-parse-info (arg)
2926 "Parse the svn info output for the base directory.
2927 Show the repository url after this call in the `svn-status-buffer-name' buffer.
2928 When called with the prefix argument 0, reset the information to nil.
2929 This hides the repository information again.
2931 When ARG is t, don't update the svn status buffer. This is useful for
2932 non-interactive use."
2935 (setq svn-status-base-info nil)
2936 (let ((svn-process-buffer-name "*svn-info-output*"))
2937 (when (get-buffer svn-process-buffer-name)
2938 (kill-buffer svn-process-buffer-name))
2939 (svn-run nil t 'parse-info "info" ".")
2940 (svn-status-parse-info-result)))
2942 (svn-status-update-buffer)))
2944 (defun svn-status-parse-info-result ()
2945 "Parse the result from the svn info command.
2946 Put the found values in `svn-status-base-info'."
2949 (last-changed-author))
2951 (set-buffer svn-process-buffer-name)
2952 (goto-char (point-min))
2953 (let ((case-fold-search t))
2954 (search-forward "url: ")
2955 (setq url (buffer-substring-no-properties (point) (svn-point-at-eol)))
2956 (when (search-forward "repository root: " nil t)
2957 (setq repository-root (buffer-substring-no-properties (point) (svn-point-at-eol))))
2958 (when (search-forward "last changed author: " nil t)
2959 (setq last-changed-author (buffer-substring-no-properties (point) (svn-point-at-eol))))))
2960 (setq svn-status-base-info `((url ,url) (repository-root ,repository-root) (last-changed-author ,last-changed-author)))))
2962 (defun svn-status-base-info->url ()
2963 "Extract the url part from `svn-status-base-info'."
2964 (if svn-status-base-info
2965 (cadr (assoc 'url svn-status-base-info))
2968 (defun svn-status-base-info->repository-root ()
2969 "Extract the repository-root part from `svn-status-base-info'."
2970 (if svn-status-base-info
2971 (cadr (assoc 'repository-root svn-status-base-info))
2974 (defun svn-status-checkout-prefix-path ()
2975 "When only a part of the svn repository is checked out, return the file path for this checkout."
2977 (svn-status-parse-info t)
2978 (let ((root (svn-status-base-info->repository-root))
2979 (url (svn-status-base-info->url))
2981 (base-dir (svn-status-base-dir))
2982 (wc-checkout-prefix))
2983 (setq p (substring url (length root)))
2984 (setq wc-checkout-prefix (file-relative-name default-directory base-dir))
2985 (when (string= wc-checkout-prefix "./")
2986 (setq wc-checkout-prefix ""))
2987 ;; (message "svn-status-checkout-prefix-path: wc-checkout-prefix: '%s' p: '%s' base-dir: %s" wc-checkout-prefix p base-dir)
2988 (setq p (substring p 0 (- (length p) (length wc-checkout-prefix))))
2989 (when (interactive-p)
2990 (message "svn-status-checkout-prefix-path: '%s'" p))
2993 (defun svn-status-ls (path &optional synchron)
2995 (interactive "sPath for svn ls: ")
2996 (svn-run (not synchron) t 'ls "ls" path)
2998 (split-string (with-current-buffer svn-process-buffer-name
2999 (buffer-substring-no-properties (point-min) (point-max))))))
3001 (defun svn-status-ls-branches ()
3002 "Show, which branches exist for the actual working copy.
3003 Note: this command assumes the proposed standard svn repository layout."
3005 (svn-status-parse-info t)
3006 (svn-status-ls (concat (svn-status-base-info->repository-root) "/branches")))
3008 (defun svn-status-ls-tags ()
3009 "Show, which tags exist for the actual working copy.
3010 Note: this command assumes the proposed standard svn repository layout."
3012 (svn-status-parse-info t)
3013 (svn-status-ls (concat (svn-status-base-info->repository-root) "/tags")))
3015 (defun svn-status-toggle-edit-cmd-flag (&optional reset)
3016 "Allow the user to edit the parameters for the next svn command.
3017 This command toggles between
3018 * editing the next command parameters (EditCmd)
3019 * editing all all command parameters (EditCmd#)
3020 * don't edit the command parameters ()
3021 The string in parentheses is shown in the status line to show the state."
3023 (cond ((or reset (eq svn-status-edit-svn-command 'sticky))
3024 (setq svn-status-edit-svn-command nil))
3025 ((eq svn-status-edit-svn-command nil)
3026 (setq svn-status-edit-svn-command t))
3027 ((eq svn-status-edit-svn-command t)
3028 (setq svn-status-edit-svn-command 'sticky)))
3029 (cond ((eq svn-status-edit-svn-command t)
3030 (setq svn-status-mode-line-process-edit-flag " EditCmd"))
3031 ((eq svn-status-edit-svn-command 'sticky)
3032 (setq svn-status-mode-line-process-edit-flag " EditCmd#"))
3034 (setq svn-status-mode-line-process-edit-flag "")))
3035 (svn-status-update-mode-line))
3037 (defun svn-status-goto-root-or-return ()
3038 "Bounce point between the root (\".\") and the current line."
3040 (if (string= (svn-status-line-info->filename (svn-status-get-line-information)) ".")
3041 (when svn-status-root-return-info
3042 (svn-status-goto-file-name
3043 (svn-status-line-info->filename svn-status-root-return-info)))
3044 (setq svn-status-root-return-info (svn-status-get-line-information))
3045 (svn-status-goto-file-name ".")))
3047 (defun svn-status-next-line (nr-of-lines)
3048 "Go to the next line that holds a file information.
3049 When called with a prefix argument advance the given number of lines."
3052 (forward-line nr-of-lines)
3054 (not (svn-status-get-line-information)))))
3055 (when (svn-status-get-line-information)
3056 (goto-char (+ (svn-point-at-bol) svn-status-default-column))))
3058 (defun svn-status-previous-line (nr-of-lines)
3059 "Go to the previous line that holds a file information.
3060 When called with a prefix argument go back the given number of lines."
3063 (forward-line (- nr-of-lines))
3065 (not (svn-status-get-line-information)))))
3066 (when (svn-status-get-line-information)
3067 (goto-char (+ (svn-point-at-bol) svn-status-default-column))))
3069 (defun svn-status-dired-jump ()
3070 "Jump to a dired buffer, containing the file at point."
3072 (let* ((line-info (svn-status-get-line-information))
3073 (file-full-path (if line-info
3074 (svn-status-line-info->full-path line-info)
3075 default-directory)))
3076 (let ((default-directory
3077 (file-name-as-directory
3078 (expand-file-name (if line-info
3079 (svn-status-line-info->directory-containing-line-info line-info t)
3080 default-directory)))))
3081 (if (fboundp 'dired-jump-back) (dired-jump-back) (dired-jump))) ;; Xemacs uses dired-jump-back
3082 (dired-goto-file file-full-path)))
3084 (defun svn-status-possibly-negate-meaning-of-arg (arg &optional command)
3085 "Negate arg, if this-command is a member of svn-status-possibly-negate-meaning-of-arg."
3087 (setq command this-command))
3088 (if (member command svn-status-negate-meaning-of-arg-commands)
3092 (defun svn-status-update (&optional arg)
3093 "Run 'svn status -v'.
3094 When called with a prefix argument run 'svn status -vu'."
3096 (unless (interactive-p)
3098 (set-buffer svn-process-buffer-name)
3099 (setq svn-status-update-previous-process-output
3100 (buffer-substring (point-min) (point-max)))))
3101 (svn-status default-directory arg))
3103 (defun svn-status-get-line-information ()
3104 "Find out about the file under point.
3105 The result may be parsed with the various `svn-status-line-info->...' functions."
3106 (if (eq major-mode 'svn-status-mode)
3107 (let ((svn-info nil))
3108 (dolist (overlay (overlays-at (point)))
3109 (setq svn-info (or svn-info
3110 (overlay-get overlay 'svn-info))))
3112 ;; different mode, means called not from the *svn-status* buffer
3113 (if svn-status-get-line-information-for-file
3114 (svn-status-make-line-info (if (eq svn-status-get-line-information-for-file 'relative)
3115 (file-relative-name (buffer-file-name) (svn-status-base-dir))
3116 (buffer-file-name)))
3117 (svn-status-make-line-info "."))))
3120 (defun svn-status-get-file-list (use-marked-files)
3121 "Get either the selected files or the file under point.
3122 USE-MARKED-FILES decides which we do.
3123 See `svn-status-marked-files' for what counts as selected."
3124 (if use-marked-files
3125 (svn-status-marked-files)
3126 (list (svn-status-get-line-information))))
3128 (defun svn-status-get-file-list-names (use-marked-files)
3129 (mapcar 'svn-status-line-info->filename (svn-status-get-file-list use-marked-files)))
3131 (defun svn-status-get-file-information ()
3132 "Find out about the file under point.
3133 The result may be parsed with the various `svn-status-line-info->...' functions.
3134 When called from a *svn-status* buffer, do the same as `svn-status-get-line-information'.
3135 When called from a file buffer provide a structure that contains the filename."
3136 (cond ((eq major-mode 'svn-status-mode)
3137 (svn-status-get-line-information))
3139 ;; a fake strukture that contains the buffername for the current buffer
3140 (svn-status-make-line-info (buffer-file-name (current-buffer))))))
3142 (defun svn-status-select-line ()
3143 "Return information about the file under point.
3144 \(Only used for debugging\)"
3146 (let ((info (svn-status-get-line-information)))
3148 (message "%S hide-because-unknown: %S hide-because-unmodified: %S" info
3149 (svn-status-line-info->hide-because-unknown info)
3150 (svn-status-line-info->hide-because-unmodified info))
3151 (message "No file on this line"))))
3153 (defun svn-status-ensure-cursor-on-file ()
3154 "Raise an error unless point is on a valid file."
3155 (unless (svn-status-get-line-information)
3156 (error "No file on the current line")))
3158 (defun svn-status-directory-containing-point (allow-self)
3159 "Find the (full path of) directory containing the file under point.
3161 If ALLOW-SELF and the file is a directory, return that directory,
3162 otherwise return the directory containing the file under point."
3163 ;;the first `or' below is because s-s-g-l-i returns `nil' if
3164 ;;point was outside the file list, but we need
3165 ;;s-s-l-i->f to return a string to add to `default-directory'.
3166 (let ((line-info (or (svn-status-get-line-information)
3167 (svn-status-make-line-info))))
3168 (file-name-as-directory
3170 (svn-status-line-info->directory-containing-line-info line-info allow-self)))))
3172 (defun svn-status-line-info->directory-containing-line-info (line-info allow-self)
3173 "Find the directory containing for LINE-INFO.
3175 If ALLOW-SELF is t and LINE-INFO refers to a directory then return the
3176 directory itself, in all other cases find the parent directory"
3177 (if (and allow-self (svn-status-line-info->directory-p line-info))
3178 (svn-status-line-info->filename line-info)
3179 ;;The next `or' is because (file-name-directory "file") returns nil
3180 (or (file-name-directory (svn-status-line-info->filename line-info))
3183 (defun svn-status-set-user-mark (arg)
3184 "Set a user mark on the current file or directory.
3185 If the cursor is on a file this file is marked and the cursor advances to the next line.
3186 If the cursor is on a directory all files in this directory are marked.
3188 If this function is called with a prefix argument, only the current line is
3189 marked, even if it is a directory."
3191 (setq arg (svn-status-possibly-negate-meaning-of-arg arg 'svn-status-set-user-mark))
3192 (let ((info (svn-status-get-line-information)))
3195 (svn-status-apply-usermark t arg)
3196 (svn-status-next-line 1))
3197 (message "No file on this line - cannot set a mark"))))
3199 (defun svn-status-unset-user-mark (arg)
3200 "Remove a user mark on the current file or directory.
3201 If the cursor is on a file, this file is unmarked and the cursor advances to the next line.
3202 If the cursor is on a directory, all files in this directory are unmarked.
3204 If this function is called with a prefix argument, only the current line is
3205 unmarked, even if is a directory."
3207 (setq arg (svn-status-possibly-negate-meaning-of-arg arg 'svn-status-set-user-mark))
3208 (let ((info (svn-status-get-line-information)))
3211 (svn-status-apply-usermark nil arg)
3212 (svn-status-next-line 1))
3213 (message "No file on this line - cannot unset a mark"))))
3215 (defun svn-status-unset-user-mark-backwards ()
3216 "Remove a user mark from the previous file.
3217 Then move to that line."
3218 ;; This is consistent with `dired-unmark-backward' and
3219 ;; `cvs-mode-unmark-up'.
3221 (let ((info (save-excursion
3222 (svn-status-next-line -1)
3223 (svn-status-get-line-information))))
3226 (svn-status-next-line -1)
3227 (svn-status-apply-usermark nil t))
3228 (message "No file on previous line - cannot unset a mark"))))
3230 (defun svn-status-apply-usermark (set-mark only-this-line)
3231 "Do the work for the various marking/unmarking functions."
3232 (let* ((st-info svn-status-info)
3234 (line-info (svn-status-get-line-information))
3235 (file-name (svn-status-line-info->filename line-info))
3236 (sub-file-regexp (if (file-directory-p file-name)
3237 (concat "^" (regexp-quote
3238 (file-name-as-directory file-name)))
3240 (newcursorpos-fname)
3243 (current-line svn-start-of-file-list-line-number))
3245 (when (or (svn-status-line-info->is-visiblep (car st-info)) first-line)
3246 (setq current-line (1+ current-line))
3247 (setq first-line nil))
3248 (setq i-fname (svn-status-line-info->filename (car st-info)))
3249 (when (or (string= file-name i-fname)
3250 (when sub-file-regexp
3251 (string-match sub-file-regexp i-fname)))
3252 (when (svn-status-line-info->is-visiblep (car st-info))
3253 (when (or (not only-this-line) (string= file-name i-fname))
3254 (setq newcursorpos-fname i-fname)
3255 (unless (eq (car (svn-status-line-info->ui-status (car st-info))) set-mark)
3256 (setcar (svn-status-line-info->ui-status (car st-info)) set-mark)
3257 (setq mark-count (+ 1 mark-count))
3259 (let ((buffer-read-only nil))
3260 (goto-line current-line)
3261 (delete-region (svn-point-at-bol) (svn-point-at-eol))
3262 (svn-insert-line-in-status-buffer (car st-info))
3264 (message "%s %s" (if set-mark "Marked" "Unmarked") i-fname)))))
3265 (setq st-info (cdr st-info)))
3266 ;;(svn-status-update-buffer)
3267 (svn-status-goto-file-name newcursorpos-fname)
3268 (when (> mark-count 1)
3269 (message "%s %d files" (if set-mark "Marked" "Unmarked") mark-count))))
3271 (defun svn-status-apply-usermark-checked (check-function set-mark)
3272 "Mark or unmark files, whether a given function returns t.
3273 The function is called with the line information. Therefore the
3274 svn-status-line-info->* functions can be used in the check."
3275 (let ((st-info svn-status-info)
3278 (when (apply check-function (list (car st-info)))
3279 (unless (eq (svn-status-line-info->has-usermark (car st-info)) set-mark)
3280 (setq mark-count (+ 1 mark-count))
3282 (if set-mark "Marked" "Unmarked")
3283 (svn-status-line-info->filename (car st-info))))
3284 (setcar (svn-status-line-info->ui-status (car st-info)) set-mark))
3285 (setq st-info (cdr st-info)))
3286 (svn-status-update-buffer)
3287 (when (> mark-count 1)
3288 (message "%s %d files" (if set-mark "Marked" "Unmarked") mark-count))))
3290 (defun svn-status-mark-unknown (arg)
3291 "Mark all unknown files.
3292 These are the files marked with '?' in the `svn-status-buffer-name' buffer.
3293 If the function is called with a prefix arg, unmark all these files."
3295 (svn-status-apply-usermark-checked
3296 '(lambda (info) (eq (svn-status-line-info->filemark info) ??)) (not arg)))
3298 (defun svn-status-mark-added (arg)
3299 "Mark all added files.
3300 These are the files marked with 'A' in the `svn-status-buffer-name' buffer.
3301 If the function is called with a prefix ARG, unmark all these files."
3303 (svn-status-apply-usermark-checked
3304 '(lambda (info) (eq (svn-status-line-info->filemark info) ?A)) (not arg)))
3306 (defun svn-status-mark-modified (arg)
3307 "Mark all modified files.
3308 These are the files marked with 'M' in the `svn-status-buffer-name' buffer.
3309 If the function is called with a prefix ARG, unmark all these files."
3311 (svn-status-apply-usermark-checked
3312 '(lambda (info) (or (eq (svn-status-line-info->filemark info) ?M)
3313 (eq (svn-status-line-info->filemark info)
3314 svn-status-file-modified-after-save-flag)))
3317 (defun svn-status-mark-deleted (arg)
3318 "Mark all files scheduled for deletion.
3319 These are the files marked with 'D' in the `svn-status-buffer-name' buffer.
3320 If the function is called with a prefix ARG, unmark all these files."
3322 (svn-status-apply-usermark-checked
3323 '(lambda (info) (eq (svn-status-line-info->filemark info) ?D)) (not arg)))
3325 (defun svn-status-mark-changed (arg)
3326 "Mark all files that could be committed.
3328 * all modified files
3329 * all files scheduled for addition
3330 * all files scheduled for deletion
3332 The last two categories include all copied and moved files.
3333 If called with a prefix ARG, unmark all such files."
3335 (svn-status-mark-added arg)
3336 (svn-status-mark-modified arg)
3337 (svn-status-mark-deleted arg))
3339 (defun svn-status-unset-all-usermarks ()
3341 (svn-status-apply-usermark-checked '(lambda (info) t) nil))
3343 (defvar svn-status-regexp-history nil
3344 "History list of regular expressions used in svn status commands.")
3346 (defun svn-status-read-regexp (prompt)
3347 (read-from-minibuffer prompt nil nil nil 'svn-status-regexp-history))
3349 (defun svn-status-mark-filename-regexp (regexp &optional unmark)
3350 "Mark all files matching REGEXP.
3351 If the function is called with a prefix arg, unmark all these files."
3353 (list (svn-status-read-regexp (concat (if current-prefix-arg "Unmark" "Mark")
3354 " files (regexp): "))
3355 (if current-prefix-arg t nil)))
3356 (svn-status-apply-usermark-checked
3357 '(lambda (info) (string-match regexp (svn-status-line-info->filename-nondirectory info))) (not unmark)))
3359 (defun svn-status-mark-by-file-ext (ext &optional unmark)
3360 "Mark all files matching the given file extension EXT.
3361 If the function is called with a prefix arg, unmark all these files."
3363 (list (read-string (concat (if current-prefix-arg "Unmark" "Mark")
3364 " files with extensions: "))
3365 (if current-prefix-arg t nil)))
3366 (svn-status-apply-usermark-checked
3367 '(lambda (info) (let ((case-fold-search nil))
3368 (string-match (concat "\\." ext "$") (svn-status-line-info->filename-nondirectory info)))) (not unmark)))
3370 (defun svn-status-toggle-hide-unknown ()
3372 (setq svn-status-hide-unknown (not svn-status-hide-unknown))
3373 (svn-status-update-buffer))
3375 (defun svn-status-toggle-hide-unmodified ()
3377 (setq svn-status-hide-unmodified (not svn-status-hide-unmodified))
3378 (svn-status-update-buffer))
3380 (defun svn-status-get-file-name-buffer-position (name)
3381 "Find the buffer position for a file.
3382 If the file is not found, return nil."
3383 (let ((start-pos (let ((cached-pos (gethash name
3384 svn-status-filename-to-buffer-position-cache)))
3386 (goto-char (previous-overlay-change cached-pos)))
3389 ;; performance optimization: search from point to end of buffer
3390 (while (and (not found) (< (point) (point-max)))
3391 (goto-char (next-overlay-change (point)))
3392 (when (string= name (svn-status-line-info->filename
3393 (svn-status-get-line-information)))
3394 (setq start-pos (+ (point) svn-status-default-column))
3396 ;; search from buffer start to point
3397 (goto-char (point-min))
3398 (while (and (not found) (< (point) start-pos))
3399 (goto-char (next-overlay-change (point)))
3400 (when (string= name (svn-status-line-info->filename
3401 (svn-status-get-line-information)))
3402 (setq start-pos (+ (point) svn-status-default-column))
3404 (and found start-pos)))
3406 (defun svn-status-goto-file-name (name)
3407 "Move the cursor the the line that displays NAME."
3408 (let ((pos (svn-status-get-file-name-buffer-position name)))
3411 (svn-status-message 7 "Note: svn-status-goto-file-name: %s not found" name))))
3413 (defun svn-status-find-info-for-file-name (name)
3414 (let* ((st-info svn-status-info)
3417 (when (string= name (svn-status-line-info->filename (car st-info)))
3418 (setq info (car st-info))
3419 (setq st-info nil)) ; terminate loop
3420 (setq st-info (cdr st-info)))
3423 (defun svn-status-marked-files ()
3424 "Return all files marked by `svn-status-set-user-mark',
3425 or (if no files were marked) the file under point."
3426 (if (eq major-mode 'svn-status-mode)
3427 (let* ((st-info svn-status-info)
3430 (when (svn-status-line-info->has-usermark (car st-info))
3431 (setq file-list (append file-list (list (car st-info)))))
3432 (setq st-info (cdr st-info)))
3434 (if (svn-status-get-line-information)
3435 (list (svn-status-get-line-information))
3437 ;; different mode, means called not from the *svn-status* buffer
3438 (if svn-status-get-line-information-for-file
3439 (list (svn-status-make-line-info (if (eq svn-status-get-line-information-for-file 'relative)
3440 (file-relative-name (buffer-file-name) (svn-status-base-dir))
3441 (buffer-file-name))))
3442 (list (svn-status-make-line-info ".")))))
3444 (defun svn-status-marked-file-names ()
3445 (mapcar 'svn-status-line-info->filename (svn-status-marked-files)))
3447 (defun svn-status-some-files-marked-p ()
3448 "Return non-nil iff a file has been marked by `svn-status-set-user-mark'.
3449 Unlike `svn-status-marked-files', this does not select the file under point
3450 if no files have been marked."
3451 ;; `some' would be shorter but requires cl-seq at runtime.
3452 ;; (Because it accepts both lists and vectors, it is difficult to inline.)
3453 (loop for line-info in svn-status-info
3454 thereis (svn-status-line-info->has-usermark line-info)))
3456 (defun svn-status-only-dirs-or-nothing-marked-p ()
3457 "Return non-nil iff only dirs has been marked by `svn-status-set-user-mark'."
3458 ;; `some' would be shorter but requires cl-seq at runtime.
3459 ;; (Because it accepts both lists and vectors, it is difficult to inline.)
3460 (loop for line-info in svn-status-info
3461 thereis (and (not (svn-status-line-info->directory-p line-info))
3462 (svn-status-line-info->has-usermark line-info))))
3464 (defun svn-status-ui-information-hash-table ()
3465 (let ((st-info svn-status-info)
3466 (svn-status-ui-information (make-hash-table :test 'equal)))
3468 (svn-puthash (svn-status-line-info->filename (car st-info))
3469 (svn-status-line-info->ui-status (car st-info))
3470 svn-status-ui-information)
3471 (setq st-info (cdr st-info)))
3472 svn-status-ui-information))
3475 (defun svn-status-create-arg-file (file-name prefix file-info-list postfix)
3476 (with-temp-file file-name
3478 (let ((st-info file-info-list))
3480 (insert (svn-status-line-info->filename (car st-info)))
3482 (setq st-info (cdr st-info)))
3486 (defun svn-status-show-process-buffer-internal (&optional scroll-to-top)
3487 (let ((cur-buff (current-buffer)))
3488 (unless svn-status-preserve-window-configuration
3489 (when (string= (buffer-name) svn-status-buffer-name)
3490 (delete-other-windows)))
3491 (pop-to-buffer svn-process-buffer-name)
3494 (goto-char (point-min)))
3495 (pop-to-buffer cur-buff)))
3497 (defun svn-status-show-process-output (cmd &optional scroll-to-top)
3498 "Display the result of a svn command.
3499 Consider svn-status-window-alist to choose the buffer name."
3500 (let ((window-mode (cadr (assoc cmd svn-status-window-alist)))
3501 (process-default-directory))
3502 (cond ((eq window-mode nil) ;; use *svn-process* buffer
3503 (setq svn-status-last-output-buffer-name svn-process-buffer-name))
3504 ((eq window-mode t) ;; use *svn-info* buffer
3505 (setq svn-status-last-output-buffer-name "*svn-info*"))
3506 ((eq window-mode 'invisible) ;; don't display the buffer
3507 (setq svn-status-last-output-buffer-name nil))
3509 (setq svn-status-last-output-buffer-name window-mode)))
3510 (when svn-status-last-output-buffer-name
3513 (unless svn-status-preserve-window-configuration
3514 (when (string= (buffer-name) svn-status-buffer-name)
3515 (delete-other-windows)))
3516 (pop-to-buffer svn-process-buffer-name)
3517 (setq process-default-directory default-directory)
3518 (switch-to-buffer (get-buffer-create svn-status-last-output-buffer-name))
3519 (setq default-directory process-default-directory)
3520 (let ((buffer-read-only nil))
3521 (delete-region (point-min) (point-max))
3522 (insert-buffer-substring svn-process-buffer-name)
3524 (goto-char (point-min))))
3525 (when (eq window-mode t) ;; *svn-info* buffer
3528 (svn-status-show-process-buffer-internal scroll-to-top)))))
3530 (defun svn-status-svn-log-switches (arg)
3531 (cond ((eq arg 0) '())
3532 ((or (eq arg -1) (eq arg '-)) '("-q"))
3534 (t svn-status-default-log-arguments)))
3536 (defun svn-status-show-svn-log (arg)
3537 "Run `svn log' on selected files.
3538 The output is put into the *svn-log* buffer
3539 The optional prefix argument ARG determines which switches are passed to `svn log':
3540 no prefix --- use whatever is in the list `svn-status-default-log-arguments'
3541 prefix argument of -1: --- use the -q switch (quiet)
3542 prefix argument of 0 --- use no arguments
3543 other prefix arguments: --- use the -v switch (verbose)
3545 See `svn-status-marked-files' for what counts as selected."
3547 (let ((switches (svn-status-svn-log-switches arg))
3548 (svn-status-get-line-information-for-file t))
3549 ;; (message "svn-status-show-svn-log %S" arg)
3550 (svn-status-create-arg-file svn-status-temp-arg-file "" (svn-status-marked-files) "")
3551 (svn-run t t 'log "log" "--targets" svn-status-temp-arg-file switches)))
3553 (defun svn-status-version ()
3554 "Show the version numbers for psvn.el and the svn command line client.
3555 The version number of the client is cached in `svn-client-version'."
3557 (let ((window-conf (current-window-configuration))
3559 (if (or (interactive-p) (not svn-status-cached-version-string))
3561 (svn-run nil t 'version "--version")
3562 (when (interactive-p)
3563 (svn-status-show-process-output 'info t))
3564 (with-current-buffer svn-status-last-output-buffer-name
3565 (goto-char (point-min))
3566 (setq svn-client-version
3567 (when (re-search-forward "svn, version \\([0-9\.]+\\) " nil t)
3568 (mapcar 'string-to-number (split-string (match-string 1) "\\."))))
3569 (let ((buffer-read-only nil))
3570 (goto-char (point-min))
3571 (insert (format "psvn.el revision: %s\n\n" svn-psvn-revision)))
3572 (setq version-string (buffer-substring-no-properties (point-min) (point-max))))
3573 (setq svn-status-cached-version-string version-string))
3574 (setq version-string svn-status-cached-version-string)
3575 (unless (interactive-p)
3576 (set-window-configuration window-conf)
3579 (defun svn-status-info ()
3580 "Run `svn info' on all selected files.
3581 See `svn-status-marked-files' for what counts as selected."
3583 (svn-status-create-arg-file svn-status-temp-arg-file "" (svn-status-marked-files) "")
3584 (svn-run t t 'info "info" "--targets" svn-status-temp-arg-file))
3586 (defun svn-status-info-for-path (path)
3587 "Run svn info on the given PATH.
3588 Return some interesting parts of the resulting output.
3589 At the moment a list containing the last changed author is returned."
3590 (let ((svn-process-buffer-name "*svn-info-output*")
3591 (last-changed-author))
3592 (svn-run nil t 'info "info" path)
3593 (with-current-buffer svn-process-buffer-name
3594 (goto-char (point-min))
3595 (when (search-forward "last changed author: " nil t)
3596 (setq last-changed-author (buffer-substring-no-properties (point) (svn-point-at-eol)))))
3597 (svn-status-message 7 "last-changed-author for '%s': %s" path last-changed-author)
3598 (list last-changed-author)))
3600 (defun svn-status-blame (revision)
3601 "Run `svn blame' on the current file.
3602 When called with a prefix argument, ask the user for the REVISION to use.
3603 When called from a file buffer, go to the current line in the resulting blame output."
3605 (when current-prefix-arg
3606 (setq revision (svn-status-read-revision-string "Blame for version: " "BASE")))
3607 (unless revision (setq revision "BASE"))
3608 (setq svn-status-blame-file-name (svn-status-line-info->filename (svn-status-get-file-information)))
3609 (svn-run t t 'blame "blame" svn-status-default-blame-arguments "-r" revision svn-status-blame-file-name))
3611 (defun svn-status-show-svn-diff (arg)
3612 "Run `svn diff' on the current file.
3613 If the current file is a directory, compare it recursively.
3614 If there is a newer revision in the repository, the diff is done against HEAD,
3615 otherwise compare the working copy with BASE.
3616 If ARG then prompt for revision to diff against (unless arg is '-)
3617 When called with a negative prefix argument, do a non recursive diff."
3619 (let ((non-recursive (or (and (numberp arg) (< arg 0)) (eq arg '-)))
3620 (revision (if (and (not (eq arg '-)) arg) :ask :auto)))
3621 (svn-status-ensure-cursor-on-file)
3622 (svn-status-show-svn-diff-internal (list (svn-status-get-line-information)) (not non-recursive)
3625 (defun svn-file-show-svn-diff (arg)
3626 "Run `svn diff' on the current file.
3627 If there is a newer revision in the repository, the diff is done against HEAD,
3628 otherwise compare the working copy with BASE.
3629 If ARG then prompt for revision to diff against."
3631 (svn-status-show-svn-diff-internal (list (svn-status-make-line-info buffer-file-name)) nil
3632 (if arg :ask :auto)))
3634 (defun svn-status-show-svn-diff-for-marked-files (arg)
3635 "Run `svn diff' on all selected files.
3636 If some files have been marked, compare those non-recursively;
3637 this is because marking a directory with \\[svn-status-set-user-mark]
3638 normally marks all of its files as well.
3639 If no files have been marked, compare recursively the file at point.
3640 If ARG then prompt for revision to diff against, else compare working copy with BASE."
3642 (svn-status-show-svn-diff-internal (svn-status-marked-files)
3643 (not (svn-status-some-files-marked-p))
3644 (if arg :ask "BASE")))
3646 (defun svn-status-diff-show-changeset (rev &optional user-confirmation)
3647 "Show the changeset for a given log entry.
3648 When called with a prefix argument, ask the user for the revision."
3649 (let* ((upper-rev rev)
3650 (lower-rev (number-to-string (- (string-to-number upper-rev) 1)))
3651 (rev-arg (concat lower-rev ":" upper-rev)))
3652 (when user-confirmation
3653 (setq rev-arg (read-string "Revision for changeset: " rev-arg)))
3654 (svn-run nil t 'diff "diff" (concat "-r" rev-arg))
3655 (svn-status-activate-diff-mode)))
3657 (defun svn-status-show-svn-diff-internal (line-infos recursive revision)
3658 ;; REVISION must be one of:
3659 ;; - a string: whatever the -r option allows.
3660 ;; - `:ask': asks the user to specify the revision, which then becomes
3661 ;; saved in `minibuffer-history' rather than in `command-history'.
3662 ;; - `:auto': use "HEAD" if an update is known to exist, "BASE" otherwise.
3663 ;; In the future, `nil' might mean omit the -r option entirely;
3664 ;; but that currently seems to imply "BASE", so we just use that.
3665 (when (eq revision :ask)
3666 (setq revision (svn-status-read-revision-string
3667 "Diff with files for version: " "PREV")))
3669 (setq svn-status-last-diff-options (list line-infos recursive revision))
3673 (dolist (line-info line-infos)
3674 (svn-run nil clear-buf 'diff "diff" svn-status-default-diff-arguments
3675 "-r" (if (eq revision :auto)
3676 (if (svn-status-line-info->update-available line-info)
3679 (unless recursive "--non-recursive")
3680 (svn-status-line-info->filename line-info))
3681 (setq clear-buf nil)
3683 ;; "svn diff --non-recursive" skips only subdirectories, not files.
3684 ;; But a non-recursive diff via psvn should skip files too, because
3685 ;; the user would have marked them if he wanted them to be compared.
3686 ;; So we'll look for the "Index: foo" line that marks the first file
3687 ;; in the diff output, and delete it and everything that follows.
3688 ;; This is made more complicated by the fact that `svn-status-activate-diff-mode'
3689 ;; expects the output to be left in the *svn-process* buffer.
3691 ;; Check `directory-p' relative to the `default-directory' of the
3692 ;; "*svn-status*" buffer, not that of the svn-process-buffer-name buffer.
3693 (let ((directory-p (svn-status-line-info->directory-p line-info)))
3694 (with-current-buffer svn-process-buffer-name
3696 (goto-char (or beginning (point-min)))
3697 (when (re-search-forward "^Index: " nil t)
3698 (delete-region (match-beginning 0) (point-max))))
3699 (goto-char (setq beginning (point-max))))))))
3700 (svn-status-activate-diff-mode))
3702 (defun svn-status-diff-save-current-defun-as-kill ()
3703 "Copy the function name for the change at point to the kill-ring.
3704 That function uses `add-log-current-defun'"
3706 (let ((func-name (add-log-current-defun)))
3709 (kill-new func-name)
3710 (message "Copied %S" func-name))
3711 (message "No current defun detected."))))
3713 (defun svn-status-diff-pop-to-commit-buffer ()
3714 "Temporary switch to the `svn-status-buffer-name' buffer and start a commit from there."
3716 (let ((window-conf (current-window-configuration)))
3717 (svn-status-switch-to-status-buffer)
3719 (set-window-configuration window-conf)
3720 (setq svn-status-pre-commit-window-configuration window-conf)
3721 (pop-to-buffer svn-log-edit-buffer-name)))
3723 (defun svn-status-activate-diff-mode ()
3724 "Show the `svn-process-buffer-name' buffer, using the diff-mode."
3725 (svn-status-show-process-output 'diff t)
3726 (let ((working-directory default-directory))
3728 (set-buffer svn-status-last-output-buffer-name)
3729 (setq default-directory working-directory)
3730 (svn-status-diff-mode)
3731 (setq buffer-read-only t))))
3733 (define-derived-mode svn-status-diff-mode fundamental-mode "svn-diff"
3734 "Major mode to display svn diffs. Derives from `diff-mode'.
3737 \\{svn-status-diff-mode-map}
3739 (let ((diff-mode-shared-map (copy-keymap svn-status-diff-mode-map))
3740 major-mode mode-name)
3742 (set (make-local-variable 'revert-buffer-function) 'svn-status-diff-update)))
3744 (defun svn-status-diff-update (arg noconfirm)
3745 "Rerun the last svn diff command and update the *svn-diff* buffer."
3747 (svn-status-save-some-buffers)
3748 (save-window-excursion
3749 (apply 'svn-status-show-svn-diff-internal svn-status-last-diff-options)))
3751 (defun svn-status-show-process-buffer ()
3752 "Show the content of the `svn-process-buffer-name' buffer"
3754 (svn-status-show-process-output nil))
3756 (defun svn-status-pop-to-partner-buffer ()
3757 "Pop to the `svn-status-partner-buffer' if that variable is set."
3759 (when svn-status-partner-buffer
3760 (let ((cur-buf (current-buffer)))
3761 (pop-to-buffer svn-status-partner-buffer)
3762 (setq svn-status-partner-buffer cur-buf))))
3764 (defun svn-status-pop-to-new-partner-buffer (buffer)
3765 "Call `pop-to-buffer' and register the current buffer as partner buffer for BUFFER."
3766 (let ((cur-buf (current-buffer)))
3767 (pop-to-buffer buffer)
3768 (setq svn-status-partner-buffer cur-buf)))
3770 (defun svn-status-add-file-recursively (arg)
3771 "Run `svn add' on all selected files.
3772 When a directory is added, add files recursively.
3773 See `svn-status-marked-files' for what counts as selected.
3774 When this function is called with a prefix argument, use the actual file instead."
3776 (message "adding: %S" (svn-status-get-file-list-names (not arg)))
3777 (svn-status-create-arg-file svn-status-temp-arg-file "" (svn-status-get-file-list (not arg)) "")
3778 (svn-run t t 'add "add" "--targets" svn-status-temp-arg-file))
3780 (defun svn-status-add-file (arg)
3781 "Run `svn add' on all selected files.
3782 When a directory is added, don't add the files of the directory
3783 (svn add --non-recursive <file-list> is called).
3784 See `svn-status-marked-files' for what counts as selected.
3785 When this function is called with a prefix argument, use the actual file instead."
3787 (message "adding: %S" (svn-status-get-file-list-names (not arg)))
3788 (svn-status-create-arg-file svn-status-temp-arg-file "" (svn-status-get-file-list (not arg)) "")
3789 (svn-run t t 'add "add" "--non-recursive" "--targets" svn-status-temp-arg-file))
3791 (defun svn-status-lock (arg)
3792 "Run `svn lock' on all selected files.
3793 See `svn-status-marked-files' for what counts as selected."
3795 (message "locking: %S" (svn-status-get-file-list-names t))
3796 (svn-status-create-arg-file svn-status-temp-arg-file "" (svn-status-get-file-list t) "")
3797 (svn-run t t 'lock "lock" "--targets" svn-status-temp-arg-file))
3799 (defun svn-status-unlock (arg)
3800 "Run `svn unlock' on all selected files.
3801 See `svn-status-marked-files' for what counts as selected."
3803 (message "unlocking: %S" (svn-status-get-file-list-names t))
3804 (svn-status-create-arg-file svn-status-temp-arg-file "" (svn-status-get-file-list t) "")
3805 (svn-run t t 'unlock "unlock" "--targets" svn-status-temp-arg-file))
3807 (defun svn-status-make-directory (dir)
3808 "Run `svn mkdir DIR'."
3809 ;; TODO: Allow entering a URI interactively.
3810 ;; Currently, `read-file-name' corrupts it.
3811 (interactive (list (read-file-name "Make directory: "
3812 (svn-status-directory-containing-point t))))
3813 (unless (string-match "^[^:/]+://" dir) ; Is it a URI?
3814 (setq dir (file-relative-name dir)))
3815 (svn-run t t 'mkdir "mkdir" "--" dir))
3817 (defun svn-status-mv ()
3818 "Prompt for a destination, and `svn mv' selected files there.
3819 See `svn-status-marked-files' for what counts as `selected'.
3821 If one file was selected then the destination DEST should be a
3822 filename to rename the selected file to, or a directory to move the
3823 file into; if multiple files were selected then DEST should be a
3824 directory to move the selected files into.
3826 The default DEST is the directory containing point.
3828 BUG: If we've marked some directory containging a file as well as the
3829 file itself, then we should just mv the directory, but this implementation
3830 doesn't check for that.
3831 SOLUTION: for each dir, umark all its contents (but not the dir
3832 itself) before running mv."
3834 (svn-status-mv-cp "mv" "Rename" "Move" "mv"))
3836 (defun svn-status-cp ()
3837 "See `svn-status-mv'"
3839 (svn-status-mv-cp "cp" "Copy" "Copy" "cp"))
3841 (defun svn-status-mv-cp (command singleprompt manyprompt fallback)
3842 "Run svn COMMAND on marked files, prompting for destination
3844 This function acts on `svn-status-marked-files': at the prompt the
3845 user can enter a new file name, or an existing directory: this is used as the argument for svn COMMAND.
3846 COMMAND --- string saying what to do: \"mv\" or \"cp\"
3847 SINGLEPROMPT --- string at start of prompt when one file marked
3848 MANYPROMPT --- string at start of prompt when multiple files marked
3849 FALLBACK --- If any marked file is unversioned, use this instead of 'svn COMMAND'"
3850 (let* ((marked-files (svn-status-marked-files))
3851 (num-of-files (length marked-files))
3853 (if (= 1 num-of-files)
3854 ;; one file to act on: new name, or directory to hold results
3855 (setq dest (read-file-name
3856 (format "%s %s to: " singleprompt
3857 (svn-status-line-info->filename (car marked-files)))
3858 (svn-status-directory-containing-point t)
3859 (svn-status-line-info->full-path (car marked-files))))
3860 ;;TODO: (when file-exists-p but-no-dir-p dest (error "%s already exists" dest))
3861 ;;multiple files selected, so prompt for existing directory to mv them into.
3862 (setq dest (svn-read-directory-name
3863 (format "%s %d files to directory: " manyprompt num-of-files)
3864 (svn-status-directory-containing-point t) nil t))
3865 (unless (file-directory-p dest)
3866 (error "%s is not a directory" dest)))
3867 (when (string= dest "")
3868 (error "No destination entered"))
3869 (unless (string-match "^[^:/]+://" dest) ; Is it a URI?
3870 (setq dest (file-relative-name dest)))
3872 ;;do the move: svn mv only lets us move things once at a time, so
3873 ;;we need to run svn mv once for each file (hence second arg to
3876 ;;TODO: before doing any moving, For every marked directory,
3877 ;;ensure none of its contents are also marked, since we dont want
3878 ;;to move both file *and* its parent...
3879 ;; what about elided files? what if user marks a dir+contents, then presses `_' ?
3881 ;; (dolist (original marked-files)
3882 ;; (when (svn-status-line-info->directory-p original)
3883 ;; ;; run svn-status-goto-file-name to move point to line of file
3884 ;; ;; run svn-status-unset-user-mark to unmark dir+all contents
3885 ;; ;; run svn-status-set-user-mark to remark dir
3886 ;; ;; maybe check for local mods here, and unmark if user does't say --force?
3888 (dolist (original marked-files)
3889 (let ((original-name (svn-status-line-info->filename original))
3890 (original-filemarks (svn-status-line-info->filemark original))
3891 (original-propmarks (svn-status-line-info->propmark original))
3894 ((or (eq original-filemarks ?M) ;local mods: maybe do `svn mv --force'
3895 (eq original-propmarks ?M)) ;local prop mods: maybe do `svn mv --force'
3897 (format "%s has local modifications; use `--force' to really move it? " original-name))
3899 (svn-status-run-mv-cp command original-name dest t)
3901 (message "Not acting on %s" original-name)))
3902 ((eq original-filemarks ??) ;original is unversioned: use fallback
3903 (if (yes-or-no-p (format "%s is unversioned. Use `%s -i -- %s %s'? "
3904 original-name fallback original-name dest))
3905 ;; TODO: consider svn-call-process-function here also...
3906 (progn (call-process fallback nil (get-buffer-create svn-process-buffer-name) nil
3907 "-i" "--" original-name dest)
3909 ;;new files created by fallback are not in *svn-status* now,
3910 ;;TODO: so call (svn-status-update) here?
3911 (message "Not acting on %s" original-name)))
3913 ((eq original-filemarks ?A) ;;`A' (`svn add'ed, but not committed)
3914 (message "Not acting on %s (commit it first)" original-name))
3916 ((eq original-filemarks ? ) ;original is unmodified: can proceed
3917 (svn-status-run-mv-cp command original-name dest)
3920 ;;file has some other mark (eg conflicted)
3923 (format "The status of %s looks scary. Risk moving it anyway? "
3926 (svn-status-run-mv-cp command original-name dest)
3928 (message "Not acting on %s" original-name))))
3930 (message "psvn: did '%s' from %s to %s" command original-name dest)
3931 ;; Silently rename the visited file of any buffer visiting this file.
3932 (when (get-file-buffer original-name)
3933 (with-current-buffer (get-file-buffer original-name)
3934 (set-visited-file-name dest nil t))))))
3935 (svn-status-update)))
3937 (defun svn-status-run-mv-cp (command original destination &optional force)
3938 "Actually run svn mv or svn cp.
3939 This is just to prevent duplication in `svn-status-prompt-and-act-on-files'"
3941 (svn-run nil t (intern command) command "--force" "--" original destination)
3942 (svn-run nil t (intern command) command "--" original destination))
3943 ;;;TODO: use something like the following instead of calling svn-status-update
3944 ;;; at the end of svn-status-mv-cp.
3945 ;; (let ((output (svn-status-parse-ar-output))
3947 ;; buffer-read-only) ; otherwise insert-line-in-status-buffer fails
3948 ;; (dolist (new-file output)
3949 ;; (when (eq (cadr new-file) 'added-wc)
3950 ;; ;; files with 'wc-added action do not exist in *svn-status*
3951 ;; ;; buffer yet, so give each of them their own line-info
3952 ;; ;; TODO: need to insert the new line-info in a sensible place, ie in the correct directory! [svn-status-filename-to-buffer-position-cache might help?]
3954 ;; (svn-insert-line-in-status-buffer
3955 ;; (svn-status-make-line-info (car new-file)))))
3956 ;; (svn-status-update-with-command-list output))
3959 (defun svn-status-revert ()
3960 "Run `svn revert' on all selected files.
3961 See `svn-status-marked-files' for what counts as selected."
3963 (let* ((marked-files (svn-status-marked-files))
3964 (num-of-files (length marked-files)))
3966 (if (= 1 num-of-files)
3967 (format "Revert %s? " (svn-status-line-info->filename (car marked-files)))
3968 (format "Revert %d files? " num-of-files)))
3969 (message "reverting: %S" (svn-status-marked-file-names))
3970 (svn-status-create-arg-file svn-status-temp-arg-file "" (svn-status-marked-files) "")
3971 (svn-run t t 'revert "revert" "--targets" svn-status-temp-arg-file))))
3973 (defun svn-status-rm (force)
3974 "Run `svn rm' on all selected files.
3975 See `svn-status-marked-files' for what counts as selected.
3976 When called with a prefix argument add the command line switch --force.
3978 Forcing the deletion can also be used to delete files not under svn control."
3980 (let* ((marked-files (svn-status-marked-files))
3981 (num-of-files (length marked-files)))
3983 (if (= 1 num-of-files)
3984 (format "%sRemove %s? " (if force "Force " "") (svn-status-line-info->filename (car marked-files)))
3985 (format "%sRemove %d files? " (if force "Force " "") num-of-files)))
3986 (message "removing: %S" (svn-status-marked-file-names))
3987 (svn-status-create-arg-file svn-status-temp-arg-file "" (svn-status-marked-files) "")
3990 (svn-run t t 'rm "rm" "--force" "--targets" svn-status-temp-arg-file)
3991 (dolist (to-delete (svn-status-marked-files))
3992 (when (eq (svn-status-line-info->filemark to-delete) ??)
3993 (svn-status-goto-file-name (svn-status-line-info->filename to-delete))
3994 (let ((buffer-read-only nil))
3995 (delete-region (svn-point-at-bol) (+ 1 (svn-point-at-eol)))
3996 (delete to-delete svn-status-info)))))
3997 (svn-run t t 'rm "rm" "--targets" svn-status-temp-arg-file)))))
3999 (defun svn-status-update-cmd (arg)
4001 When called with a prefix argument, ask the user for the revision to update to.
4002 When called with a negative prefix argument, only update the selected files."
4004 (let* ((selective-update (or (and (numberp arg) (< arg 0)) (eq arg '-)))
4005 (rev (when arg (svn-status-read-revision-string
4006 (if selective-update
4007 (format "Selected entries: Run svn update -r ")
4008 (format "Directory: %s: Run svn update -r " default-directory))
4009 (if selective-update "HEAD" nil)))))
4010 (if selective-update
4012 (message "Running svn-update for %s" (svn-status-marked-file-names))
4013 (svn-run t t 'update "update"
4014 (when rev (list "-r" rev))
4015 (list "--non-interactive")
4016 (svn-status-marked-file-names)))
4017 (message "Running svn-update for %s" default-directory)
4018 (svn-run t t 'update "update"
4019 (when rev (list "-r" rev))
4020 (list "--non-interactive")))))
4022 (defun svn-status-commit ()
4023 "Commit selected files.
4024 If some files have been marked, commit those non-recursively;
4025 this is because marking a directory with \\[svn-status-set-user-mark]
4026 normally marks all of its files as well.
4027 If no files have been marked, commit recursively the file at point."
4029 (svn-status-save-some-buffers)
4030 (let* ((selected-files (svn-status-marked-files)))
4031 (setq svn-status-files-to-commit selected-files
4032 svn-status-recursive-commit (not (svn-status-only-dirs-or-nothing-marked-p)))
4033 (svn-log-edit-show-files-to-commit)
4034 (svn-status-pop-to-commit-buffer)
4035 (when svn-log-edit-insert-files-to-commit
4036 (svn-log-edit-insert-files-to-commit))
4037 (when svn-log-edit-show-diff-for-commit
4038 (svn-log-edit-svn-diff nil))))
4040 (defun svn-status-pop-to-commit-buffer ()
4041 "Pop to the svn commit buffer.
4042 If a saved log message exists in `svn-log-edit-file-name' insert it in the buffer."
4044 (setq svn-status-pre-commit-window-configuration (current-window-configuration))
4045 (let* ((use-existing-buffer (get-buffer svn-log-edit-buffer-name))
4046 (commit-buffer (get-buffer-create svn-log-edit-buffer-name))
4047 (dir default-directory)
4048 (log-edit-file-name))
4049 (pop-to-buffer commit-buffer)
4050 (setq default-directory dir)
4051 (setq log-edit-file-name (svn-log-edit-file-name))
4052 (unless use-existing-buffer
4053 (when (and log-edit-file-name (file-readable-p log-edit-file-name))
4054 (insert-file-contents log-edit-file-name)))
4055 (svn-log-edit-mode)))
4057 (defun svn-status-switch-to-status-buffer ()
4058 "Switch to the `svn-status-buffer-name' buffer."
4060 (switch-to-buffer svn-status-buffer-name))
4062 (defun svn-status-pop-to-status-buffer ()
4063 "Pop to the `svn-status-buffer-name' buffer."
4065 (pop-to-buffer svn-status-buffer-name))
4067 (defun svn-status-via-bookmark (bookmark)
4068 "Allows a quick selection of a bookmark in `svn-bookmark-list'.
4069 Run `svn-status' on the selected bookmark."
4072 (let ((completion-ignore-case t))
4073 (funcall svn-status-completing-read-function "SVN status bookmark: " svn-bookmark-list))))
4075 (error "No bookmark specified"))
4076 (let ((directory (cdr (assoc bookmark svn-bookmark-list))))
4077 (if (file-directory-p directory)
4078 (svn-status directory)
4079 (error "%s is not a directory" directory))))
4081 (defun svn-status-export ()
4082 "Run `svn export' for the current working copy.
4083 Ask the user for the destination path.
4084 `svn-status-default-export-directory' is suggested as export directory."
4086 (let* ((src default-directory)
4087 (dir1-name (nth 1 (nreverse (split-string src "/"))))
4088 (dest (read-file-name (format "Export %s to " src) (concat svn-status-default-export-directory dir1-name))))
4089 (svn-run t t 'export "export" (expand-file-name src) (expand-file-name dest))
4090 (message "svn-status-export %s %s" src dest)))
4092 (defun svn-status-cleanup (arg)
4093 "Run `svn cleanup' on all selected files.
4094 See `svn-status-marked-files' for what counts as selected.
4095 When this function is called with a prefix argument, use the actual file instead."
4097 (let ((file-names (svn-status-get-file-list-names (not arg))))
4100 (message "svn-status-cleanup %S" file-names)
4101 (svn-run t t 'cleanup (append (list "cleanup") file-names)))
4102 (message "No valid file selected - No status cleanup possible"))))
4104 (defun svn-status-resolved ()
4105 "Run `svn resolved' on all selected files.
4106 See `svn-status-marked-files' for what counts as selected."
4108 (let* ((marked-files (svn-status-marked-files))
4109 (num-of-files (length marked-files)))
4111 (if (= 1 num-of-files)
4112 (format "Resolve %s? " (svn-status-line-info->filename (car marked-files)))
4113 (format "Resolve %d files? " num-of-files)))
4114 (message "resolving: %S" (svn-status-marked-file-names))
4115 (svn-status-create-arg-file svn-status-temp-arg-file "" (svn-status-marked-files) "")
4116 (svn-run t t 'resolved "resolved" "--targets" svn-status-temp-arg-file))))
4119 (defun svn-status-svnversion ()
4120 "Run svnversion on the directory that contains the file at point."
4122 (svn-status-ensure-cursor-on-file)
4123 (let ((simple-path (svn-status-line-info->filename (svn-status-get-line-information)))
4124 (full-path (svn-status-line-info->full-path (svn-status-get-line-information)))
4126 (unless (file-directory-p simple-path)
4127 (setq simple-path (or (file-name-directory simple-path) "."))
4128 (setq full-path (file-name-directory full-path)))
4129 (setq version (shell-command-to-string (concat "svnversion -n " full-path)))
4130 (message "svnversion for '%s': %s" simple-path version)
4133 ;; --------------------------------------------------------------------------------
4134 ;; Update the `svn-status-buffer-name' buffer, when a file is saved
4135 ;; --------------------------------------------------------------------------------
4137 (defvar svn-status-file-modified-after-save-flag ?m
4138 "Flag shown whenever a file is modified and saved in Emacs.
4139 The flag is shown in the `svn-status-buffer-name' buffer.
4140 Recommended values are ?m or ?M.")
4141 (defun svn-status-after-save-hook ()
4142 "Set a modified indication, when a file is saved from a svn working copy."
4143 (let* ((svn-dir (car-safe svn-status-directory-history))
4144 (svn-dir (when svn-dir (expand-file-name svn-dir)))
4145 (file-dir (file-name-directory (buffer-file-name)))
4146 (svn-dir-len (length (or svn-dir "")))
4147 (file-dir-len (length file-dir))
4149 (when (and (get-buffer svn-status-buffer-name)
4151 (>= file-dir-len svn-dir-len)
4152 (string= (substring file-dir 0 svn-dir-len) svn-dir))
4153 (setq file-name (substring (buffer-file-name) svn-dir-len))
4154 ;;(message "In svn-status directory %S" file-name)
4155 (let ((st-info svn-status-info)
4158 (setq i-fname (svn-status-line-info->filename (car st-info)))
4159 ;;(message "i-fname=%S" i-fname)
4160 (when (and (string= file-name i-fname)
4161 (not (eq (svn-status-line-info->filemark (car st-info)) ??)))
4162 (svn-status-line-info->set-filemark (car st-info)
4163 svn-status-file-modified-after-save-flag)
4164 (save-window-excursion
4165 (set-buffer svn-status-buffer-name)
4167 (let ((buffer-read-only nil)
4168 (pos (svn-status-get-file-name-buffer-position i-fname)))
4172 (delete-region (svn-point-at-bol) (svn-point-at-eol))
4173 (svn-insert-line-in-status-buffer (car st-info))
4175 (svn-status-message 3 "psvn: file %s not found, updating %s buffer content..."
4176 i-fname svn-status-buffer-name)
4177 (svn-status-update-buffer))))))
4178 (setq st-info (cdr st-info))))))
4181 (add-hook 'after-save-hook 'svn-status-after-save-hook)
4183 ;; --------------------------------------------------------------------------------
4184 ;; vc-svn integration
4185 ;; --------------------------------------------------------------------------------
4186 (defvar svn-status-state-mark-modeline t) ; modeline mark display or not
4187 (defvar svn-status-state-mark-tooltip nil) ; modeline tooltip display
4189 (defun svn-status-state-mark-modeline-dot (color)
4191 'help-echo 'svn-status-state-mark-tooltip
4194 :data ,(format "/* XPM */
4195 static char * data[] = {
4216 (defun svn-status-install-state-mark-modeline (color)
4217 (push `(svn-status-state-mark-modeline
4218 ,(svn-status-state-mark-modeline-dot color))
4220 (force-mode-line-update t))
4222 (defun svn-status-uninstall-state-mark-modeline ()
4223 (setq mode-line-format
4224 (remove-if #'(lambda (mode) (eq (car-safe mode)
4225 'svn-status-state-mark-modeline))
4227 (force-mode-line-update t))
4229 (defun svn-status-update-state-mark-tooltip (tooltip)
4230 (setq svn-status-state-mark-tooltip tooltip))
4232 (defun svn-status-update-state-mark (color)
4233 (svn-status-uninstall-state-mark-modeline)
4234 (svn-status-install-state-mark-modeline color))
4236 (defsubst svn-status-in-vc-mode? ()
4238 (and vc-mode (string-match "^ SVN" (substring-no-properties vc-mode))))
4240 (when svn-status-fancy-file-state-in-modeline
4241 (defadvice vc-find-file-hook (after svn-status-vc-svn-find-file-hook activate)
4242 "vc-find-file-hook advice for synchronizing psvn with vc-svn interface"
4243 (when (svn-status-in-vc-mode?) (svn-status-update-modeline)))
4245 (defadvice vc-after-save (after svn-status-vc-svn-after-save activate)
4246 "vc-after-save advice for synchronizing psvn when saving buffer"
4247 (when (svn-status-in-vc-mode?) (svn-status-update-modeline))))
4249 (defun svn-status-update-modeline ()
4250 "Update modeline state dot mark properly"
4251 (when (and buffer-file-name (svn-status-in-vc-mode?))
4252 (svn-status-update-state-mark
4253 (svn-status-interprete-state-mode-color
4254 (vc-svn-state buffer-file-name)))))
4256 (defsubst svn-status-interprete-state-mode-color (stat)
4257 "Interpret vc-svn-state symbol to mode line color"
4260 ('up-to-date "GreenYellow" )
4261 ;; what is missing here??
4262 ;; ('unknown "gray" )
4264 ;; ('deleted "red" )
4265 ;; ('unmerged "purple" )
4268 ;; --------------------------------------------------------------------------------
4269 ;; Getting older revisions
4270 ;; --------------------------------------------------------------------------------
4272 (defun svn-status-get-specific-revision (arg)
4273 "Retrieve older revisions.
4274 The older revisions are stored in backup files named F.~REVISION~.
4276 When the function is called without a prefix argument: get all marked files.
4277 With a prefix argument: get only the actual file."
4279 (svn-status-get-specific-revision-internal
4280 (svn-status-get-file-list (not arg)) :ask t))
4282 (defun svn-status-get-specific-revision-internal (line-infos revision handle-relative-svn-status-dir)
4283 "Retrieve older revisions of files.
4284 LINE-INFOS is a list of line-info structures (see
4285 `svn-status-get-line-information').
4287 - a string: whatever the -r option allows.
4288 - `:ask': asks the user to specify the revision, which then becomes
4289 saved in `minibuffer-history' rather than in `command-history'.
4290 - `:auto': Use \"HEAD\" if an update is known to exist, \"BASE\" otherwise.
4292 After the call, `svn-status-get-revision-file-info' will be an alist
4293 \((WORKING-FILE-NAME . RETRIEVED-REVISION-FILE-NAME) ...). These file
4294 names are relative to the directory where `svn-status' was run."
4295 ;; In `svn-status-show-svn-diff-internal', there is a comment
4296 ;; that REVISION `nil' might mean omitting the -r option entirely.
4297 ;; That doesn't seem like a good idea with svn cat.
4299 ;; (message "svn-status-get-specific-revision-internal: %S %S" line-infos revision)
4301 (when (eq revision :ask)
4302 (setq revision (svn-status-read-revision-string
4303 "Get files for version: " "PREV")))
4305 (let ((count (length line-infos)))
4307 (let ((line-info (car line-infos)))
4308 (message "Getting revision %s of %s"
4309 (if (eq revision :auto)
4310 (if (svn-status-line-info->update-available line-info)
4313 (svn-status-line-info->filename line-info)))
4314 ;; We could compute "Getting HEAD of 8 files and BASE of 11 files"
4315 ;; but that'd be more bloat than it's worth.
4316 (message "Getting revision %s of %d files"
4317 (if (eq revision :auto) "HEAD or BASE" revision)
4320 (let ((svn-status-get-specific-revision-file-info '()))
4321 (dolist (line-info line-infos)
4322 (let* ((revision (if (eq revision :auto)
4323 (if (svn-status-line-info->update-available line-info)
4325 revision)) ;must be a string by this point
4326 (file-name (svn-status-line-info->filename line-info))
4327 ;; If REVISION is e.g. "HEAD", should we find out the actual
4328 ;; revision number and save "foo.~123~" rather than "foo.~HEAD~"?
4329 ;; OTOH, `auto-mode-alist' already ignores ".~HEAD~" suffixes,
4330 ;; and if users often want to know the revision numbers of such
4331 ;; files, they can use svn:keywords.
4332 (file-name-with-revision (concat (file-name-nondirectory file-name) ".~" revision "~"))
4333 (default-directory (concat (svn-status-base-dir)
4334 (if handle-relative-svn-status-dir
4335 (file-relative-name default-directory (svn-status-base-dir))
4337 (file-name-directory file-name))))
4338 ;; `add-to-list' would unnecessarily check for duplicates.
4339 (push (cons file-name (concat (file-name-directory file-name) file-name-with-revision))
4340 svn-status-get-specific-revision-file-info)
4341 (svn-status-message 3 "svn-status-get-specific-revision-internal: file: %s, default-directory: %s"
4342 file-name default-directory)
4343 (svn-status-message 3 "svn-status-get-specific-revision-internal: file-name-with-revision: %s %S"
4344 file-name-with-revision (file-exists-p file-name-with-revision))
4346 (if (or (not (file-exists-p file-name-with-revision)) ;; file does not exist
4347 (not (string= (number-to-string (string-to-number revision)) revision))) ;; revision is not a number
4349 (message "Getting revision %s of %s, target: %s" revision file-name
4350 (expand-file-name(concat default-directory file-name-with-revision)))
4353 (if (string= revision "BASE")
4354 (insert-file-contents (concat (svn-wc-adm-dir-name)
4356 (file-name-nondirectory file-name)
4359 (svn-run nil t 'cat "cat" "-r" revision
4360 (concat default-directory (file-name-nondirectory file-name)))
4361 ;;todo: error processing
4362 ;;svn: Filesystem has no item
4363 ;;svn: file not found: revision `15', path `/trunk/file.txt'
4364 (insert-buffer-substring svn-process-buffer-name)))
4366 (find-file file-name-with-revision)
4367 (setq buffer-read-only nil)
4368 (erase-buffer) ;Widen, because we'll save the whole buffer.
4370 (goto-char (point-min))
4371 (let ((write-file-functions nil)
4372 (require-final-newline nil))
4374 (find-file file-name-with-revision)))))
4375 ;;(message "default-directory: %s revision-file-info: %S" default-directory svn-status-get-specific-revision-file-info)
4376 (nreverse svn-status-get-specific-revision-file-info)))
4378 (defun svn-status-ediff-with-revision (arg)
4379 "Run ediff on the current file with a different revision.
4380 If there is a newer revision in the repository, the diff is done against HEAD,
4381 otherwise compare the working copy with BASE.
4382 If ARG then prompt for revision to diff against."
4384 (let* ((svn-status-get-specific-revision-file-info
4385 (svn-status-get-specific-revision-internal
4386 (list (svn-status-make-line-info
4388 (svn-status-line-info->full-path (svn-status-get-line-information))
4389 (svn-status-base-dir))
4390 nil nil nil nil nil nil
4391 (svn-status-line-info->update-available (svn-status-get-line-information))))
4394 (ediff-after-quit-destination-buffer (current-buffer))
4395 (default-directory (svn-status-base-dir))
4396 (my-buffer (find-file-noselect (caar svn-status-get-specific-revision-file-info)))
4397 (base-buff (find-file-noselect (cdar svn-status-get-specific-revision-file-info)))
4398 (svn-transient-buffers (list my-buffer base-buff))
4399 (startup-hook '(svn-ediff-startup-hook)))
4400 (ediff-buffers base-buff my-buffer startup-hook)))
4402 (defun svn-ediff-startup-hook ()
4403 ;; (message "svn-ediff-startup-hook: ediff-after-quit-hook-internal: %S" ediff-after-quit-hook-internal)
4404 (add-hook 'ediff-after-quit-hook-internal
4406 (svn-ediff-exit-hook
4407 ',ediff-after-quit-destination-buffer ',svn-transient-buffers))
4410 (defun svn-ediff-exit-hook (svn-buf tmp-bufs)
4411 ;; (message "svn-ediff-exit-hook: svn-buf: %s, tmp-bufs: %s" svn-buf tmp-bufs)
4412 ;; kill the temp buffers (and their associated windows)
4413 (dolist (tb tmp-bufs)
4414 (when (and tb (buffer-live-p tb) (not (buffer-modified-p tb)))
4415 (let* ((win (get-buffer-window tb t))
4416 (file-name (buffer-file-name tb))
4417 (is-temp-file (numberp (string-match "~\\([0-9]+\\|BASE\\)~" file-name))))
4418 ;; (message "svn-ediff-exit-hook - is-temp-file: %s, temp-buf:: %s - %s " is-temp-file (current-buffer) file-name)
4419 (when (and win (> (count-windows) 1)
4420 (delete-window win)))
4422 (when (and is-temp-file svn-status-ediff-delete-temporary-files)
4423 (when (or (eq svn-status-ediff-delete-temporary-files t)
4424 (y-or-n-p (format "Delete File '%s' ? " file-name)))
4425 (delete-file file-name))))))
4426 ;; switch back to the *svn* buffer
4427 (when (and svn-buf (buffer-live-p svn-buf)
4428 (not (get-buffer-window svn-buf t)))
4429 (ignore-errors (switch-to-buffer svn-buf))))
4432 (defun svn-status-read-revision-string (prompt &optional default-value)
4433 "Prompt the user for a svn revision number."
4435 (read-string prompt default-value))
4437 (defun svn-file-show-svn-ediff (arg)
4438 "Run ediff on the current file with a previous revision.
4439 If ARG then prompt for revision to diff against."
4441 (let ((svn-status-get-line-information-for-file 'relative)
4442 (default-directory (svn-status-base-dir)))
4443 (svn-status-ediff-with-revision arg)))
4445 ;; --------------------------------------------------------------------------------
4446 ;; SVN process handling
4447 ;; --------------------------------------------------------------------------------
4449 (defun svn-process-kill ()
4450 "Kill the current running svn process."
4452 (let ((process (get-process "svn")))
4454 (delete-process process)
4455 (message "No running svn process"))))
4457 (defun svn-process-send-string (string &optional send-passwd)
4458 "Send a string to the running svn process.
4459 This is useful, if the running svn process asks the user a question.
4460 Note: use C-q C-j to send a line termination character."
4461 (interactive "sSend string to svn process: ")
4463 (set-buffer svn-process-buffer-name)
4464 (goto-char (point-max))
4465 (let ((buffer-read-only nil))
4466 (insert (if send-passwd (make-string (length string) ?.) string)))
4467 (set-marker (process-mark (get-process "svn")) (point)))
4468 (process-send-string "svn" string))
4470 (defun svn-process-send-string-and-newline (string &optional send-passwd)
4471 "Send a string to the running svn process.
4472 Just call `svn-process-send-string' with STRING and an end of line termination.
4473 When called with a prefix argument, read the data from user as password."
4474 (interactive (let* ((use-passwd current-prefix-arg)
4476 (read-passwd "Send secret line to svn process: ")
4477 (read-string "Send line to svn process: "))))
4478 (list s use-passwd)))
4479 (svn-process-send-string (concat string "\n") send-passwd))
4481 ;; --------------------------------------------------------------------------------
4482 ;; Property List stuff
4483 ;; --------------------------------------------------------------------------------
4485 (defun svn-status-property-list ()
4487 (let ((file-names (svn-status-marked-file-names)))
4490 (svn-run t t 'proplist (append (list "proplist" "-v") file-names)))
4491 (message "No valid file selected - No property listing possible"))))
4493 (defun svn-status-proplist-start ()
4494 (svn-status-ensure-cursor-on-file)
4495 (svn-run t t 'proplist-parse "proplist" (svn-status-line-info->filename
4496 (svn-status-get-line-information))))
4497 (defun svn-status-property-edit-one-entry (arg)
4499 When called with a prefix argument, it is possible to enter a new property."
4501 (setq svn-status-property-edit-must-match-flag (not arg))
4502 (svn-status-proplist-start))
4504 (defun svn-status-property-set ()
4506 (setq svn-status-property-edit-must-match-flag nil)
4507 (svn-status-proplist-start))
4509 (defun svn-status-property-delete ()
4511 (setq svn-status-property-edit-must-match-flag t)
4512 (svn-status-proplist-start))
4514 (defun svn-status-property-parse-property-names ()
4515 ;(svn-status-show-process-buffer-internal t)
4516 (message "svn-status-property-parse-property-names")
4521 (set-buffer svn-process-buffer-name)
4522 (goto-char (point-min))
4524 (while (looking-at " \\(.+\\)")
4525 (setq pl (append pl (list (match-string 1))))
4527 ;(cond last-command: svn-status-property-set, svn-status-property-edit-one-entry
4528 (cond ((eq last-command 'svn-status-property-edit-one-entry)
4529 ;;(message "svn-status-property-edit-one-entry")
4531 (completing-read "Set Property - Name: " (mapcar 'list pl)
4532 nil svn-status-property-edit-must-match-flag))
4533 (unless (string= prop-name "")
4535 (set-buffer svn-status-buffer-name)
4536 (svn-status-property-edit (list (svn-status-get-line-information))
4538 ((eq last-command 'svn-status-property-set)
4539 (message "svn-status-property-set")
4541 (completing-read "Set Property - Name: " (mapcar 'list pl) nil nil))
4542 (setq prop-value (read-from-minibuffer "Property value: "))
4543 (unless (string= prop-name "")
4545 (set-buffer svn-status-buffer-name)
4546 (message "Setting property %s := %s for %S" prop-name prop-value
4547 (svn-status-marked-file-names))
4548 (let ((file-names (svn-status-marked-file-names)))
4550 (svn-run nil t 'propset
4551 (append (list "propset" prop-name prop-value) file-names))
4554 (message "propset finished.")
4556 ((eq last-command 'svn-status-property-delete)
4558 (completing-read "Delete Property - Name: " (mapcar 'list pl) nil t))
4559 (unless (string= prop-name "")
4561 (set-buffer svn-status-buffer-name)
4562 (let ((file-names (svn-status-marked-file-names)))
4564 (message "Going to delete prop %s for %s" prop-name file-names)
4565 (svn-run t t 'propdel
4566 (append (list "propdel" prop-name) file-names))))))))))
4568 (defun svn-status-property-edit (file-info-list prop-name &optional new-prop-value remove-values)
4569 (let* ((commit-buffer (get-buffer-create "*svn-property-edit*"))
4570 (dir default-directory)
4571 ;; now only one file is implemented ...
4572 (file-name (svn-status-line-info->filename (car file-info-list)))
4574 (message "Edit property %s for file %s" prop-name file-name)
4575 (svn-run nil t 'propget-parse "propget" prop-name file-name)
4577 (set-buffer svn-process-buffer-name)
4578 (setq prop-value (if (> (point-max) 1)
4579 (buffer-substring (point-min) (- (point-max) 1))
4581 (setq svn-status-propedit-property-name prop-name)
4582 (setq svn-status-propedit-file-list file-info-list)
4583 (setq svn-status-pre-propedit-window-configuration (current-window-configuration))
4584 (pop-to-buffer commit-buffer)
4585 ;; If the buffer has been narrowed, `svn-prop-edit-done' will use
4586 ;; only the accessible part. So we need not erase the rest here.
4587 (delete-region (point-min) (point-max))
4588 (setq default-directory dir)
4590 (svn-status-remove-control-M)
4591 (when new-prop-value
4592 (when (listp new-prop-value)
4594 (message "Remove prop values %S " new-prop-value)
4595 (message "Adding new prop values %S " new-prop-value))
4596 (while new-prop-value
4597 (goto-char (point-min))
4598 (if (re-search-forward (concat "^" (regexp-quote (car new-prop-value)) "$") nil t)
4600 (kill-whole-line 1))
4601 (unless remove-values
4602 (goto-char (point-max))
4603 (when (> (current-column) 0) (insert "\n"))
4604 (insert (car new-prop-value))))
4605 (setq new-prop-value (cdr new-prop-value)))))
4606 (svn-prop-edit-mode)))
4608 (defun svn-status-property-set-property (file-info-list prop-name prop-value)
4609 "Set a property on a given file list."
4611 (set-buffer (get-buffer-create "*svn-property-edit*"))
4612 ;; If the buffer has been narrowed, `svn-prop-edit-do-it' will use
4613 ;; only the accessible part. So we need not erase the rest here.
4614 (delete-region (point-min) (point-max))
4615 (insert prop-value))
4616 (setq svn-status-propedit-file-list (svn-status-marked-files))
4617 (setq svn-status-propedit-property-name prop-name)
4618 (svn-prop-edit-do-it nil)
4619 (svn-status-update))
4622 (defun svn-status-get-directory (line-info)
4623 (let* ((file-name (svn-status-line-info->filename line-info))
4624 (file-dir (file-name-directory file-name)))
4625 ;;(message "file-dir: %S" file-dir)
4627 (substring file-dir 0 (- (length file-dir) 1))
4630 (defun svn-status-get-file-list-per-directory (files)
4631 ;;(message "%S" files)
4632 (let ((dir-list nil)
4637 (setq dir (svn-status-get-directory (car i)))
4638 (setq j (assoc dir dir-list))
4641 ;;(message "dir already present %S %s" j dir)
4642 (setcdr j (append (cdr j) (list (car i)))))
4643 (setq dir-list (append dir-list (list (list dir (car i))))))
4645 ;;(message "svn-status-get-file-list-per-directory: %S" dir-list)
4648 (defun svn-status-property-ignore-file ()
4650 (let ((d-list (svn-status-get-file-list-per-directory (svn-status-marked-files)))
4655 (setq dir (caar d-list))
4656 (setq f-info (cdar d-list))
4657 (setq ext-list (mapcar '(lambda (i)
4658 (svn-status-line-info->filename-nondirectory i)) f-info))
4659 ;;(message "ignore in dir %s: %S" dir f-info)
4660 (save-window-excursion
4661 (when (y-or-n-p (format "Ignore %S for %s? " ext-list dir))
4662 (svn-status-property-edit
4663 (list (svn-status-find-info-for-file-name dir)) "svn:ignore" ext-list)
4664 (svn-prop-edit-do-it nil))) ; synchronous
4665 (setq d-list (cdr d-list)))
4666 (svn-status-update)))
4668 (defun svn-status-property-ignore-file-extension ()
4670 (let ((d-list (svn-status-get-file-list-per-directory (svn-status-marked-files)))
4675 (setq dir (caar d-list))
4676 (setq f-info (cdar d-list))
4677 ;;(message "ignore in dir %s: %S" dir f-info)
4680 (add-to-list 'ext-list (concat "*."
4681 (file-name-extension
4682 (svn-status-line-info->filename (car f-info)))))
4683 (setq f-info (cdr f-info)))
4684 ;;(message "%S" ext-list)
4685 (save-window-excursion
4686 (when (y-or-n-p (format "Ignore %S for %s? " ext-list dir))
4687 (svn-status-property-edit
4688 (list (svn-status-find-info-for-file-name dir)) "svn:ignore"
4690 (svn-prop-edit-do-it nil)))
4691 (setq d-list (cdr d-list)))
4692 (svn-status-update)))
4694 (defun svn-status-property-edit-svn-ignore ()
4696 (let* ((line-info (svn-status-get-line-information))
4697 (dir (if (svn-status-line-info->directory-p line-info)
4698 (svn-status-line-info->filename line-info)
4699 (svn-status-get-directory line-info))))
4700 (svn-status-property-edit
4701 (list (svn-status-find-info-for-file-name dir)) "svn:ignore")
4702 (message "Edit svn:ignore on %s" dir)))
4705 (defun svn-status-property-set-keyword-list ()
4706 "Edit the svn:keywords property on the marked files."
4708 ;;(message "Set svn:keywords for %S" (svn-status-marked-file-names))
4709 (svn-status-property-edit (svn-status-marked-files) "svn:keywords"))
4711 (defun svn-status-property-set-keyword-id (arg)
4712 "Set/Remove Id from the svn:keywords property.
4713 Normally Id is added to the svn:keywords property.
4715 When called with the prefix arg -, remove Id from the svn:keywords property."
4717 (svn-status-property-edit (svn-status-marked-files) "svn:keywords" '("Id") (eq arg '-))
4718 (svn-prop-edit-do-it nil))
4720 (defun svn-status-property-set-keyword-date (arg)
4721 "Set/Remove Date from the svn:keywords property.
4722 Normally Date is added to the svn:keywords property.
4724 When called with the prefix arg -, remove Date from the svn:keywords property."
4726 (svn-status-property-edit (svn-status-marked-files) "svn:keywords" '("Date") (eq arg '-))
4727 (svn-prop-edit-do-it nil))
4730 (defun svn-status-property-set-eol-style ()
4731 "Edit the svn:eol-style property on the marked files."
4733 (svn-status-property-set-property
4734 (svn-status-marked-files) "svn:eol-style"
4735 (completing-read "Set svn:eol-style for the marked files: "
4736 (mapcar 'list '("native" "CRLF" "LF" "CR"))
4739 (defun svn-status-property-set-executable ()
4740 "Set the svn:executable property on the marked files."
4742 (svn-status-property-set-property (svn-status-marked-files) "svn:executable" "*"))
4744 (defun svn-status-property-set-mime-type ()
4745 "Set the svn:mime-type property on the marked files."
4747 (require 'mailcap nil t)
4748 (let ((completion-ignore-case t)
4749 (mime-types (when (fboundp 'mailcap-mime-types)
4750 (mailcap-mime-types))))
4751 (svn-status-property-set-property
4752 (svn-status-marked-files) "svn:mime-type"
4753 (funcall svn-status-completing-read-function "Set svn:mime-type for the marked files: "
4754 (mapcar (lambda (x) (cons x x)) ; for Emacs 21
4755 (sort mime-types 'string<))))))
4757 ;; --------------------------------------------------------------------------------
4758 ;; svn-prop-edit-mode:
4759 ;; --------------------------------------------------------------------------------
4761 (defvar svn-prop-edit-mode-map () "Keymap used in `svn-prop-edit-mode' buffers.")
4762 (put 'svn-prop-edit-mode-map 'risky-local-variable t) ;for Emacs 20.7
4764 (when (not svn-prop-edit-mode-map)
4765 (setq svn-prop-edit-mode-map (make-sparse-keymap))
4766 (define-key svn-prop-edit-mode-map [(control ?c) (control ?c)] 'svn-prop-edit-done)
4767 (define-key svn-prop-edit-mode-map [(control ?c) (control ?d)] 'svn-prop-edit-svn-diff)
4768 (define-key svn-prop-edit-mode-map [(control ?c) (control ?s)] 'svn-prop-edit-svn-status)
4769 (define-key svn-prop-edit-mode-map [(control ?c) (control ?l)] 'svn-prop-edit-svn-log)
4770 (define-key svn-prop-edit-mode-map [(control ?c) (control ?q)] 'svn-prop-edit-abort))
4772 (easy-menu-define svn-prop-edit-mode-menu svn-prop-edit-mode-map
4773 "'svn-prop-edit-mode' menu"
4775 ["Commit" svn-prop-edit-done t]
4776 ["Show Diff" svn-prop-edit-svn-diff t]
4777 ["Show Status" svn-prop-edit-svn-status t]
4778 ["Show Log" svn-prop-edit-svn-log t]
4779 ["Abort" svn-prop-edit-abort t]))
4781 (defun svn-prop-edit-mode ()
4782 "Major Mode to edit file properties of files under svn control.
4784 \\{svn-prop-edit-mode-map}"
4786 (kill-all-local-variables)
4787 (use-local-map svn-prop-edit-mode-map)
4788 (easy-menu-add svn-prop-edit-mode-menu)
4789 (setq major-mode 'svn-prop-edit-mode)
4790 (setq mode-name "svn-prop-edit"))
4792 (defun svn-prop-edit-abort ()
4795 (set-window-configuration svn-status-pre-propedit-window-configuration))
4797 (defun svn-prop-edit-done ()
4799 (svn-prop-edit-do-it t))
4801 (defun svn-prop-edit-do-it (async)
4802 "Run svn propset `svn-status-propedit-property-name' with the content of the
4803 *svn-property-edit* buffer."
4804 (message "svn propset %s on %s"
4805 svn-status-propedit-property-name
4806 (mapcar 'svn-status-line-info->filename svn-status-propedit-file-list))
4808 (set-buffer (get-buffer "*svn-property-edit*"))
4809 (when (fboundp 'set-buffer-file-coding-system)
4810 (set-buffer-file-coding-system svn-status-svn-file-coding-system nil))
4811 (setq svn-status-temp-file-to-remove
4812 (concat svn-status-temp-dir "svn-prop-edit.txt" svn-temp-suffix))
4813 (write-region (point-min) (point-max) svn-status-temp-file-to-remove nil 1))
4814 (when svn-status-propedit-file-list ; there are files to change properties
4815 (svn-status-create-arg-file svn-status-temp-arg-file ""
4816 svn-status-propedit-file-list "")
4817 (setq svn-status-propedit-file-list nil)
4818 (svn-run async t 'propset "propset"
4819 svn-status-propedit-property-name
4820 "--targets" svn-status-temp-arg-file
4821 (when (eq svn-status-svn-file-coding-system 'utf-8)
4822 '("--encoding" "UTF-8"))
4823 "-F" (concat svn-status-temp-dir "svn-prop-edit.txt" svn-temp-suffix))
4824 (unless async (svn-status-remove-temp-file-maybe)))
4825 (when svn-status-pre-propedit-window-configuration
4826 (set-window-configuration svn-status-pre-propedit-window-configuration)))
4828 (defun svn-prop-edit-svn-diff (arg)
4830 (set-buffer svn-status-buffer-name)
4831 ;; Because propedit is not recursive in our use, neither is this diff.
4832 (svn-status-show-svn-diff-internal svn-status-propedit-file-list nil
4833 (if arg :ask "BASE")))
4835 (defun svn-prop-edit-svn-log (arg)
4837 (set-buffer svn-status-buffer-name)
4838 (svn-status-show-svn-log arg))
4840 (defun svn-prop-edit-svn-status ()
4842 (pop-to-buffer svn-status-buffer-name)
4845 ;; --------------------------------------------------------------------------------
4846 ;; svn-log-edit-mode:
4847 ;; --------------------------------------------------------------------------------
4849 (defvar svn-log-edit-mode-map () "Keymap used in `svn-log-edit-mode' buffers.")
4850 (put 'svn-log-edit-mode-map 'risky-local-variable t) ;for Emacs 20.7
4852 (defvar svn-log-edit-mode-menu) ;really defined with `easy-menu-define' below.
4854 (defun svn-log-edit-common-setup ()
4855 (set (make-local-variable 'paragraph-start) svn-log-edit-paragraph-start)
4856 (set (make-local-variable 'paragraph-separate) svn-log-edit-paragraph-separate))
4858 (if svn-log-edit-use-log-edit-mode
4859 (define-derived-mode svn-log-edit-mode log-edit-mode "svn-log-edit"
4860 "Wrapper around `log-edit-mode' for psvn.el"
4861 (easy-menu-add svn-log-edit-mode-menu)
4862 (setq svn-log-edit-update-log-entry nil)
4863 (set (make-local-variable 'log-edit-callback) 'svn-log-edit-done)
4864 (set (make-local-variable 'log-edit-listfun) 'svn-log-edit-files-to-commit)
4865 (set (make-local-variable 'log-edit-initial-files) (log-edit-files))
4866 (svn-log-edit-common-setup)
4867 (message "Press %s when you are done editing."
4868 (substitute-command-keys "\\[log-edit-done]"))
4870 (defun svn-log-edit-mode ()
4871 "Major Mode to edit svn log messages.
4873 \\{svn-log-edit-mode-map}"
4875 (kill-all-local-variables)
4876 (use-local-map svn-log-edit-mode-map)
4877 (easy-menu-add svn-log-edit-mode-menu)
4878 (setq major-mode 'svn-log-edit-mode)
4879 (setq mode-name "svn-log-edit")
4880 (setq svn-log-edit-update-log-entry nil)
4881 (svn-log-edit-common-setup)
4882 (run-hooks 'svn-log-edit-mode-hook)))
4884 (when (not svn-log-edit-mode-map)
4885 (setq svn-log-edit-mode-map (make-sparse-keymap))
4886 (unless svn-log-edit-use-log-edit-mode
4887 (define-key svn-log-edit-mode-map (kbd "C-c C-c") 'svn-log-edit-done))
4888 (define-key svn-log-edit-mode-map (kbd "C-c C-d") 'svn-log-edit-svn-diff)
4889 (define-key svn-log-edit-mode-map (kbd "C-c C-s") 'svn-log-edit-save-message)
4890 (define-key svn-log-edit-mode-map (kbd "C-c C-i") 'svn-log-edit-svn-status)
4891 (define-key svn-log-edit-mode-map (kbd "C-c C-l") 'svn-log-edit-svn-log)
4892 (define-key svn-log-edit-mode-map (kbd "C-c C-?") 'svn-log-edit-show-files-to-commit)
4893 (define-key svn-log-edit-mode-map (kbd "C-c C-z") 'svn-log-edit-erase-edit-buffer)
4894 (define-key svn-log-edit-mode-map (kbd "C-c C-q") 'svn-log-edit-abort))
4896 (easy-menu-define svn-log-edit-mode-menu svn-log-edit-mode-map
4897 "'svn-log-edit-mode' menu"
4899 ["Save to disk" svn-log-edit-save-message t]
4900 ["Commit" svn-log-edit-done t]
4901 ["Show Diff" svn-log-edit-svn-diff t]
4902 ["Show Status" svn-log-edit-svn-status t]
4903 ["Show Log" svn-log-edit-svn-log t]
4904 ["Show files to commit" svn-log-edit-show-files-to-commit t]
4905 ["Erase buffer" svn-log-edit-erase-edit-buffer]
4906 ["Abort" svn-log-edit-abort t]))
4907 (put 'svn-log-edit-mode-menu 'risky-local-variable t)
4909 (defun svn-log-edit-abort ()
4912 (set-window-configuration svn-status-pre-commit-window-configuration))
4914 (defun svn-log-edit-done ()
4915 "Finish editing the log message and run svn commit."
4917 (svn-status-save-some-buffers)
4919 (set-buffer (get-buffer svn-log-edit-buffer-name))
4920 (when svn-log-edit-insert-files-to-commit
4921 (svn-log-edit-remove-comment-lines))
4922 (when (fboundp 'set-buffer-file-coding-system)
4923 (set-buffer-file-coding-system svn-status-svn-file-coding-system nil))
4924 (when (or svn-log-edit-update-log-entry svn-status-files-to-commit)
4925 (setq svn-status-temp-file-to-remove
4926 (concat svn-status-temp-dir "svn-log-edit.txt" svn-temp-suffix))
4927 (write-region (point-min) (point-max) svn-status-temp-file-to-remove nil 1))
4929 (if svn-log-edit-update-log-entry
4930 (when (y-or-n-p "Update the log entry? ")
4931 ;; svn propset svn:log --revprop -r11672 -F file
4932 (svn-run nil t 'propset "propset" "svn:log" "--revprop"
4933 (concat "-r" svn-log-edit-update-log-entry)
4934 "-F" svn-status-temp-file-to-remove)
4936 (set-buffer svn-process-buffer-name)
4937 (message "%s" (buffer-substring (point-min) (- (point-max) 1)))))
4938 (when svn-status-files-to-commit ; there are files to commit
4939 (setq svn-status-operated-on-dot
4940 (and (= 1 (length svn-status-files-to-commit))
4941 (string= "." (svn-status-line-info->filename (car svn-status-files-to-commit)))))
4942 (svn-status-create-arg-file svn-status-temp-arg-file ""
4943 svn-status-files-to-commit "")
4944 (svn-run t t 'commit "commit"
4945 (unless svn-status-recursive-commit "--non-recursive")
4946 "--targets" svn-status-temp-arg-file
4947 "-F" svn-status-temp-file-to-remove
4948 (when (eq svn-status-svn-file-coding-system 'utf-8)
4949 '("--encoding" "UTF-8"))
4950 svn-status-default-commit-arguments))
4951 (set-window-configuration svn-status-pre-commit-window-configuration)
4952 (message "svn-log editing done")))
4954 (defun svn-log-edit-svn-diff (arg)
4955 "Show the diff we are about to commit.
4956 If ARG then show diff between some other version of the selected files."
4958 (set-buffer svn-status-buffer-name) ; TODO: is this necessary?
4959 ;; This call is very much like `svn-status-show-svn-diff-for-marked-files'
4960 ;; but uses commit-specific variables instead of the current marks.
4961 (svn-status-show-svn-diff-internal svn-status-files-to-commit
4962 svn-status-recursive-commit
4963 (if arg :ask "BASE")))
4965 (defun svn-log-edit-svn-log (arg)
4967 (set-buffer svn-status-buffer-name)
4968 (svn-status-show-svn-log arg))
4970 (defun svn-log-edit-svn-status ()
4972 (pop-to-buffer svn-status-buffer-name)
4975 (defun svn-log-edit-files-to-commit ()
4976 (mapcar 'svn-status-line-info->filename svn-status-files-to-commit))
4978 (defun svn-log-edit-show-files-to-commit ()
4980 (message "Files to commit%s: %S"
4981 (if svn-status-recursive-commit " recursively" "")
4982 (svn-log-edit-files-to-commit)))
4984 (defun svn-log-edit-save-message ()
4985 "Save the current log message to the file `svn-log-edit-file-name'."
4987 (let ((log-edit-file-name (svn-log-edit-file-name)))
4988 (if (string= buffer-file-name log-edit-file-name)
4990 (write-region (point-min) (point-max) log-edit-file-name))))
4992 (defun svn-log-edit-erase-edit-buffer ()
4993 "Delete everything in the `svn-log-edit-buffer-name' buffer."
4995 (set-buffer svn-log-edit-buffer-name)
4998 (defun svn-log-edit-insert-files-to-commit ()
5000 (svn-log-edit-remove-comment-lines)
5001 (let ((buf-size (- (point-max) (point-min))))
5003 (goto-char (point-min))
5004 (insert "## Lines starting with '## ' will be removed from the log message.\n")
5005 (insert "## File(s) to commit"
5006 (if svn-status-recursive-commit " recursively" "") ":\n")
5007 (let ((file-list svn-status-files-to-commit))
5009 (insert (concat "## " (svn-status-line-info->filename (car file-list)) "\n"))
5010 (setq file-list (cdr file-list)))))
5011 (when (= 0 buf-size)
5012 (goto-char (point-max)))))
5014 (defun svn-log-edit-remove-comment-lines ()
5017 (goto-char (point-min))
5018 (flush-lines "^## .*")))
5020 (defun svn-file-add-to-changelog (prefix-arg)
5021 "Create a changelog entry for the function at point.
5022 The variable `svn-status-changelog-style' allows to select the used changlog style"
5024 (cond ((eq svn-status-changelog-style 'changelog)
5025 (svn-file-add-to-log-changelog-style prefix-arg))
5026 ((eq svn-status-changelog-style 'svn-dev)
5027 (svn-file-add-to-log-svn-dev-style prefix-arg))
5028 ((fboundp svn-status-changelog-style)
5029 (funcall svn-status-changelog-style prefix-arg))
5031 (error "Invalid setting for `svn-status-changelog-style'"))))
5033 (defun svn-file-add-to-log-changelog-style (curdir)
5034 "Create a changelog entry for the function at point.
5035 `add-change-log-entry-other-window' creates the header information.
5036 If CURDIR, save the log file in the current directory, otherwise in the base directory of this working copy."
5038 (add-change-log-entry-other-window nil (svn-log-edit-file-name curdir))
5039 (svn-log-edit-mode))
5041 ;; taken from svn-dev.el: svn-log-path-derive
5042 (defun svn-dev-log-path-derive (path)
5043 "Derive a relative directory path for absolute PATH, for a log entry."
5045 (let ((base (file-name-nondirectory path))
5046 (chop-spot (string-match
5047 "\\(code/\\)\\|\\(src/\\)\\|\\(projects/\\)"
5051 (setq path (substring path (match-end 0)))
5052 ;; Kluge for Subversion developers.
5053 (if (string-match "subversion/" path)
5054 (substring path (+ (match-beginning 0) 11))
5056 (string-match (expand-file-name "~/") path)
5057 (substring path (match-end 0))))))
5059 ;; taken from svn-dev.el: svn-log-message
5060 (defun svn-file-add-to-log-svn-dev-style (prefix-arg)
5061 "Add to an in-progress log message, based on context around point.
5062 If PREFIX-ARG is negative, then use basenames only in
5063 log messages, otherwise use full paths. The current defun name is
5066 If PREFIX-ARG is a list (e.g. by using C-u), save the log file in
5067 the current directory, otherwise in the base directory of this
5070 If the log message already contains material about this defun, then put
5071 point there, so adding to that material is easy.
5073 Else if the log message already contains material about this file, put
5074 point there, and push onto the kill ring the defun name with log
5075 message dressing around it, plus the raw defun name, so yank and
5076 yank-next are both useful.
5078 Else if there is no material about this defun nor file anywhere in the
5079 log message, then put point at the end of the message and insert a new
5080 entry for file with defun.
5083 (let* ((short-file-names (and (numberp prefix-arg) (< prefix-arg 0)))
5084 (curdir (listp prefix-arg))
5085 (this-file (if short-file-names
5086 (file-name-nondirectory buffer-file-name)
5087 (svn-dev-log-path-derive buffer-file-name)))
5088 (this-defun (or (add-log-current-defun)
5091 (if (eq major-mode 'c-mode)
5093 (if (fboundp 'c-beginning-of-statement-1)
5094 (c-beginning-of-statement-1)
5095 (c-beginning-of-statement))
5096 (search-forward "(" nil t)
5101 (progn (forward-sexp 1) (point)))))))))
5102 (log-file (svn-log-edit-file-name curdir)))
5103 (find-file log-file)
5104 (goto-char (point-min))
5105 ;; Strip text properties from strings
5106 (set-text-properties 0 (length this-file) nil this-file)
5107 (set-text-properties 0 (length this-defun) nil this-defun)
5108 ;; If log message for defun already in progress, add to it
5110 this-defun ;; we have a defun to work with
5111 (search-forward this-defun nil t) ;; it's in the log msg already
5112 (save-excursion ;; and it's about the same file
5114 (if (re-search-backward ; Ick, I want a real filename regexp!
5115 "^\\*\\s-+\\([a-zA-Z0-9-_.@=+^$/%!?(){}<>]+\\)" nil t)
5116 (string-equal (match-string 1) this-file)
5118 (if (re-search-forward ":" nil t)
5119 (if (looking-at " ") (forward-char 1)))
5120 ;; Else no log message for this defun in progress...
5121 (goto-char (point-min))
5122 ;; But if log message for file already in progress, add to it.
5123 (if (search-forward this-file nil t)
5125 (if this-defun (progn
5126 (kill-new (format "(%s): " this-defun))
5127 (kill-new this-defun)))
5128 (search-forward ")" nil t)
5129 (if (looking-at " ") (forward-char 1)))
5130 ;; Found neither defun nor its file, so create new entry.
5131 (goto-char (point-max))
5132 (if (not (bolp)) (insert "\n"))
5133 (insert (format "\n* %s (%s): " this-file (or this-defun "")))
5134 ;; Finally, if no derived defun, put point where the user can
5135 ;; type it themselves.
5136 (if (not this-defun) (forward-char -3))))))
5138 ;; --------------------------------------------------------------------------------
5139 ;; svn-log-view-mode:
5140 ;; --------------------------------------------------------------------------------
5142 (defvar svn-log-view-mode-map () "Keymap used in `svn-log-view-mode' buffers.")
5143 (put 'svn-log-view-mode-map 'risky-local-variable t) ;for Emacs 20.7
5145 (when (not svn-log-view-mode-map)
5146 (setq svn-log-view-mode-map (make-sparse-keymap))
5147 (suppress-keymap svn-log-view-mode-map)
5148 (define-key svn-log-view-mode-map (kbd "p") 'svn-log-view-prev)
5149 (define-key svn-log-view-mode-map (kbd "n") 'svn-log-view-next)
5150 (define-key svn-log-view-mode-map (kbd "~") 'svn-log-get-specific-revision)
5151 (define-key svn-log-view-mode-map (kbd "E") 'svn-log-ediff-specific-revision)
5152 (define-key svn-log-view-mode-map (kbd "=") 'svn-log-view-diff)
5153 (define-key svn-log-view-mode-map (kbd "TAB") 'svn-log-next-link)
5154 (define-key svn-log-view-mode-map [backtab] 'svn-log-prev-link)
5155 (define-key svn-log-view-mode-map (kbd "RET") 'svn-log-find-file-at-point)
5156 (define-key svn-log-view-mode-map (kbd "e") 'svn-log-edit-log-entry)
5157 (define-key svn-log-view-mode-map (kbd "q") 'bury-buffer))
5159 (defvar svn-log-view-popup-menu-map ()
5160 "Keymap used to show popup menu in `svn-log-view-mode' buffers.")
5161 (put 'svn-log-view-popup-menu-map 'risky-local-variable t) ;for Emacs 20.7
5162 (when (not svn-log-view-popup-menu-map)
5163 (setq svn-log-view-popup-menu-map (make-sparse-keymap))
5164 (suppress-keymap svn-log-view-popup-menu-map)
5165 (define-key svn-log-view-popup-menu-map [down-mouse-3] 'svn-log-view-popup-menu))
5167 (easy-menu-define svn-log-view-mode-menu svn-log-view-mode-map
5168 "'svn-log-view-mode' menu"
5170 ["Show Changeset" svn-log-view-diff t]
5171 ["Ediff file at point" svn-log-ediff-specific-revision t]
5172 ["Find file at point" svn-log-find-file-at-point t]
5173 ["Get older revision for file at point" svn-log-get-specific-revision t]
5174 ["Edit log message" svn-log-edit-log-entry t]))
5176 (defun svn-log-view-popup-menu (event)
5178 (mouse-set-point event)
5179 (let* ((rev (svn-log-revision-at-point)))
5181 (svn-status-face-set-temporary-during-popup
5182 'svn-status-marked-popup-face (svn-point-at-bol) (svn-point-at-eol)
5183 svn-log-view-mode-menu))))
5185 (defvar svn-log-view-font-lock-basic-keywords
5186 '(("^r[0-9]+ .+" (0 `(face font-lock-keyword-face
5187 mouse-face highlight
5188 keymap ,svn-log-view-popup-menu-map))))
5189 "Basic keywords in `svn-log-view-mode'.")
5190 (put 'svn-log-view-font-basic-lock-keywords 'risky-local-variable t) ;for Emacs 20.7
5192 (defvar svn-log-view-font-lock-keywords)
5193 (define-derived-mode svn-log-view-mode fundamental-mode "svn-log-view"
5194 "Major Mode to show the output from svn log.
5196 \\{svn-log-view-mode-map}
5198 (use-local-map svn-log-view-mode-map)
5199 (easy-menu-add svn-log-view-mode-menu)
5200 (set (make-local-variable 'svn-log-view-font-lock-keywords) svn-log-view-font-lock-basic-keywords)
5201 (dolist (lh svn-log-link-handlers)
5202 (add-to-list 'svn-log-view-font-lock-keywords (gethash lh svn-log-registered-link-handlers)))
5203 (set (make-local-variable 'font-lock-defaults) '(svn-log-view-font-lock-keywords t)))
5205 (defun svn-log-view-next ()
5207 (when (re-search-forward "^r[0-9]+" nil t)
5208 (beginning-of-line 2)
5209 (unless (looking-at "Changed paths:")
5210 (beginning-of-line 1))))
5212 (defun svn-log-view-prev ()
5214 (when (re-search-backward "^r[0-9]+" nil t 2)
5215 (beginning-of-line 2)
5216 (unless (looking-at "Changed paths:")
5217 (beginning-of-line 1))))
5219 (defun svn-log-revision-at-point ()
5222 (re-search-backward "^r\\([0-9]+\\)")
5223 (svn-match-string-no-properties 1)))
5225 (defun svn-log-file-name-at-point (respect-checkout-prefix-path)
5226 (let ((full-file-name)
5228 (checkout-prefix-path (if respect-checkout-prefix-path
5230 (svn-status-checkout-prefix-path))
5234 (when (looking-at " [MA] /\\(.+\\)$")
5235 (setq full-file-name (svn-match-string-no-properties 1))))
5236 (when (string= checkout-prefix-path "")
5237 (setq checkout-prefix-path "/"))
5238 (if (null full-file-name)
5240 (message "No file at point")
5243 (if (eq (string-match (regexp-quote (substring checkout-prefix-path 1)) full-file-name) 0)
5244 (substring full-file-name (- (length checkout-prefix-path) (if (string= checkout-prefix-path "/") 1 0)))
5246 ;; (message "svn-log-file-name-at-point %s prefix: '%s', full-file-name: %s" file-name checkout-prefix-path full-file-name)
5249 (defun svn-log-find-file-at-point ()
5251 (let ((file-name (svn-log-file-name-at-point t)))
5253 (let ((default-directory (svn-status-base-dir)))
5254 ;;(message "svn-log-file-name-at-point: %s, default-directory: %s" file-name default-directory)
5255 (find-file file-name)))))
5257 (defun svn-log-next-link ()
5258 "Jump to the next external link in this buffer"
5260 (let ((start-pos (if (get-text-property (point) 'link-handler)
5261 (next-single-property-change (point) 'link-handler)
5263 (goto-char (or (next-single-property-change start-pos 'link-handler) (point)))))
5265 (defun svn-log-prev-link ()
5266 "Jump to the previous external link in this buffer"
5268 (let ((start-pos (if (get-text-property (point) 'link-handler)
5269 (previous-single-property-change (point) 'link-handler)
5271 (goto-char (or (previous-single-property-change (or start-pos (point)) 'link-handler) (point)))))
5273 (defun svn-log-view-diff (arg)
5274 "Show the changeset for a given log entry.
5275 When called with a prefix argument, ask the user for the revision."
5277 (svn-status-diff-show-changeset (svn-log-revision-at-point) arg))
5279 (defun svn-log-get-specific-revision ()
5280 "Get an older revision of the file at point via svn cat."
5282 ;; (message "%S" (svn-status-make-line-info (svn-log-file-name-at-point t)))
5283 (let ((default-directory (svn-status-base-dir)))
5284 (svn-status-get-specific-revision-internal
5285 (list (svn-status-make-line-info (svn-log-file-name-at-point t)))
5286 (svn-log-revision-at-point)
5289 (defun svn-log-ediff-specific-revision ()
5290 "Call ediff for the file at point to view a changeset"
5292 ;; (message "svn-log-ediff-specific-revision: %s" (svn-log-file-name-at-point t))
5293 (let* ((cur-buf (current-buffer))
5294 (upper-rev (svn-log-revision-at-point))
5295 (lower-rev (number-to-string (- (string-to-number upper-rev) 1)))
5296 (file-name (svn-log-file-name-at-point t))
5297 (default-directory (svn-status-base-dir))
5298 (upper-rev-file-name (when file-name
5299 (cdar (svn-status-get-specific-revision-internal
5300 (list (svn-status-make-line-info file-name)) upper-rev nil))))
5301 (lower-rev-file-name (when file-name
5302 (cdar (svn-status-get-specific-revision-internal
5303 (list (svn-status-make-line-info file-name)) lower-rev nil)))))
5304 ;;(message "%S %S" upper-rev-file-name lower-rev-file-name)
5306 (let* ((ediff-after-quit-destination-buffer cur-buf)
5307 (newer-buffer (find-file-noselect upper-rev-file-name))
5308 (base-buff (find-file-noselect lower-rev-file-name))
5309 (svn-transient-buffers (list base-buff newer-buffer))
5310 (startup-hook '(svn-ediff-startup-hook)))
5311 (ediff-buffers base-buff newer-buffer startup-hook))
5312 (message "No file at point"))))
5314 (defun svn-log-edit-log-entry ()
5315 "Edit the given log entry."
5317 (let ((rev (svn-log-revision-at-point))
5319 (svn-run nil t 'propget-parse "propget" "--revprop" (concat "-r" rev) "svn:log")
5321 (set-buffer svn-process-buffer-name)
5322 (setq log-message (if (> (point-max) 1)
5323 (buffer-substring (point-min) (- (point-max) 1))
5325 (svn-status-pop-to-commit-buffer)
5326 ;; If the buffer has been narrowed, `svn-log-edit-done' will use
5327 ;; only the accessible part. So we need not erase the rest here.
5328 (delete-region (point-min) (point-max))
5329 (insert log-message)
5330 (goto-char (point-min))
5331 (setq svn-log-edit-update-log-entry rev)))
5334 ;; allow additional hyperlinks in log view buffers
5335 (defvar svn-log-link-keymap ()
5336 "Keymap used to resolve links `svn-log-view-mode' buffers.")
5337 (put 'svn-log-link-keymap 'risky-local-variable t) ;for Emacs 20.7
5338 (when (not svn-log-link-keymap)
5339 (setq svn-log-link-keymap (make-sparse-keymap))
5340 (suppress-keymap svn-log-link-keymap)
5341 (define-key svn-log-link-keymap [mouse-2] 'svn-log-resolve-mouse-link)
5342 (define-key svn-log-link-keymap (kbd "RET") 'svn-log-resolve-link))
5344 (defun svn-log-resolve-mouse-link (event)
5346 (mouse-set-point event)
5347 (svn-log-resolve-link))
5349 (defun svn-log-resolve-link ()
5351 (let* ((point-adjustment (if (not (get-text-property (- (point) 1) 'link-handler)) 1
5352 (if (not (get-text-property (+ (point) 1) 'link-handler)) -1 0)))
5353 (link-name (buffer-substring-no-properties (previous-single-property-change (+ (point) point-adjustment) 'link-handler)
5354 (next-single-property-change (+ (point) point-adjustment) 'link-handler))))
5355 ;; (message "svn-log-resolve-link '%s'" link-name)
5356 (funcall (get-text-property (point) 'link-handler) link-name)))
5358 (defun svn-log-register-link-handler (handler-id link-regexp handler-function)
5359 "Register a link handler for external links in *svn-log* buffers
5360 HANDLER-ID is a symbolic name for this handler. The link handler is active when HANDLER-ID
5361 is registered in `svn-log-link-handlers'.
5362 LINK-REGEXP specifies a regular expression that matches the external link.
5363 HANDLER-FUNCTION is called with the match of LINK-REGEXP when the user clicks at the external link."
5364 (let ((font-lock-desc (list link-regexp '(0 `(face font-lock-function-name-face
5365 mouse-face highlight
5366 link-handler invalid-handler-function
5367 keymap ,svn-log-link-keymap)))))
5368 ;; no idea, how to use handler-function in invalid-handler-function above, so set it here
5369 (setcar (nthcdr 5 (nth 1 (nth 1 (nth 1 font-lock-desc)))) handler-function)
5370 (svn-puthash handler-id font-lock-desc svn-log-registered-link-handlers)))
5372 ;; example: add support for ditrack links and handle them via svn-log-resolve-ditrack
5373 ;;(svn-log-register-link-handler 'ditrack-issue "i#[0-9]+" 'svn-log-resolve-ditrack)
5374 ;;(defun svn-log-resolve-ditrack (link-name)
5376 ;; (message "svn-log-resolve-ditrack %s" link-name))
5379 (defun svn-log-resolve-trac-ticket-short (link-name)
5380 "Show the trac ticket specified by LINK-NAME via `svn-trac-browse-ticket'."
5382 (let ((ticket-nr (string-to-number (substring-no-properties link-name 1))))
5383 (svn-trac-browse-ticket ticket-nr)))
5385 ;; register the out of the box provided link handlers
5386 (svn-log-register-link-handler 'trac-ticket-short "#[0-9]+" 'svn-log-resolve-trac-ticket-short)
5388 ;; the actually used link handlers are specified in svn-log-link-handlers
5390 ;; --------------------------------------------------------------------------------
5392 ;; --------------------------------------------------------------------------------
5393 (defvar svn-info-mode-map () "Keymap used in `svn-info-mode' buffers.")
5394 (put 'svn-info-mode-map 'risky-local-variable t) ;for Emacs 20.7
5396 (when (not svn-info-mode-map)
5397 (setq svn-info-mode-map (make-sparse-keymap))
5398 (define-key svn-info-mode-map [?s] 'svn-status-pop-to-status-buffer)
5399 (define-key svn-info-mode-map (kbd "h") 'svn-status-pop-to-partner-buffer)
5400 (define-key svn-info-mode-map (kbd "n") 'next-line)
5401 (define-key svn-info-mode-map (kbd "p") 'previous-line)
5402 (define-key svn-info-mode-map (kbd "RET") 'svn-info-show-context)
5403 (define-key svn-info-mode-map [?q] 'bury-buffer))
5405 (defun svn-info-mode ()
5406 "Major Mode to view informative output from svn."
5408 (kill-all-local-variables)
5409 (use-local-map svn-info-mode-map)
5410 (setq major-mode 'svn-info-mode)
5411 (setq mode-name "svn-info")
5412 (toggle-read-only 1))
5414 (defun svn-info-show-context ()
5415 "Show the context for a line in the info buffer.
5416 Currently is the output from the svn update command known."
5418 (cond ((save-excursion
5419 (goto-char (point-max))
5422 (looking-at "Updated to revision"))
5423 ;; svn-info contains info from an svn update
5424 (let ((cur-pos (point))
5425 (file-name (buffer-substring-no-properties
5426 (progn (beginning-of-line) (re-search-forward ".. +") (point))
5427 (line-end-position)))
5429 (when (eq system-type 'windows-nt)
5430 (setq file-name (replace-regexp-in-string "\\\\" "/" file-name)))
5432 (with-current-buffer svn-status-buffer-name
5433 (setq pos (svn-status-get-file-name-buffer-position file-name)))
5435 (svn-status-pop-to-new-partner-buffer svn-status-buffer-name)
5436 (goto-char pos))))))
5438 ;; --------------------------------------------------------------------------------
5439 ;; svn blame minor mode
5440 ;; --------------------------------------------------------------------------------
5442 (unless (assq 'svn-blame-mode minor-mode-alist)
5443 (setq minor-mode-alist
5444 (cons (list 'svn-blame-mode " SvnBlame")
5447 (defvar svn-blame-mode-map () "Keymap used in `svn-blame-mode' buffers.")
5448 (put 'svn-blame-mode-map 'risky-local-variable t) ;for Emacs 20.7
5450 (when (not svn-blame-mode-map)
5451 (setq svn-blame-mode-map (make-sparse-keymap))
5452 (define-key svn-blame-mode-map [?s] 'svn-status-pop-to-status-buffer)
5453 (define-key svn-blame-mode-map (kbd "n") 'next-line)
5454 (define-key svn-blame-mode-map (kbd "p") 'previous-line)
5455 (define-key svn-blame-mode-map (kbd "RET") 'svn-blame-open-source-file)
5456 (define-key svn-blame-mode-map (kbd "a") 'svn-blame-highlight-author)
5457 (define-key svn-blame-mode-map (kbd "r") 'svn-blame-highlight-revision)
5458 (define-key svn-blame-mode-map (kbd "=") 'svn-blame-show-changeset)
5459 (define-key svn-blame-mode-map (kbd "l") 'svn-blame-show-log)
5460 (define-key svn-blame-mode-map [?q] 'bury-buffer))
5462 (easy-menu-define svn-blame-mode-menu svn-blame-mode-map
5463 "svn blame minor mode menu"
5465 ["Jump to source location" svn-blame-open-source-file t]
5466 ["Show changeset" svn-blame-show-changeset t]
5467 ["Show log" svn-blame-show-log t]
5468 ["Highlight by author" svn-blame-highlight-author t]
5469 ["Highlight by revision" svn-blame-highlight-revision t]))
5471 (or (assq 'svn-blame-mode minor-mode-map-alist)
5472 (setq minor-mode-map-alist
5473 (cons (cons 'svn-blame-mode svn-blame-mode-map) minor-mode-map-alist)))
5475 (make-variable-buffer-local 'svn-blame-mode)
5477 (defun svn-blame-mode (&optional arg)
5478 "Toggle svn blame minor mode.
5479 With ARG, turn svn blame minor mode on if ARG is positive, off otherwise.
5481 Note: This mode does not yet work on XEmacs...
5482 It is probably because the revisions are in 'before-string properties of overlays
5485 \\{svn-blame-mode-map}"
5487 (setq svn-blame-mode (if (null arg)
5488 (not svn-blame-mode)
5489 (> (prefix-numeric-value arg) 0)))
5492 (easy-menu-add svn-blame-mode-menu)
5493 (toggle-read-only 1))
5494 (easy-menu-remove svn-blame-mode-menu))
5495 (force-mode-line-update))
5497 (defun svn-status-activate-blame-mode ()
5498 "Activate the svn blame minor in the current buffer.
5499 The current buffer must contain a valid output from svn blame"
5501 (goto-char (point-min))
5502 (let ((buffer-read-only nil)
5503 (line (svn-line-number-at-pos))
5505 (info-end-col (save-excursion (forward-word 2) (+ (current-column) 1)))
5508 ;; remove the old overlays (only for testing)
5509 ;; (dolist (ov (overlays-in (point) limit))
5510 ;; (when (overlay-get ov 'svn-blame-line-info)
5511 ;; (delete-overlay ov)))
5512 (while (and (not (eobp)) (< (point) limit))
5513 (setq ov (make-overlay (point) (point)))
5514 (overlay-put ov 'svn-blame-line-info t)
5515 (setq s (buffer-substring-no-properties (svn-point-at-bol) (+ (svn-point-at-bol) info-end-col)))
5516 (overlay-put ov 'before-string (propertize s 'face 'svn-status-blame-rev-number-face))
5517 (overlay-put ov 'rev-info (delete "" (split-string s " ")))
5518 (delete-region (svn-point-at-bol) (+ (svn-point-at-bol) info-end-col))
5520 (setq line (1+ line)))))
5521 (let* ((buf-name (format "*svn-blame: %s*" (file-relative-name svn-status-blame-file-name)))
5522 (buffer (get-buffer buf-name)))
5524 (kill-buffer buffer))
5525 (rename-buffer buf-name))
5526 ;; use the correct mode for the displayed blame output
5527 (let ((buffer-file-name svn-status-blame-file-name))
5529 (set (make-local-variable 'svn-status-blame-file-name) svn-status-blame-file-name))
5530 (font-lock-fontify-buffer)
5533 (defun svn-blame-open-source-file ()
5534 "Jump to the source file location for the current position in the svn blame buffer"
5536 (let ((src-line-number (svn-line-number-at-pos))
5537 (src-line-col (current-column)))
5538 (find-file-other-window svn-status-blame-file-name)
5539 (goto-line src-line-number)
5540 (forward-char src-line-col)))
5542 (defun svn-blame-rev-at-point ()
5544 (dolist (ov (overlays-in (svn-point-at-bol) (line-end-position)))
5545 (when (overlay-get ov 'svn-blame-line-info)
5546 (setq rev (car (overlay-get ov 'rev-info)))))
5549 (defun svn-blame-show-changeset (arg)
5550 "Show a diff for the revision at point.
5551 When called with a prefix argument, allow the user to edit the revision."
5553 (svn-status-diff-show-changeset (svn-blame-rev-at-point) arg))
5555 (defun svn-blame-show-log (arg)
5556 "Show the log for the revision at point.
5557 The output is put into the *svn-log* buffer
5558 The optional prefix argument ARG determines which switches are passed to `svn log':
5559 no prefix --- use whatever is in the list `svn-status-default-log-arguments'
5560 prefix argument of -1: --- use the -q switch (quiet)
5561 prefix argument of 0 --- use no arguments
5562 other prefix arguments: --- use the -v switch (verbose)"
5564 (let ((switches (svn-status-svn-log-switches arg))
5565 (rev (svn-blame-rev-at-point)))
5566 (svn-run t t 'log "log" "--revision" rev switches)))
5568 (defun svn-blame-highlight-line-maybe (compare-func)
5569 (let ((reference-value)
5571 (consider-this-line)
5573 (dolist (ov (overlays-in (svn-point-at-bol) (line-end-position)))
5574 (when (overlay-get ov 'svn-blame-line-info)
5575 (setq reference-value (funcall compare-func ov)))
5576 (when (overlay-get ov 'svn-blame-highlighted)
5577 (setq is-highlighted t)))
5579 (goto-char (point-min))
5581 (setq consider-this-line nil)
5582 (dolist (ov (overlays-in (svn-point-at-bol) (line-end-position)))
5583 (when (overlay-get ov 'svn-blame-line-info)
5584 (when (string= reference-value (funcall compare-func ov))
5585 (setq consider-this-line t))))
5586 (when consider-this-line
5587 (dolist (ov (overlays-in (svn-point-at-bol) (line-end-position)))
5588 (when (and (overlay-get ov 'svn-blame-highlighted) is-highlighted)
5589 (delete-overlay ov))
5590 (unless is-highlighted
5591 (setq hl-ov (make-overlay (svn-point-at-bol) (line-end-position)))
5592 (overlay-put hl-ov 'svn-blame-highlighted t)
5593 (overlay-put hl-ov 'face 'svn-status-blame-highlight-face))))
5596 (defun svn-blame-highlight-author-field (ov)
5597 (cadr (overlay-get ov 'rev-info)))
5599 (defun svn-blame-highlight-author ()
5600 "(Un)Highlight all lines with the same author."
5602 (svn-blame-highlight-line-maybe 'svn-blame-highlight-author-field))
5604 (defun svn-blame-highlight-revision-field (ov)
5605 (car (overlay-get ov 'rev-info)))
5607 (defun svn-blame-highlight-revision ()
5608 "(Un)Highlight all lines with the same revision."
5610 (svn-blame-highlight-line-maybe 'svn-blame-highlight-revision-field))
5612 ;; --------------------------------------------------------------------------------
5614 ;; --------------------------------------------------------------------------------
5615 (defvar svn-process-mode-map () "Keymap used in `svn-process-mode' buffers.")
5616 (put 'svn-process-mode-map 'risky-local-variable t) ;for Emacs 20.7
5618 (when (not svn-process-mode-map)
5619 (setq svn-process-mode-map (make-sparse-keymap))
5620 (define-key svn-process-mode-map (kbd "RET") 'svn-process-send-string-and-newline)
5621 (define-key svn-process-mode-map [?s] 'svn-process-send-string)
5622 (define-key svn-process-mode-map [?q] 'bury-buffer))
5624 (easy-menu-define svn-process-mode-menu svn-process-mode-map
5625 "'svn-process-mode' menu"
5627 ["Send line to process" svn-process-send-string-and-newline t]
5628 ["Send raw string to process" svn-process-send-string t]
5629 ["Bury process buffer" bury-buffer t]))
5631 (defun svn-process-mode ()
5632 "Major Mode to view process output from svn.
5634 You can send a new line terminated string to the process via \\[svn-process-send-string-and-newline]
5635 You can send raw data to the process via \\[svn-process-send-string]."
5637 (kill-all-local-variables)
5638 (use-local-map svn-process-mode-map)
5639 (easy-menu-add svn-log-view-mode-menu)
5640 (setq major-mode 'svn-process-mode)
5641 (setq mode-name "svn-process"))
5643 ;; --------------------------------------------------------------------------------
5644 ;; svn status persistent options
5645 ;; --------------------------------------------------------------------------------
5647 (defun svn-status-repo-for-path (directory)
5648 "Find the repository root for DIRECTORY."
5649 (let ((old-process-default-dir))
5650 (with-current-buffer (get-buffer-create svn-process-buffer-name)
5651 (setq old-process-default-dir default-directory)
5652 (setq default-directory directory)) ;; update the default-directory for the *svn-process* buffer
5653 (svn-run nil t 'parse-info "info" ".")
5654 (with-current-buffer svn-process-buffer-name
5655 ;; (message "svn-status-repo-for-path: %s: default-directory: %s directory: %s old-process-default-dir: %s" svn-process-buffer-name default-directory directory old-process-default-dir)
5656 (setq default-directory old-process-default-dir)
5657 (goto-char (point-min))
5658 (let ((case-fold-search t))
5659 (if (search-forward "repository root: " nil t)
5660 (buffer-substring-no-properties (point) (svn-point-at-eol))
5661 (when (search-forward "repository uuid: " nil t)
5662 (message "psvn.el: Detected an old svn working copy in '%s'. Please check it out again to get a 'Repository Root' entry in the svn info output."
5664 (concat "Svn Repo UUID: " (buffer-substring-no-properties (point) (svn-point-at-eol)))))))))
5666 (defun svn-status-base-dir (&optional start-directory)
5667 "Find the svn root directory for the current working copy.
5668 Return nil, if not in a svn working copy."
5669 (let* ((start-dir (expand-file-name (or start-directory default-directory)))
5670 (base-dir (gethash start-dir svn-status-base-dir-cache 'not-found)))
5671 ;;(message "svn-status-base-dir: %S %S" start-dir base-dir)
5672 (if (not (eq base-dir 'not-found))
5674 ;; (message "calculating base-dir for %s" start-dir)
5675 (unless svn-client-version
5676 (svn-status-version))
5677 (let* ((base-dir start-dir)
5678 (repository-root (svn-status-repo-for-path base-dir))
5679 (dot-svn-dir (concat base-dir (svn-wc-adm-dir-name)))
5680 (in-tree (and repository-root (file-exists-p dot-svn-dir)))
5681 (dir-below (expand-file-name base-dir)))
5682 ;; (message "repository-root: %s start-dir: %s" repository-root start-dir)
5683 (if (and (<= (car svn-client-version) 1) (< (cadr svn-client-version) 3))
5684 (setq base-dir (svn-status-base-dir-for-ancient-svn-client start-dir)) ;; svn version < 1.3
5685 (while (when (and dir-below (file-exists-p dot-svn-dir))
5686 (setq base-dir (file-name-directory dot-svn-dir))
5687 (string-match "\\(.+/\\).+/" dir-below)
5689 (and (string-match "\\(.*/\\)[^/]+/" dir-below)
5690 (match-string 1 dir-below)))
5691 ;; (message "base-dir: %s, dir-below: %s, dot-svn-dir: %s in-tree: %s" base-dir dir-below dot-svn-dir in-tree)
5693 (if (string= (svn-status-repo-for-path dir-below) repository-root)
5694 (setq dot-svn-dir (concat dir-below (svn-wc-adm-dir-name)))
5695 (setq dir-below nil)))))
5696 (setq base-dir (and in-tree base-dir)))
5697 (svn-puthash start-dir base-dir svn-status-base-dir-cache)
5698 (svn-status-message 7 "svn-status-base-dir %s => %s" start-dir base-dir)
5701 (defun svn-status-base-dir-for-ancient-svn-client (&optional start-directory)
5702 "Find the svn root directory for the current working copy.
5703 Return nil, if not in a svn working copy.
5704 This function is used for svn clients version 1.2 and below."
5705 (let* ((base-dir (expand-file-name (or start-directory default-directory)))
5706 (dot-svn-dir (concat base-dir (svn-wc-adm-dir-name)))
5707 (in-tree (file-exists-p dot-svn-dir))
5708 (dir-below (expand-file-name default-directory)))
5709 (while (when (and dir-below (file-exists-p dot-svn-dir))
5710 (setq base-dir (file-name-directory dot-svn-dir))
5711 (string-match "\\(.+/\\).+/" dir-below)
5713 (and (string-match "\\(.*/\\)[^/]+/" dir-below)
5714 (match-string 1 dir-below)))
5715 (setq dot-svn-dir (concat dir-below (svn-wc-adm-dir-name)))))
5716 (and in-tree base-dir)))
5718 (defun svn-status-save-state ()
5719 "Save psvn persistent options for this working copy to a file."
5721 (let ((buf (find-file (concat (svn-status-base-dir) "++psvn.state"))))
5722 (erase-buffer) ;Widen, because we'll save the whole buffer.
5723 ;; TO CHECK: why is svn-status-options a global variable??
5724 (setq svn-status-options
5726 (list "svn-trac-project-root" svn-trac-project-root)
5727 (list "sort-status-buffer" svn-status-sort-status-buffer)
5728 (list "elide-list" svn-status-elided-list)
5729 (list "module-name" svn-status-module-name)
5730 (list "branch-list" svn-status-branch-list)
5731 (list "changelog-style" svn-status-changelog-style)
5733 (insert (pp-to-string svn-status-options))
5737 (defun svn-status-load-state (&optional no-error)
5738 "Load psvn persistent options for this working copy from a file."
5740 (let ((file (concat (svn-status-base-dir) "++psvn.state")))
5741 (if (file-readable-p file)
5743 (insert-file-contents file)
5744 (setq svn-status-options (read (current-buffer)))
5745 (setq svn-status-sort-status-buffer
5746 (nth 1 (assoc "sort-status-buffer" svn-status-options)))
5747 (setq svn-trac-project-root
5748 (nth 1 (assoc "svn-trac-project-root" svn-status-options)))
5749 (setq svn-status-elided-list
5750 (nth 1 (assoc "elide-list" svn-status-options)))
5751 (setq svn-status-module-name
5752 (nth 1 (assoc "module-name" svn-status-options)))
5753 (setq svn-status-branch-list
5754 (nth 1 (assoc "branch-list" svn-status-options)))
5755 (setq svn-status-changelog-style
5756 (nth 1 (assoc "changelog-style" svn-status-options)))
5757 (when (and (interactive-p) svn-status-elided-list (svn-status-apply-elide-list)))
5758 (message "psvn.el: loaded %s" file))
5760 (setq svn-trac-project-root nil
5761 svn-status-elided-list nil
5762 svn-status-module-name nil
5763 svn-status-branch-list nil
5764 svn-status-changelog-style 'changelog)
5765 (error "psvn.el: %s is not readable." file)))))
5767 (defun svn-status-toggle-sort-status-buffer ()
5768 "Toggle sorting of the *svn-status* buffer.
5770 If you turn off sorting, you can speed up \\[svn-status]. However,
5771 the buffer is not correctly sorted then. This function will be
5772 removed again, when a faster parsing and display routine for
5773 `svn-status' is available."
5775 (setq svn-status-sort-status-buffer (not svn-status-sort-status-buffer))
5776 (message "The %s buffer will %sbe sorted." svn-status-buffer-name
5777 (if svn-status-sort-status-buffer "" "not ")))
5779 (defun svn-status-toggle-svn-verbose-flag ()
5780 "Toggle `svn-status-verbose'. "
5782 (setq svn-status-verbose (not svn-status-verbose))
5783 (message "svn status calls will %suse the -v flag." (if svn-status-verbose "" "not ")))
5785 (defun svn-status-toggle-display-full-path ()
5786 "Toggle displaying the full path in the `svn-status-buffer-name' buffer"
5788 (setq svn-status-display-full-path (not svn-status-display-full-path))
5789 (message "The %s buffer will%s use full path names." svn-status-buffer-name
5790 (if svn-status-display-full-path "" " not"))
5791 (svn-status-update-buffer))
5793 (defun svn-status-set-trac-project-root ()
5795 (setq svn-trac-project-root
5796 (read-string "Trac project root (e.g.: http://projects.edgewall.com/trac/): "
5797 svn-trac-project-root))
5798 (when (yes-or-no-p "Save the new setting for svn-trac-project-root to disk? ")
5799 (svn-status-save-state)))
5801 (defun svn-status-set-module-name ()
5802 "Interactively set `svn-status-module-name'."
5804 (setq svn-status-module-name
5805 (read-string "Short Unit Name (e.g.: MyProject): "
5806 svn-status-module-name))
5807 (when (yes-or-no-p "Save the new setting for svn-status-module-name to disk? ")
5808 (svn-status-save-state)))
5810 (defun svn-status-set-changelog-style ()
5811 "Interactively set `svn-status-changelog-style'."
5813 (setq svn-status-changelog-style
5814 (intern (funcall svn-status-completing-read-function "svn-status on directory: " '("changelog" "svn-dev" "other"))))
5815 (when (string= svn-status-changelog-style 'other)
5816 (setq svn-status-changelog-style (car (find-function-read))))
5817 (when (yes-or-no-p "Save the new setting for svn-status-changelog-style to disk? ")
5818 (svn-status-save-state)))
5820 (defun svn-status-set-branch-list ()
5821 "Interactively set `svn-status-branch-list'."
5823 (setq svn-status-branch-list
5824 (split-string (read-string "Branch list: "
5825 (mapconcat 'identity svn-status-branch-list " "))))
5826 (when (yes-or-no-p "Save the new setting for svn-status-branch-list to disk? ")
5827 (svn-status-save-state)))
5829 (defun svn-browse-url (url)
5830 "Call `browse-url', using `svn-browse-url-function'."
5831 (let ((browse-url-browser-function (or svn-browse-url-function
5832 browse-url-browser-function)))
5835 ;; --------------------------------------------------------------------------------
5836 ;; svn status trac integration
5837 ;; --------------------------------------------------------------------------------
5838 (defun svn-trac-browse-wiki ()
5839 "Open the trac wiki view for the current svn repository."
5841 (unless svn-trac-project-root
5842 (svn-status-set-trac-project-root))
5843 (svn-browse-url (concat svn-trac-project-root "wiki")))
5845 (defun svn-trac-browse-timeline ()
5846 "Open the trac timeline view for the current svn repository."
5848 (unless svn-trac-project-root
5849 (svn-status-set-trac-project-root))
5850 (svn-browse-url (concat svn-trac-project-root "timeline")))
5852 (defun svn-trac-browse-roadmap ()
5853 "Open the trac roadmap view for the current svn repository."
5855 (unless svn-trac-project-root
5856 (svn-status-set-trac-project-root))
5857 (svn-browse-url (concat svn-trac-project-root "roadmap")))
5859 (defun svn-trac-browse-source ()
5860 "Open the trac source browser for the current svn repository."
5862 (unless svn-trac-project-root
5863 (svn-status-set-trac-project-root))
5864 (svn-browse-url (concat svn-trac-project-root "browser")))
5866 (defun svn-trac-browse-report (arg)
5867 "Open the trac report view for the current svn repository.
5868 When called with a prefix argument, display the given report number."
5870 (unless svn-trac-project-root
5871 (svn-status-set-trac-project-root))
5872 (svn-browse-url (concat svn-trac-project-root "report" (if (numberp arg) (format "/%s" arg) ""))))
5874 (defun svn-trac-browse-changeset (changeset-nr)
5875 "Show a changeset in the trac issue tracker."
5876 (interactive (list (read-number "Browse changeset number: " (number-at-point))))
5877 (unless svn-trac-project-root
5878 (svn-status-set-trac-project-root))
5879 (svn-browse-url (concat svn-trac-project-root "changeset/" (number-to-string changeset-nr))))
5881 (defun svn-trac-browse-ticket (ticket-nr)
5882 "Show a ticket in the trac issue tracker."
5883 (interactive (list (read-number "Browse ticket number: " (number-at-point))))
5884 (unless svn-trac-project-root
5885 (svn-status-set-trac-project-root))
5886 (svn-browse-url (concat svn-trac-project-root "ticket/" (number-to-string ticket-nr))))
5888 ;;;------------------------------------------------------------
5889 ;;; resolve conflicts using ediff
5890 ;;;------------------------------------------------------------
5891 (defun svn-resolve-conflicts-ediff (&optional name-A name-B)
5892 "Invoke ediff to resolve conflicts in the current buffer.
5893 The conflicts must be marked with rcsmerge conflict markers."
5896 (file-name (file-name-nondirectory buffer-file-name))
5897 (your-buffer (generate-new-buffer
5898 (concat "*" file-name
5899 " " (or name-A "WORKFILE") "*")))
5900 (other-buffer (generate-new-buffer
5901 (concat "*" file-name
5902 " " (or name-B "CHECKED-IN") "*")))
5903 (result-buffer (current-buffer)))
5905 (set-buffer your-buffer)
5907 (insert-buffer-substring result-buffer)
5908 (goto-char (point-min))
5909 (while (re-search-forward "^<<<<<<< .\\(mine\\|working\\)\n" nil t)
5912 (if (not (re-search-forward "^=======\n" nil t))
5913 (error "Malformed conflict marker"))
5915 (let ((start (point)))
5916 (if (not (re-search-forward "^>>>>>>> .\\(r[0-9]+\\|merge.*\\)\n" nil t))
5917 (error "Malformed conflict marker"))
5918 (delete-region start (point))))
5921 (kill-buffer your-buffer)
5922 (kill-buffer other-buffer)
5923 (error "No conflict markers found")))
5924 (set-buffer other-buffer)
5926 (insert-buffer-substring result-buffer)
5927 (goto-char (point-min))
5928 (while (re-search-forward "^<<<<<<< .\\(mine\\|working\\)\n" nil t)
5929 (let ((start (match-beginning 0)))
5930 (if (not (re-search-forward "^=======\n" nil t))
5931 (error "Malformed conflict marker"))
5932 (delete-region start (point))
5933 (if (not (re-search-forward "^>>>>>>> .\\(r[0-9]+\\|merge.*\\)\n" nil t))
5934 (error "Malformed conflict marker"))
5935 (replace-match "")))
5936 (let ((config (current-window-configuration))
5937 (ediff-default-variant 'default-B))
5941 (set-buffer (ediff-merge-buffers your-buffer other-buffer))
5943 ;; Ediff is now set up, and we are in the control buffer.
5944 ;; Do a few further adjustments and take precautions for exit.
5946 (make-local-variable 'svn-ediff-windows)
5947 (setq svn-ediff-windows config)
5948 (make-local-variable 'svn-ediff-result)
5949 (setq svn-ediff-result result-buffer)
5950 (make-local-variable 'ediff-quit-hook)
5951 (setq ediff-quit-hook
5953 (let ((buffer-A ediff-buffer-A)
5954 (buffer-B ediff-buffer-B)
5955 (buffer-C ediff-buffer-C)
5956 (result svn-ediff-result)
5957 (windows svn-ediff-windows))
5958 (ediff-cleanup-mess)
5961 (insert-buffer-substring buffer-C)
5962 (kill-buffer buffer-A)
5963 (kill-buffer buffer-B)
5964 (kill-buffer buffer-C)
5965 (set-window-configuration windows)
5966 (message "Conflict resolution finished; you may save the buffer"))))
5967 (message "Please resolve conflicts now; exit ediff when done")
5970 (defun svn-resolve-conflicts (filename)
5971 (let ((buff (find-file-noselect filename)))
5973 (progn (switch-to-buffer buff)
5974 (svn-resolve-conflicts-ediff))
5975 (error "can not open file %s" filename))))
5977 (defun svn-status-resolve-conflicts ()
5978 "Resolve conflict in the selected file"
5980 (let ((file-info (svn-status-get-line-information)))
5982 (= ?C (svn-status-line-info->filemark file-info))
5983 (svn-resolve-conflicts
5984 (svn-status-line-info->full-path file-info)))
5985 (error "can not resolve conflicts at this point"))))
5988 ;; --------------------------------------------------------------------------------
5989 ;; Working with branches
5990 ;; --------------------------------------------------------------------------------
5992 (defun svn-branch-select (&optional prompt)
5993 "Select a branch interactively from `svn-status-branch-list'"
5996 (setq prompt "Select branch: "))
5997 (let* ((branch (funcall svn-status-completing-read-function prompt svn-status-branch-list))
6000 (when (string-match "#\\(1#\\)?\\(.+\\)" branch)
6001 (setq directory (match-string 2 branch))
6002 (setq base-url (concat (svn-status-base-info->repository-root) "/" directory))
6004 (svn-status-parse-info t))
6005 (if (eq (length (match-string 1 branch)) 0)
6006 (setq branch base-url)
6007 (let ((svn-status-branch-list (svn-status-ls base-url t)))
6008 (setq branch (concat (svn-status-base-info->repository-root) "/"
6010 (svn-branch-select (format "Select branch from '%s': " directory)))))))
6013 (defun svn-branch-diff (branch1 branch2)
6014 "Show the diff between two svn repository urls.
6015 When called interactively, use `svn-branch-select' to choose two branches from `svn-status-branch-list'."
6017 (let* ((branch1 (svn-branch-select "svn diff branch1: "))
6018 (branch2 (svn-branch-select (format "svn diff %s against: " branch1))))
6019 (list branch1 branch2)))
6020 (svn-run t t 'diff "diff" svn-status-default-diff-arguments branch1 branch2))
6022 ;; --------------------------------------------------------------------------------
6023 ;; svnadmin interface
6024 ;; --------------------------------------------------------------------------------
6025 (defun svn-admin-create (dir)
6026 "Run svnadmin create DIR."
6027 (interactive (list (expand-file-name
6028 (svn-read-directory-name "Create a svn repository at: "
6029 svn-admin-default-create-directory nil nil))))
6030 (shell-command-to-string (concat "svnadmin create " dir))
6031 (setq svn-admin-last-repository-dir (concat "file://" dir))
6032 (message "Svn repository created at %s" dir)
6033 (run-hooks 'svn-admin-create-hook))
6035 ;; - Import an empty directory
6036 ;; cd to an empty directory
6037 ;; svn import -m "Initial import" . file:///home/stefan/svn_repos/WaldiConfig/trunk
6038 (defun svn-admin-create-trunk-directory ()
6039 "Import an empty trunk directory to `svn-admin-last-repository-dir'.
6040 Set `svn-admin-last-repository-dir' to the new created trunk url."
6042 (let ((empty-temp-dir-name (make-temp-name svn-status-temp-dir)))
6043 (make-directory empty-temp-dir-name t)
6044 (setq svn-admin-last-repository-dir (concat svn-admin-last-repository-dir "/trunk"))
6045 (svn-run nil t 'import "import" "-m" "Created trunk directory"
6046 empty-temp-dir-name svn-admin-last-repository-dir)
6047 (delete-directory empty-temp-dir-name)))
6049 (defun svn-admin-start-import ()
6050 "Start to import the current working directory in a subversion repository.
6051 The user is asked to perform the following two steps:
6052 1. Create a local repository
6053 2. Add a trunk directory to that repository
6055 After that step the empty base directory (either the root directory or
6056 the trunk directory of the selected repository) is checked out in the current
6059 (if (y-or-n-p "Create local repository? ")
6061 (call-interactively 'svn-admin-create)
6062 (when (y-or-n-p "Add a trunk directory? ")
6063 (svn-admin-create-trunk-directory)))
6064 (setq svn-admin-last-repository-dir (read-string "Repository Url: ")))
6065 (svn-checkout svn-admin-last-repository-dir "."))
6067 ;; --------------------------------------------------------------------------------
6068 ;; svn status profiling
6069 ;; --------------------------------------------------------------------------------
6070 ;;; Note about profiling psvn:
6071 ;; (load-library "elp")
6072 ;; M-x elp-reset-all
6073 ;; (elp-instrument-package "svn-")
6077 (defun svn-status-elp-init ()
6081 (elp-instrument-package "svn-")
6082 (message "Run the desired svn command (e.g. M-x svn-status), then use M-x elp-results."))
6084 (defun svn-status-last-commands (&optional string-prefix)
6085 "Return a string with the last executed svn commands"
6087 (unless string-prefix
6088 (setq string-prefix ""))
6089 (with-output-to-string
6090 (dolist (e (ring-elements svn-last-cmd-ring))
6091 (princ (format "%s%s: svn %s <%s>\n" string-prefix (nth 0 e) (mapconcat 'concat (nth 1 e) " ") (nth 2 e))))))
6093 ;; --------------------------------------------------------------------------------
6095 ;; --------------------------------------------------------------------------------
6096 (defun svn-insert-indented-lines (text)
6097 "Helper function to insert TEXT, indented by two characters."
6098 (dolist (line (split-string text "\n"))
6099 (insert (format " %s\n" line))))
6101 (defun svn-prepare-bug-report ()
6102 "Create the buffer *psvn-bug-report*. This buffer can be useful to debug problems with psvn.el"
6104 (let* ((last-output-buffer-name (or svn-status-last-output-buffer-name svn-process-buffer-name))
6105 (last-svn-cmd-output (with-current-buffer last-output-buffer-name
6106 (buffer-substring-no-properties (point-min) (point-max)))))
6107 (switch-to-buffer "*psvn-bug-report*")
6108 (delete-region (point-min) (point-max))
6109 (insert "This buffer holds some debug informations for psvn.el\n")
6110 (insert "Please enter a description of the observed and the wanted behaviour\n")
6111 (insert "and send it to the author (stefan@xsteve.at) to allow easier debugging\n\n")
6112 (insert "Revisions:\n")
6113 (svn-insert-indented-lines (svn-status-version))
6114 (insert "Language environment:\n")
6115 (dolist (elem (svn-process-environment))
6116 (when (member (car (split-string elem "=")) '("LC_MESSAGES" "LC_ALL" "LANG"))
6117 (insert (format " %s\n" elem))))
6118 (insert "\nLast svn commands:\n")
6119 (svn-insert-indented-lines (svn-status-last-commands))
6120 (insert (format "\nContent of the <%s> buffer:\n" last-output-buffer-name))
6121 (svn-insert-indented-lines last-svn-cmd-output)
6122 (goto-char (point-min))))
6124 ;; --------------------------------------------------------------------------------
6125 ;; Make it easier to reload psvn, if a distribution has an older version
6126 ;; Just add the following to your .emacs:
6127 ;; (svn-prepare-for-reload)
6128 ;; (load "/path/to/psvn.el")
6130 ;; Note the above will only work, if the loaded psvn.el has already the
6131 ;; function svn-prepare-for-reload
6132 ;; If this is not the case, do the following:
6133 ;; (load "/path/to/psvn.el");;make svn-prepare-for-reload available
6134 ;; (svn-prepare-for-reload)
6135 ;; (load "/path/to/psvn.el");; update the keybindings
6136 ;; --------------------------------------------------------------------------------
6138 (defvar svn-prepare-for-reload-dont-touch-list '() "A list of variables that should not be touched by `svn-prepare-for-reload'")
6139 (defvar svn-prepare-for-reload-variables-list '(svn-global-keymap svn-status-diff-mode-map svn-global-trac-map svn-status-mode-map
6140 svn-status-mode-property-map svn-status-mode-extension-map
6141 svn-status-mode-options-map svn-status-mode-trac-map svn-status-mode-branch-map
6142 svn-log-edit-mode-map svn-log-view-mode-map
6143 svn-log-view-popup-menu-map svn-info-mode-map svn-blame-mode-map svn-process-mode-map)
6144 "A list of variables that should be set to nil via M-x `svn-prepare-for-reload'")
6145 (defun svn-prepare-for-reload ()
6146 "This function resets some psvn.el variables to nil.
6147 It makes reloading a newer version of psvn.el easier, if for example the used
6148 GNU/Linux distribution uses an older version.
6150 The variables specified in `svn-prepare-for-reload-variables-list' will be reseted by this function.
6152 A variable will keep its value, if it is specified in `svn-prepare-for-reload-dont-touch-list'."
6154 (dolist (var svn-prepare-for-reload-variables-list)
6155 (unless (member var svn-prepare-for-reload-dont-touch-list)
6156 (message (format "Resetting value of %s to nil" var)))
6162 ;; indent-tabs-mode: nil
6164 ;;; psvn.el ends here