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