annotate lisp/vc-hg.el @ 79597:cfa45835a9e5

*** empty log message ***
author Eli Zaretskii <eliz@gnu.org>
date Sat, 22 Dec 2007 17:10:17 +0000
parents 27f00e50116a
children 2fe98820fa48
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
1 ;;; vc-hg.el --- VC backend for the mercurial version control system
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
2
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
3 ;; Copyright (C) 2006, 2007 Free Software Foundation, Inc.
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
4
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
5 ;; Author: Ivan Kanis
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
6 ;; Keywords: tools
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
7
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
8 ;; This file is part of GNU Emacs.
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
9
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
10 ;; GNU Emacs is free software; you can redistribute it and/or modify
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
11 ;; it under the terms of the GNU General Public License as published by
78236
9355f9b7bbff Switch license to GPLv3 or later.
Glenn Morris <rgm@gnu.org>
parents: 78211
diff changeset
12 ;; the Free Software Foundation; either version 3, or (at your option)
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
13 ;; any later version.
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
14
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
15 ;; GNU Emacs is distributed in the hope that it will be useful,
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
16 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
18 ;; GNU General Public License for more details.
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
19
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
21 ;; along with GNU Emacs; see the file COPYING. If not, write to the
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
22 ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
23 ;; Boston, MA 02110-1301, USA.
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
24
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
25 ;;; Commentary:
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
26
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
27 ;; This is a mercurial version control backend
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
28
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
29 ;;; Thanks:
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
30
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
31 ;;; Bugs:
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
32
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
33 ;;; Installation:
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
34
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
35 ;;; Todo:
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
36
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
37 ;; Implement the rest of the vc interface. See the comment at the
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
38 ;; beginning of vc.el. The current status is:
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
39
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
40 ;; FUNCTION NAME STATUS
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
41 ;; * registered (file) OK
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
42 ;; * state (file) OK
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
43 ;; - state-heuristic (file) ?? PROBABLY NOT NEEDED
78148
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
44 ;; - dir-state (dir) OK
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
45 ;; * workfile-version (file) OK
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
46 ;; - latest-on-branch-p (file) ??
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
47 ;; * checkout-model (file) OK
78167
252b7f091c04 (vc-hg-workfile-unchanged-p): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78166
diff changeset
48 ;; - workfile-unchanged-p (file) OK
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
49 ;; - mode-line-string (file) NOT NEEDED
78148
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
50 ;; - dired-state-info (file) OK
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
51 ;; STATE-CHANGING FUNCTIONS
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
52 ;; * register (file &optional rev comment) OK
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
53 ;; - init-version () NOT NEEDED
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
54 ;; - responsible-p (file) OK
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
55 ;; - could-register (file) OK
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
56 ;; - receive-file (file rev) ?? PROBABLY NOT NEEDED
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
57 ;; - unregister (file) COMMENTED OUT, MAY BE INCORRECT
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
58 ;; * checkin (file rev comment) OK
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
59 ;; * find-version (file rev buffer) OK
78148
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
60 ;; * checkout (file &optional editable rev) OK
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
61 ;; * revert (file &optional contents-done) OK
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
62 ;; - cancel-version (file editable) ?? PROBABLY NOT NEEDED
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
63 ;; - merge (file rev1 rev2) NEEDED
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
64 ;; - merge-news (file) NEEDED
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
65 ;; - steal-lock (file &optional version) NOT NEEDED
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
66 ;; HISTORY FUNCTIONS
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
67 ;; * print-log (file &optional buffer) OK
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
68 ;; - log-view-mode () OK
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
69 ;; - show-log-entry (version) NOT NEEDED, DEFAULT IS GOOD
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
70 ;; - wash-log (file) ??
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
71 ;; - logentry-check () NOT NEEDED
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
72 ;; - comment-history (file) NOT NEEDED
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
73 ;; - update-changelog (files) NOT NEEDED
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
74 ;; * diff (file &optional rev1 rev2 buffer) OK
78211
ce0473a5b031 (vc-hg-revision-completion-table): Temporarily comment
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78182
diff changeset
75 ;; - revision-completion-table (file) COMMENTED OUT AS A WORKAROUND FOR A BUG
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
76 ;; - diff-tree (dir &optional rev1 rev2) TEST IT
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
77 ;; - annotate-command (file buf &optional rev) OK
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
78 ;; - annotate-time () OK
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
79 ;; - annotate-current-time () ?? NOT NEEDED
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
80 ;; - annotate-extract-revision-at-line () OK
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
81 ;; SNAPSHOT SYSTEM
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
82 ;; - create-snapshot (dir name branchp) NEEDED (probably branch?)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
83 ;; - assign-name (file name) NOT NEEDED
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
84 ;; - retrieve-snapshot (dir name update) ?? NEEDED??
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
85 ;; MISCELLANEOUS
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
86 ;; - make-version-backups-p (file) ??
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
87 ;; - repository-hostname (dirname) ??
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
88 ;; - previous-version (file rev) OK
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
89 ;; - next-version (file rev) OK
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
90 ;; - check-headers () ??
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
91 ;; - clear-headers () ??
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
92 ;; - delete-file (file) TEST IT
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
93 ;; - rename-file (old new) OK
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
94 ;; - find-file-hook () PROBABLY NOT NEEDED
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
95 ;; - find-file-not-found-hook () PROBABLY NOT NEEDED
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
96
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
97 ;; Implement Stefan Monnier's advice:
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
98 ;; vc-hg-registered and vc-hg-state
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
99 ;; Both of those functions should be super extra careful to fail gracefully in
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
100 ;; unexpected circumstances. The reason this is important is that any error
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
101 ;; there will prevent the user from even looking at the file :-(
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
102 ;; Ideally, just like in vc-arch and vc-cvs, checking that the file is under
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
103 ;; mercurial's control and extracting the current revision should be done
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
104 ;; without even using `hg' (this way even if you don't have `hg' installed,
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
105 ;; Emacs is able to tell you this file is under mercurial's control).
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
106
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
107 ;;; History:
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
108 ;;
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
109
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
110 ;;; Code:
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
111
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
112 (eval-when-compile
78182
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
113 (require 'cl)
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
114 (require 'vc))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
115
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
116 ;;; Customization options
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
117
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
118 (defcustom vc-hg-global-switches nil
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
119 "*Global switches to pass to any Hg command."
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
120 :type '(choice (const :tag "None" nil)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
121 (string :tag "Argument String")
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
122 (repeat :tag "Argument List"
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
123 :value ("")
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
124 string))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
125 :version "22.2"
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
126 :group 'vc)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
127
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
128 ;;; State querying functions
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
129
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
130 ;;;###autoload (defun vc-hg-registered (file)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
131 ;;;###autoload "Return non-nil if FILE is registered with hg."
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
132 ;;;###autoload (if (vc-find-root file ".hg") ; short cut
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
133 ;;;###autoload (progn
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
134 ;;;###autoload (load "vc-hg")
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
135 ;;;###autoload (vc-hg-registered file))))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
136
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
137 ;; Modelled after the similar function in vc-bzr.el
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
138 (defun vc-hg-registered (file)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
139 "Return non-nil if FILE is registered with hg."
78166
516805bc7988 (vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78148
diff changeset
140 (when (vc-hg-root file) ; short cut
78363
9b9e30a9b135 * vc-hg.el (vc-hg-registered): Set the vc-state property.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78359
diff changeset
141 (vc-file-setprop file 'vc-state (vc-hg-state file)))) ; expensive
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
142
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
143 (defun vc-hg-state (file)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
144 "Hg-specific version of `vc-state'."
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
145 (let*
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
146 ((status nil)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
147 (out
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
148 (with-output-to-string
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
149 (with-current-buffer
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
150 standard-output
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
151 (setq status
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
152 (condition-case nil
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
153 ;; Ignore all errors.
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
154 (call-process
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
155 "hg" nil t nil "--cwd" (file-name-directory file)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
156 "status" (file-name-nondirectory file))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
157 ;; Some problem happened. E.g. We can't find an `hg'
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
158 ;; executable.
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
159 (error nil)))))))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
160 (when (eq 0 status)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
161 (if (eq 0 (length out)) 'up-to-date
78166
516805bc7988 (vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78148
diff changeset
162 (when (null (string-match ".*: No such file or directory$" out))
516805bc7988 (vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78148
diff changeset
163 (let ((state (aref out 0)))
516805bc7988 (vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78148
diff changeset
164 (cond
516805bc7988 (vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78148
diff changeset
165 ((eq state ?A) 'edited)
516805bc7988 (vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78148
diff changeset
166 ((eq state ?M) 'edited)
516805bc7988 (vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78148
diff changeset
167 ((eq state ?R) nil)
516805bc7988 (vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78148
diff changeset
168 ((eq state ??) nil)
516805bc7988 (vc-hg-registered): Replace if with when.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78148
diff changeset
169 (t 'up-to-date))))))))
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
170
78148
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
171 (defun vc-hg-dir-state (dir)
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
172 (with-temp-buffer
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
173 (vc-hg-command (current-buffer) nil nil "status")
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
174 (goto-char (point-min))
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
175 (let ((status-char nil)
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
176 (file nil))
78182
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
177 (while (not (eobp))
78148
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
178 (setq status-char (char-after))
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
179 (setq file
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
180 (expand-file-name
78182
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
181 (buffer-substring-no-properties (+ (point) 2)
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
182 (line-end-position))))
78148
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
183 (cond
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
184 ;; The rest of the possible states in "hg status" output:
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
185 ;; R = removed
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
186 ;; ! = deleted, but still tracked
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
187 ;; ? = not tracked
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
188 ;; should not show up in vc-dired, so don't deal with them
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
189 ;; here.
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
190 ((eq status-char ?A)
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
191 (vc-file-setprop file 'vc-workfile-version "0")
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
192 (vc-file-setprop file 'vc-state 'edited))
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
193 ((eq status-char ?M)
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
194 (vc-file-setprop file 'vc-state 'edited))
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
195 ((eq status-char ??)
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
196 (vc-file-setprop file 'vc-backend 'none)
78182
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
197 (vc-file-setprop file 'vc-state 'nil)))
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
198 (forward-line)))))
78148
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
199
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
200 (defun vc-hg-workfile-version (file)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
201 "Hg-specific version of `vc-workfile-version'."
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
202 (let*
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
203 ((status nil)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
204 (out
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
205 (with-output-to-string
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
206 (with-current-buffer
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
207 standard-output
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
208 (setq status
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
209 (condition-case nil
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
210 ;; Ignore all errors.
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
211 (call-process
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
212 "hg" nil t nil "--cwd" (file-name-directory file)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
213 "log" "-l1" (file-name-nondirectory file))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
214 ;; Some problem happened. E.g. We can't find an `hg'
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
215 ;; executable.
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
216 (error nil)))))))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
217 (when (eq 0 status)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
218 (if (string-match "changeset: *\\([0-9]*\\)" out)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
219 (match-string 1 out)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
220 "0"))))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
221
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
222 ;;; History functions
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
223
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
224 (defun vc-hg-print-log(file &optional buffer)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
225 "Get change log associated with FILE."
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
226 ;; `log-view-mode' needs to have the file name in order to function
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
227 ;; correctly. "hg log" does not print it, so we insert it here by
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
228 ;; hand.
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
229
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
230 ;; `vc-do-command' creates the buffer, but we need it before running
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
231 ;; the command.
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
232 (vc-setup-buffer buffer)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
233 ;; If the buffer exists from a previous invocation it might be
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
234 ;; read-only.
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
235 (let ((inhibit-read-only t))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
236 (with-current-buffer
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
237 buffer
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
238 (insert "File: " (file-name-nondirectory file) "\n")))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
239 (vc-hg-command
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
240 buffer
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
241 (if (and (vc-stay-local-p file) (fboundp 'start-process)) 'async 0)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
242 file "log"))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
243
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
244 (defvar log-view-message-re)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
245 (defvar log-view-file-re)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
246 (defvar log-view-font-lock-keywords)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
247
78404
27f00e50116a Change capitalization of VC backend names for new backends
Miles Bader <miles@gnu.org>
parents: 78363
diff changeset
248 (define-derived-mode vc-hg-log-view-mode log-view-mode "Hg-Log-View"
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
249 (require 'add-log) ;; we need the faces add-log
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
250 ;; Don't have file markers, so use impossible regexp.
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
251 (set (make-local-variable 'log-view-file-re) "^File:[ \t]+\\(.+\\)")
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
252 (set (make-local-variable 'log-view-message-re)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
253 "^changeset:[ \t]*\\([0-9]+\\):\\(.+\\)")
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
254 (set (make-local-variable 'log-view-font-lock-keywords)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
255 (append
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
256 log-view-font-lock-keywords
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
257 ;; Handle the case:
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
258 ;; user: foo@bar
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
259 '(("^user:[ \t]+\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)"
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
260 (1 'change-log-email))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
261 ;; Handle the case:
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
262 ;; user: FirstName LastName <foo@bar>
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
263 ("^user:[ \t]+\\([^<(]+?\\)[ \t]*[(<]\\([A-Za-z0-9_.+-]+@[A-Za-z0-9_.-]+\\)[>)]"
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
264 (1 'change-log-name)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
265 (2 'change-log-email))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
266 ("^date: \\(.+\\)" (1 'change-log-date))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
267 ("^summary:[ \t]+\\(.+\\)" (1 'log-view-message))))))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
268
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
269 (defun vc-hg-diff (file &optional oldvers newvers buffer)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
270 "Get a difference report using hg between two versions of FILE."
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
271 (let ((working (vc-workfile-version file)))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
272 (if (and (equal oldvers working) (not newvers))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
273 (setq oldvers nil))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
274 (if (and (not oldvers) newvers)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
275 (setq oldvers working))
78182
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
276 (apply #'vc-hg-command (or buffer "*vc-diff*") nil
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
277 (file-name-nondirectory file)
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
278 "--cwd" (file-name-directory file)
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
279 "diff"
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
280 (append
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
281 (if oldvers
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
282 (if newvers
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
283 (list "-r" oldvers "-r" newvers)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
284 (list "-r" oldvers))
78182
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
285 (list ""))))))
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
286
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
287 (defun vc-hg-revision-table (file)
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
288 (let ((default-directory (file-name-directory file)))
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
289 (with-temp-buffer
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
290 (vc-hg-command t nil file "log" "--template" "{rev} ")
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
291 (split-string
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
292 (buffer-substring-no-properties (point-min) (point-max))))))
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
293
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
294 ;; Modelled after the similar function in vc-cvs.el
78359
2dd5d799a16d * vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78236
diff changeset
295 (defun vc-hg-revision-completion-table (file)
2dd5d799a16d * vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78236
diff changeset
296 (lexical-let ((file file)
2dd5d799a16d * vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78236
diff changeset
297 table)
2dd5d799a16d * vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78236
diff changeset
298 (setq table (lazy-completion-table
2dd5d799a16d * vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78236
diff changeset
299 table (lambda () (vc-hg-revision-table file))))
2dd5d799a16d * vc-git.el: (vc-directory-exclusion-list, vc-handled-backends):
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78236
diff changeset
300 table))
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
301
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
302 (defalias 'vc-hg-diff-tree 'vc-hg-diff)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
303
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
304 (defun vc-hg-annotate-command (file buffer &optional version)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
305 "Execute \"hg annotate\" on FILE, inserting the contents in BUFFER.
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
306 Optional arg VERSION is a version to annotate from."
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
307 (vc-hg-command buffer 0 file "annotate" "-d" "-n" (if version (concat "-r" version)))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
308 (with-current-buffer buffer
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
309 (goto-char (point-min))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
310 (re-search-forward "^[0-9]")
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
311 (delete-region (point-min) (1- (point)))))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
312
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
313
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
314 ;; The format for one line output by "hg annotate -d -n" looks like this:
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
315 ;;215 Wed Jun 20 21:22:58 2007 -0700: CONTENTS
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
316 ;; i.e: VERSION_NUMBER DATE: CONTENTS
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
317 (defconst vc-hg-annotate-re "^[ \t]*\\([0-9]+\\) \\(.\\{30\\}\\): ")
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
318
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
319 (defun vc-hg-annotate-time ()
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
320 (when (looking-at vc-hg-annotate-re)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
321 (goto-char (match-end 0))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
322 (vc-annotate-convert-time
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
323 (date-to-time (match-string-no-properties 2)))))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
324
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
325 (defun vc-hg-annotate-extract-revision-at-line ()
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
326 (save-excursion
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
327 (beginning-of-line)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
328 (if (looking-at vc-hg-annotate-re) (match-string-no-properties 1))))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
329
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
330 (defun vc-hg-previous-version (file rev)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
331 (let ((newrev (1- (string-to-number rev))))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
332 (when (>= newrev 0)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
333 (number-to-string newrev))))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
334
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
335 (defun vc-hg-next-version (file rev)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
336 (let ((newrev (1+ (string-to-number rev)))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
337 (tip-version
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
338 (with-temp-buffer
78182
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
339 (vc-hg-command t 0 nil "tip")
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
340 (goto-char (point-min))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
341 (re-search-forward "^changeset:[ \t]*\\([0-9]+\\):")
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
342 (string-to-number (match-string-no-properties 1)))))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
343 ;; We don't want to exceed the maximum possible version number, ie
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
344 ;; the tip version.
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
345 (when (<= newrev tip-version)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
346 (number-to-string newrev))))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
347
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
348 ;; Modelled after the similar function in vc-bzr.el
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
349 (defun vc-hg-delete-file (file)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
350 "Delete FILE and delete it in the hg repository."
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
351 (condition-case ()
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
352 (delete-file file)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
353 (file-error nil))
78182
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
354 (vc-hg-command nil 0 file "remove" "--after" "--force"))
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
355
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
356 ;; Modelled after the similar function in vc-bzr.el
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
357 (defun vc-hg-rename-file (old new)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
358 "Rename file from OLD to NEW using `hg mv'."
78182
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
359 (vc-hg-command nil 0 new old "mv"))
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
360
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
361 (defun vc-hg-register (file &optional rev comment)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
362 "Register FILE under hg.
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
363 REV is ignored.
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
364 COMMENT is ignored."
78182
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
365 (vc-hg-command nil 0 file "add"))
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
366
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
367 (defalias 'vc-hg-responsible-p 'vc-hg-root)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
368
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
369 ;; Modelled after the similar function in vc-bzr.el
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
370 (defun vc-hg-could-register (file)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
371 "Return non-nil if FILE could be registered under hg."
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
372 (and (vc-hg-responsible-p file) ; shortcut
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
373 (condition-case ()
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
374 (with-temp-buffer
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
375 (vc-hg-command t nil file "add" "--dry-run"))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
376 ;; The command succeeds with no output if file is
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
377 ;; registered.
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
378 (error))))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
379
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
380 ;; XXX This would remove the file. Is that correct?
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
381 ;; (defun vc-hg-unregister (file)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
382 ;; "Unregister FILE from hg."
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
383 ;; (vc-hg-command nil nil file "remove"))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
384
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
385 (defun vc-hg-checkin (file rev comment)
78404
27f00e50116a Change capitalization of VC backend names for new backends
Miles Bader <miles@gnu.org>
parents: 78363
diff changeset
386 "Hg-specific version of `vc-backend-checkin'.
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
387 REV is ignored."
78211
ce0473a5b031 (vc-hg-revision-completion-table): Temporarily comment
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78182
diff changeset
388 (vc-hg-command nil 0 file "commit" "-m" comment))
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
389
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
390 (defun vc-hg-find-version (file rev buffer)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
391 (let ((coding-system-for-read 'binary)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
392 (coding-system-for-write 'binary))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
393 (if rev
78182
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
394 (vc-hg-command buffer 0 file "cat" "-r" rev)
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
395 (vc-hg-command buffer 0 file "cat"))))
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
396
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
397 ;; Modelled after the similar function in vc-bzr.el
78148
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
398 (defun vc-hg-checkout (file &optional editable rev)
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
399 "Retrieve a revision of FILE.
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
400 EDITABLE is ignored.
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
401 REV is the revision to check out into WORKFILE."
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
402 (let ((coding-system-for-read 'binary)
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
403 (coding-system-for-write 'binary))
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
404 (with-current-buffer (or (get-file-buffer file) (current-buffer))
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
405 (if rev
78182
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
406 (vc-hg-command t 0 file "cat" "-r" rev)
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
407 (vc-hg-command t 0 file "cat")))))
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
408
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
409 (defun vc-hg-checkout-model (file)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
410 'implicit)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
411
78167
252b7f091c04 (vc-hg-workfile-unchanged-p): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78166
diff changeset
412 ;; Modelled after the similar function in vc-bzr.el
252b7f091c04 (vc-hg-workfile-unchanged-p): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78166
diff changeset
413 (defun vc-hg-workfile-unchanged-p (file)
252b7f091c04 (vc-hg-workfile-unchanged-p): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78166
diff changeset
414 (eq 'up-to-date (vc-hg-state file)))
252b7f091c04 (vc-hg-workfile-unchanged-p): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78166
diff changeset
415
78148
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
416 (defun vc-hg-dired-state-info (file)
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
417 "Hg-specific version of `vc-dired-state-info'."
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
418 (let ((hg-state (vc-state file)))
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
419 (if (eq hg-state 'edited)
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
420 (if (equal (vc-workfile-version file) "0")
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
421 "(added)" "(modified)")
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
422 ;; fall back to the default VC representation
78404
27f00e50116a Change capitalization of VC backend names for new backends
Miles Bader <miles@gnu.org>
parents: 78363
diff changeset
423 (vc-default-dired-state-info 'Hg file))))
78148
9cbb2ce8ec8c (vc-hg-state): Handle removed files.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78086
diff changeset
424
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
425 ;; Modelled after the similar function in vc-bzr.el
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
426 (defun vc-hg-revert (file &optional contents-done)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
427 (unless contents-done
78182
86c8d81f944f (vc-hg-diff): Use vc-hg-command.
Dan Nicolaescu <dann@ics.uci.edu>
parents: 78167
diff changeset
428 (with-temp-buffer (vc-hg-command t 0 file "revert"))))
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
429
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
430 ;;; Internal functions
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
431
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
432 (defun vc-hg-command (buffer okstatus file &rest flags)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
433 "A wrapper around `vc-do-command' for use in vc-hg.el.
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
434 The difference to vc-do-command is that this function always invokes `hg',
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
435 and that it passes `vc-hg-global-switches' to it before FLAGS."
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
436 (apply 'vc-do-command buffer okstatus "hg" file
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
437 (if (stringp vc-hg-global-switches)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
438 (cons vc-hg-global-switches flags)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
439 (append vc-hg-global-switches
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
440 flags))))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
441
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
442 (defun vc-hg-root (file)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
443 (vc-find-root file ".hg"))
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
444
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
445 (provide 'vc-hg)
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
446
78086
9a13508185dc Add arch tagline
Miles Bader <miles@gnu.org>
parents: 78075
diff changeset
447 ;; arch-tag: bd094dc5-715a-434f-a331-37b9fb7cd954
78075
dbe1fd006899 vc-hg.el: New file.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
diff changeset
448 ;;; vc-hg.el ends here