Mercurial > emacs
annotate lisp/vc-hg.el @ 81974:a7c29f19fb83
(top-level): Fix typo in final comment introduced
with last change.
author | Martin Rudalics <rudalics@gmx.at> |
---|---|
date | Thu, 19 Jul 2007 06:30:39 +0000 |
parents | ba5a7f46413b |
children | d4b8336cd8f5 |
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 |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
7 ;; Version: 1889 |
81479
2d50f85a03de
Change license wording to match the rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
81476
diff
changeset
|
8 |
2d50f85a03de
Change license wording to match the rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
81476
diff
changeset
|
9 ;; 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
|
10 |
2d50f85a03de
Change license wording to match the rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
81476
diff
changeset
|
11 ;; GNU Emacs is free software; you can redistribute it and/or modify |
81474 | 12 ;; 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
|
13 ;; 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
|
14 ;; any later version. |
2d50f85a03de
Change license wording to match the rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
81476
diff
changeset
|
15 |
2d50f85a03de
Change license wording to match the rest of Emacs.
Glenn Morris <rgm@gnu.org>
parents:
81476
diff
changeset
|
16 ;; 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
|
17 ;; 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
|
18 ;; 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
|
19 ;; 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
|
20 |
81474 | 21 ;; 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
|
22 ;; 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
|
23 ;; 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
|
24 ;; Boston, MA 02110-1301, USA. |
81474 | 25 |
26 ;;; Commentary: | |
27 | |
28 ;; This is a mercurial version control backend | |
29 | |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
30 ;;; Thanks: |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
31 |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
32 ;;; Bugs: |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
33 |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
34 ;;; Installation: |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
35 |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
36 ;;; Todo: |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
37 |
81726
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
38 ;; 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
|
39 ;; beginning of vc.el. The current status is: |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
40 |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
41 ;; FUNCTION NAME STATUS |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
42 ;; * registered (file) OK |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
43 ;; * state (file) OK |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
44 ;; - state-heuristic (file) ?? PROBABLY NOT NEEDED |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
45 ;; - dir-state (dir) NEEDED |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
46 ;; * workfile-version (file) OK |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
47 ;; - latest-on-branch-p (file) ?? |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
48 ;; * checkout-model (file) OK |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
49 ;; - workfile-unchanged-p (file) ?? |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
50 ;; - mode-line-string (file) NOT NEEDED |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
51 ;; - dired-state-info (file) NEEDED |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
52 ;; 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
|
53 ;; * register (files &optional rev comment) OK |
81726
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
54 ;; - init-version () NOT NEEDED |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
55 ;; - responsible-p (file) OK |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
56 ;; - could-register (file) OK |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
57 ;; - receive-file (file rev) ?? PROBABLY NOT NEEDED |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
58 ;; - 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
|
59 ;; * checkin (files rev comment) OK |
81726
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
60 ;; * find-version (file rev buffer) OK |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
61 ;; * checkout (file &optional editable rev) NOT NEEDED, COMMENTED OUT |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
62 ;; * 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
|
63 ;; - rollback (files) ?? PROBABLY NOT NEEDED |
81726
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
64 ;; - merge (file rev1 rev2) NEEDED |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
65 ;; - merge-news (file) NEEDED |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
66 ;; - steal-lock (file &optional version) NOT NEEDED |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
67 ;; 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
|
68 ;; * print-log (files &optional buffer) OK |
81726
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
69 ;; - log-view-mode () OK |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
70 ;; - 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
|
71 ;; - wash-log (file) ?? |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
72 ;; - logentry-check () NOT NEEDED |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
73 ;; - comment-history (file) NOT NEEDED |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
74 ;; - 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
|
75 ;; * diff (files &optional rev1 rev2 buffer) OK |
81726
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
76 ;; - revision-completion-table (file) ?? |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
77 ;; - diff-tree (dir &optional rev1 rev2) TEST IT |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
78 ;; - annotate-command (file buf &optional rev) OK |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
79 ;; - annotate-time () OK |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
80 ;; - annotate-current-time () ?? NOT NEEDED |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
81 ;; - annotate-extract-revision-at-line () OK |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
82 ;; SNAPSHOT SYSTEM |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
83 ;; - create-snapshot (dir name branchp) NEEDED (probably branch?) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
84 ;; - assign-name (file name) NOT NEEDED |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
85 ;; - retrieve-snapshot (dir name update) ?? NEEDED?? |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
86 ;; MISCELLANEOUS |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
87 ;; - make-version-backups-p (file) ?? |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
88 ;; - repository-hostname (dirname) ?? |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
89 ;; - previous-version (file rev) OK |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
90 ;; - next-version (file rev) OK |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
91 ;; - check-headers () ?? |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
92 ;; - clear-headers () ?? |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
93 ;; - delete-file (file) TEST IT |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
94 ;; - rename-file (old new) OK |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
95 ;; - find-file-hook () PROBABLY NOT NEEDED |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
96 ;; - find-file-not-found-hook () PROBABLY NOT NEEDED |
81474 | 97 |
81566
0e2a83705e5f
(vc-hg-registered): Add an autoloaded version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81564
diff
changeset
|
98 ;; Implement Stefan Monnier's advice: |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
99 ;; vc-hg-registered and vc-hg-state |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
100 ;; 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
|
101 ;; 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
|
102 ;; 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
|
103 ;; 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
|
104 ;; 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
|
105 ;; 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
|
106 ;; Emacs is able to tell you this file is under mercurial's control). |
81474 | 107 |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
108 ;;; History: |
81566
0e2a83705e5f
(vc-hg-registered): Add an autoloaded version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81564
diff
changeset
|
109 ;; |
81474 | 110 |
111 ;;; Code: | |
112 | |
113 (eval-when-compile | |
114 (require 'vc)) | |
115 | |
116 ;;; Customization options | |
117 | |
118 (defcustom vc-hg-global-switches nil | |
119 "*Global switches to pass to any Hg command." | |
120 :type '(choice (const :tag "None" nil) | |
121 (string :tag "Argument String") | |
122 (repeat :tag "Argument List" | |
123 :value ("") | |
124 string)) | |
81726
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
125 :version "22.2" |
81474 | 126 :group 'vc) |
127 | |
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
|
128 |
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
|
129 ;;; 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
|
130 |
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
|
131 (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
|
132 '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
|
133 |
81474 | 134 ;;; State querying functions |
135 | |
81566
0e2a83705e5f
(vc-hg-registered): Add an autoloaded version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81564
diff
changeset
|
136 ;;;###autoload (defun vc-hg-registered (file) |
0e2a83705e5f
(vc-hg-registered): Add an autoloaded version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81564
diff
changeset
|
137 ;;;###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
|
138 ;;;###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
|
139 ;;;###autoload (progn |
0e2a83705e5f
(vc-hg-registered): Add an autoloaded version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81564
diff
changeset
|
140 ;;;###autoload (load "vc-hg") |
0e2a83705e5f
(vc-hg-registered): Add an autoloaded version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81564
diff
changeset
|
141 ;;;###autoload (vc-hg-registered file)))) |
0e2a83705e5f
(vc-hg-registered): Add an autoloaded version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81564
diff
changeset
|
142 |
0e2a83705e5f
(vc-hg-registered): Add an autoloaded version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81564
diff
changeset
|
143 ;; Modelled after the similar function in vc-bzr.el |
81474 | 144 (defun vc-hg-registered (file) |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
145 "Return non-nil if FILE is registered with hg." |
81726
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
146 (if (vc-hg-root file) ; short cut |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
147 (vc-hg-state file))) ; expensive |
81474 | 148 |
149 (defun vc-hg-state (file) | |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
150 "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
|
151 (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
|
152 ((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
|
153 (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
|
154 (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
|
155 (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
|
156 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
|
157 (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
|
158 (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
|
159 ;; 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
|
160 (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
|
161 "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
|
162 "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
|
163 ;; 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
|
164 ;; 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
|
165 (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
|
166 (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
|
167 (if (eq 0 (length out)) 'up-to-date |
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 (let ((state (aref out 0))) |
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 (cond |
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 ((eq state ?M) 'edited) |
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 ((eq state ?A) 'edited) |
fc97b55f9678
* vc-hg.el (vc-hg-internal-status): Inline in `vc-hg-state', the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81575
diff
changeset
|
172 ((eq state ?P) 'needs-patch) |
fc97b55f9678
* vc-hg.el (vc-hg-internal-status): Inline in `vc-hg-state', the
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81575
diff
changeset
|
173 ((eq state ??) 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
|
174 (t 'up-to-date))))))) |
81474 | 175 |
176 (defun vc-hg-workfile-version (file) | |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
177 "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
|
178 (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
|
179 ((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
|
180 (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
|
181 (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
|
182 (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
|
183 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
|
184 (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
|
185 (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
|
186 ;; 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
|
187 (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
|
188 "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
|
189 "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
|
190 ;; 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
|
191 ;; 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
|
192 (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
|
193 (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
|
194 (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
|
195 (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
|
196 "0")))) |
81474 | 197 |
198 ;;; History functions | |
199 | |
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
|
200 (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
|
201 "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
|
202 ;; `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
|
203 ;; 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
|
204 ;; hand. |
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
205 |
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
206 ;; `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
|
207 ;; the command. |
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
208 (vc-setup-buffer buffer) |
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
209 ;; 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
|
210 ;; read-only. |
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
211 (let ((inhibit-read-only t)) |
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
212 (with-current-buffer |
99961edaa9c1
(vc-hg-print-log): Insert the file name.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81538
diff
changeset
|
213 buffer |
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
|
214 (insert "File: " (vc-delistify (mapcar (lambda (file) (file-name-nondirectory file)) files)) "\n"))) |
81474 | 215 (vc-hg-command |
216 buffer | |
217 (if (and (vc-stay-local-p file) (fboundp 'start-process)) 'async 0) | |
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
|
218 files "log")) |
81474 | 219 |
81538
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
220 (defvar log-view-message-re) |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
221 (defvar log-view-file-re) |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
222 (defvar log-view-font-lock-keywords) |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
223 |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
224 (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
|
225 (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
|
226 ;; 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
|
227 (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
|
228 (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
|
229 "^changeset:[ \t]*\\([0-9]+\\):\\(.+\\)") |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
230 (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
|
231 (append |
81575
cea1e05b3c83
* vc-hg.el (vc-hg-log-view-mode): Revert incorrect change.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81572
diff
changeset
|
232 log-view-font-lock-keywords |
81538
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
233 ;; Handle the case: |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
234 ;; user: foo@bar |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
235 '(("^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
|
236 (1 'change-log-email)) |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
237 ;; Handle the case: |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
238 ;; user: FirstName LastName <foo@bar> |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
239 ("^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
|
240 (1 'change-log-name) |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
241 (2 'change-log-email)) |
ac8e3d72984f
(vc-hg-log-view-mode): New mode.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81526
diff
changeset
|
242 ("^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
|
243 ("^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
|
244 |
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
|
245 (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
|
246 "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
|
247 (let ((working (vc-workfile-version (car files)))) |
81526 | 248 (if (and (equal oldvers working) (not newvers)) |
249 (setq oldvers nil)) | |
250 (if (and (not oldvers) newvers) | |
251 (setq oldvers working)) | |
252 (apply 'call-process "hg" nil (or buffer "*vc-diff*") nil | |
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
|
253 "--cwd" (file-name-directory (car files)) "diff" |
81566
0e2a83705e5f
(vc-hg-registered): Add an autoloaded version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81564
diff
changeset
|
254 (append |
81526 | 255 (if oldvers |
256 (if newvers | |
257 (list "-r" oldvers "-r" newvers) | |
258 (list "-r" oldvers)) | |
259 (list "")) | |
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
|
260 (mapcar (lambda (file) (file-name-nondirectory file)) files))))) |
81526 | 261 |
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
|
262 (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
|
263 (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
|
264 |
81526 | 265 (defun vc-hg-annotate-command (file buffer &optional version) |
266 "Execute \"hg annotate\" on FILE, inserting the contents in BUFFER. | |
267 Optional arg VERSION is a version to annotate from." | |
268 (vc-hg-command buffer 0 file "annotate" "-d" "-n" (if version (concat "-r" version))) | |
269 (with-current-buffer buffer | |
270 (goto-char (point-min)) | |
271 (re-search-forward "^[0-9]") | |
272 (delete-region (point-min) (1- (point))))) | |
273 | |
274 | |
81566
0e2a83705e5f
(vc-hg-registered): Add an autoloaded version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81564
diff
changeset
|
275 ;; 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
|
276 ;;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
|
277 ;; i.e: VERSION_NUMBER DATE: CONTENTS |
81526 | 278 (defconst vc-hg-annotate-re "^[ \t]*\\([0-9]+\\) \\(.\\{30\\}\\): ") |
279 | |
280 (defun vc-hg-annotate-time () | |
281 (when (looking-at vc-hg-annotate-re) | |
282 (goto-char (match-end 0)) | |
81566
0e2a83705e5f
(vc-hg-registered): Add an autoloaded version.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
81564
diff
changeset
|
283 (vc-annotate-convert-time |
81526 | 284 (date-to-time (match-string-no-properties 2))))) |
285 | |
286 (defun vc-hg-annotate-extract-revision-at-line () | |
287 (save-excursion | |
288 (beginning-of-line) | |
289 (if (looking-at vc-hg-annotate-re) (match-string-no-properties 1)))) | |
290 | |
291 (defun vc-hg-previous-version (file rev) | |
292 (let ((newrev (1- (string-to-number rev)))) | |
293 (when (>= newrev 0) | |
294 (number-to-string newrev)))) | |
81474 | 295 |
81726
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
296 (defun vc-hg-next-version (file rev) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
297 (let ((newrev (1+ (string-to-number rev))) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
298 (tip-version |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
299 (with-temp-buffer |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
300 (vc-hg-command t nil nil "tip") |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
301 (goto-char (point-min)) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
302 (re-search-forward "^changeset:[ \t]*\\([0-9]+\\):") |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
303 (string-to-number (match-string-no-properties 1))))) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
304 ;; 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
|
305 ;; the tip version. |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
306 (when (<= newrev tip-version) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
307 (number-to-string newrev)))) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
308 |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
309 ;; 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
|
310 (defun vc-hg-delete-file (file) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
311 "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
|
312 (condition-case () |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
313 (delete-file file) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
314 (file-error nil)) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
315 (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
|
316 |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
317 ;; 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
|
318 (defun vc-hg-rename-file (old new) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
319 "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
|
320 (vc-hg-command nil nil new old "mv")) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
321 |
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
|
322 (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
|
323 "Register FILES under hg. |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
324 REV is ignored. |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
325 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
|
326 (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
|
327 |
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
|
328 (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
|
329 "Create a new Mercurial 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
|
330 (vc-do-command nil 0 "svn" '("init"))) |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
331 |
81726
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
332 (defalias 'vc-hg-responsible-p 'vc-hg-root) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
333 |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
334 ;; 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
|
335 (defun vc-hg-could-register (file) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
336 "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
|
337 (and (vc-hg-responsible-p file) ; shortcut |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
338 (condition-case () |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
339 (with-temp-buffer |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
340 (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
|
341 ;; 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
|
342 ;; registered. |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
343 (error)))) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
344 |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
345 ;; 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
|
346 ;; (defun vc-hg-unregister (file) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
347 ;; "Unregister FILE from hg." |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
348 ;; (vc-hg-command nil nil file "remove")) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
349 |
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
|
350 (defun vc-hg-checkin (files rev comment) |
81526 | 351 "HG-specific version of `vc-backend-checkin'. |
352 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
|
353 (vc-hg-command nil nil files "commit" "-m" comment)) |
81526 | 354 |
81726
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
355 (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
|
356 (let ((coding-system-for-read 'binary) |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
357 (coding-system-for-write 'binary)) |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
358 (if rev |
81726
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
359 (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
|
360 (vc-hg-command buffer nil file "cat")))) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
361 |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
362 ;; 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
|
363 ;; This should not be needed, `vc-hg-find-version' provides the same |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
364 ;; functionality. |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
365 ;; (defun vc-hg-checkout (file &optional editable rev workfile) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
366 ;; "Retrieve a revision of FILE into a WORKFILE. |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
367 ;; EDITABLE is ignored. |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
368 ;; REV is the revision to check out into WORKFILE." |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
369 ;; (unless workfile |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
370 ;; (setq workfile (vc-version-backup-file-name file rev))) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
371 ;; (let ((coding-system-for-read 'binary) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
372 ;; (coding-system-for-write 'binary)) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
373 ;; (with-temp-file workfile |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
374 ;; (if rev |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
375 ;; (vc-hg-command t nil file "cat" "-r" rev) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
376 ;; (vc-hg-command t nil file "cat"))))) |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
377 |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
378 (defun vc-hg-checkout-model (file) |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
379 'implicit) |
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
380 |
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
|
381 ;; 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
|
382 (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
|
383 (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
|
384 (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
|
385 |
81474 | 386 ;;; Internal functions |
387 | |
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
|
388 (defun vc-hg-command (buffer okstatus file-or-list &rest flags) |
81474 | 389 "A wrapper around `vc-do-command' for use in vc-hg.el. |
390 The difference to vc-do-command is that this function always invokes `hg', | |
391 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
|
392 (apply 'vc-do-command buffer okstatus "hg" file-or-list |
81474 | 393 (if (stringp vc-hg-global-switches) |
394 (cons vc-hg-global-switches flags) | |
395 (append vc-hg-global-switches | |
396 flags)))) | |
397 | |
81726
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
398 (defun vc-hg-root (file) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
399 (vc-find-root file ".hg")) |
b7c76df62fba
(vc-hg-root): New function.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81709
diff
changeset
|
400 |
81474 | 401 (provide 'vc-hg) |
402 | |
81757 | 403 ;; arch-tag: bd094dc5-715a-434f-a331-37b9fb7cd954 |
81476
3dedb2297b98
(vc-hg-global-switches): Simplify.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
81474
diff
changeset
|
404 ;;; vc-hg.el ends here |