diff options
| author | Dan Nicolaescu | 2007-07-06 21:14:21 +0000 |
|---|---|---|
| committer | Dan Nicolaescu | 2007-07-06 21:14:21 +0000 |
| commit | a07e665b66031b15605f34bfa53e4334d28cfe45 (patch) | |
| tree | 1197d2791371a5df07e29c18ee0da620b7032c1b | |
| parent | 78ddf12f9733f9caba6d6aa40558c1967f23aabe (diff) | |
| download | emacs-a07e665b66031b15605f34bfa53e4334d28cfe45.tar.gz emacs-a07e665b66031b15605f34bfa53e4334d28cfe45.zip | |
(vc-hg-root): New function.
(vc-hg-registered): Use it.
(vc-hg-diff-tree): New defalias.
(vc-hg-responsible-p): Likewise.
(vc-hg-checkout): Comment out, not needed.
(vc-hg-delete-file, vc-hg-rename-file, vc-hg-could-register)
(vc-hg-find-version, vc-hg-next-version): New functions.
| -rw-r--r-- | lisp/ChangeLog | 10 | ||||
| -rw-r--r-- | lisp/vc-hg.el | 147 |
2 files changed, 140 insertions, 17 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 719d8df25be..ea358ce7b9b 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,13 @@ | |||
| 1 | 2007-07-06 Dan Nicolaescu <dann@ics.uci.edu> | ||
| 2 | |||
| 3 | * vc-hg.el (vc-hg-root): New function. | ||
| 4 | (vc-hg-registered): Use it. | ||
| 5 | (vc-hg-diff-tree): New defalias. | ||
| 6 | (vc-hg-responsible-p): Likewise. | ||
| 7 | (vc-hg-checkout): Comment out, not needed. | ||
| 8 | (vc-hg-delete-file, vc-hg-rename-file, vc-hg-could-register) | ||
| 9 | (vc-hg-find-version, vc-hg-next-version): New functions. | ||
| 10 | |||
| 1 | 2007-07-06 Andreas Schwab <schwab@suse.de> | 11 | 2007-07-06 Andreas Schwab <schwab@suse.de> |
| 2 | 12 | ||
| 3 | * emacs-lisp/lisp-mode.el (eval-last-sexp): Avoid introducing any | 13 | * emacs-lisp/lisp-mode.el (eval-last-sexp): Avoid introducing any |
diff --git a/lisp/vc-hg.el b/lisp/vc-hg.el index a301a3ad5d8..74319d3bcd6 100644 --- a/lisp/vc-hg.el +++ b/lisp/vc-hg.el | |||
| @@ -35,15 +35,70 @@ | |||
| 35 | 35 | ||
| 36 | ;;; Todo: | 36 | ;;; Todo: |
| 37 | 37 | ||
| 38 | ;; Implement the rest of the vc interface: | 38 | ;; Implement the rest of the vc interface. See the comment at the |
| 39 | ;; - dired | 39 | ;; beginning of vc.el. The current status is: |
| 40 | ;; - snapshot? | 40 | |
| 41 | ;; FUNCTION NAME STATUS | ||
| 42 | ;; * registered (file) OK | ||
| 43 | ;; * state (file) OK | ||
| 44 | ;; - state-heuristic (file) ?? PROBABLY NOT NEEDED | ||
| 45 | ;; - dir-state (dir) NEEDED | ||
| 46 | ;; * workfile-version (file) OK | ||
| 47 | ;; - latest-on-branch-p (file) ?? | ||
| 48 | ;; * checkout-model (file) OK | ||
| 49 | ;; - workfile-unchanged-p (file) ?? | ||
| 50 | ;; - mode-line-string (file) NOT NEEDED | ||
| 51 | ;; - dired-state-info (file) NEEDED | ||
| 52 | ;; STATE-CHANGING FUNCTIONS | ||
| 53 | ;; * register (file &optional rev comment) OK | ||
| 54 | ;; - init-version () NOT NEEDED | ||
| 55 | ;; - responsible-p (file) OK | ||
| 56 | ;; - could-register (file) OK | ||
| 57 | ;; - receive-file (file rev) ?? PROBABLY NOT NEEDED | ||
| 58 | ;; - unregister (file) COMMENTED OUT, MAY BE INCORRECT | ||
| 59 | ;; * checkin (file rev comment) OK | ||
| 60 | ;; * find-version (file rev buffer) OK | ||
| 61 | ;; * checkout (file &optional editable rev) NOT NEEDED, COMMENTED OUT | ||
| 62 | ;; * revert (file &optional contents-done) OK | ||
| 63 | ;; - cancel-version (file editable) ?? PROBABLY NOT NEEDED | ||
| 64 | ;; - merge (file rev1 rev2) NEEDED | ||
| 65 | ;; - merge-news (file) NEEDED | ||
| 66 | ;; - steal-lock (file &optional version) NOT NEEDED | ||
| 67 | ;; HISTORY FUNCTIONS | ||
| 68 | ;; * print-log (file &optional buffer) OK | ||
| 69 | ;; - log-view-mode () OK | ||
| 70 | ;; - show-log-entry (version) NOT NEEDED, DEFAULT IS GOOD | ||
| 71 | ;; - wash-log (file) ?? | ||
| 72 | ;; - logentry-check () NOT NEEDED | ||
| 73 | ;; - comment-history (file) NOT NEEDED | ||
| 74 | ;; - update-changelog (files) NOT NEEDED | ||
| 75 | ;; * diff (file &optional rev1 rev2 buffer) OK | ||
| 76 | ;; - revision-completion-table (file) ?? | ||
| 77 | ;; - diff-tree (dir &optional rev1 rev2) TEST IT | ||
| 78 | ;; - annotate-command (file buf &optional rev) OK | ||
| 79 | ;; - annotate-time () OK | ||
| 80 | ;; - annotate-current-time () ?? NOT NEEDED | ||
| 81 | ;; - annotate-extract-revision-at-line () OK | ||
| 82 | ;; SNAPSHOT SYSTEM | ||
| 83 | ;; - create-snapshot (dir name branchp) NEEDED (probably branch?) | ||
| 84 | ;; - assign-name (file name) NOT NEEDED | ||
| 85 | ;; - retrieve-snapshot (dir name update) ?? NEEDED?? | ||
| 86 | ;; MISCELLANEOUS | ||
| 87 | ;; - make-version-backups-p (file) ?? | ||
| 88 | ;; - repository-hostname (dirname) ?? | ||
| 89 | ;; - previous-version (file rev) OK | ||
| 90 | ;; - next-version (file rev) OK | ||
| 91 | ;; - check-headers () ?? | ||
| 92 | ;; - clear-headers () ?? | ||
| 93 | ;; - delete-file (file) TEST IT | ||
| 94 | ;; - rename-file (old new) OK | ||
| 95 | ;; - find-file-hook () PROBABLY NOT NEEDED | ||
| 96 | ;; - find-file-not-found-hook () PROBABLY NOT NEEDED | ||
| 41 | 97 | ||
| 42 | ;; Implement Stefan Monnier's advice: | 98 | ;; Implement Stefan Monnier's advice: |
| 43 | ;; vc-hg-registered and vc-hg-state | 99 | ;; vc-hg-registered and vc-hg-state |
| 44 | ;; Both of those functions should be super extra careful to fail gracefully in | 100 | ;; Both of those functions should be super extra careful to fail gracefully in |
| 45 | ;; unexpected circumstances. The most important such case is when the `hg' | 101 | ;; unexpected circumstances. The reason this is important is that any error |
| 46 | ;; executable is not available. The reason this is important is that any error | ||
| 47 | ;; there will prevent the user from even looking at the file :-( | 102 | ;; there will prevent the user from even looking at the file :-( |
| 48 | ;; Ideally, just like in vc-arch and vc-cvs, checking that the file is under | 103 | ;; Ideally, just like in vc-arch and vc-cvs, checking that the file is under |
| 49 | ;; mercurial's control and extracting the current revision should be done | 104 | ;; mercurial's control and extracting the current revision should be done |
| @@ -67,7 +122,7 @@ | |||
| 67 | (repeat :tag "Argument List" | 122 | (repeat :tag "Argument List" |
| 68 | :value ("") | 123 | :value ("") |
| 69 | string)) | 124 | string)) |
| 70 | ;; :version "22.2" | 125 | :version "22.2" |
| 71 | :group 'vc) | 126 | :group 'vc) |
| 72 | 127 | ||
| 73 | ;;; State querying functions | 128 | ;;; State querying functions |
| @@ -82,7 +137,7 @@ | |||
| 82 | ;; Modelled after the similar function in vc-bzr.el | 137 | ;; Modelled after the similar function in vc-bzr.el |
| 83 | (defun vc-hg-registered (file) | 138 | (defun vc-hg-registered (file) |
| 84 | "Return non-nil if FILE is registered with hg." | 139 | "Return non-nil if FILE is registered with hg." |
| 85 | (if (vc-find-root file ".hg") ; short cut | 140 | (if (vc-hg-root file) ; short cut |
| 86 | (vc-hg-state file))) ; expensive | 141 | (vc-hg-state file))) ; expensive |
| 87 | 142 | ||
| 88 | (defun vc-hg-state (file) | 143 | (defun vc-hg-state (file) |
| @@ -198,6 +253,8 @@ | |||
| 198 | (list "")) | 253 | (list "")) |
| 199 | (list (file-name-nondirectory file)))))) | 254 | (list (file-name-nondirectory file)))))) |
| 200 | 255 | ||
| 256 | (defalias 'vc-hg-diff-tree 'vc-hg-diff) | ||
| 257 | |||
| 201 | (defun vc-hg-annotate-command (file buffer &optional version) | 258 | (defun vc-hg-annotate-command (file buffer &optional version) |
| 202 | "Execute \"hg annotate\" on FILE, inserting the contents in BUFFER. | 259 | "Execute \"hg annotate\" on FILE, inserting the contents in BUFFER. |
| 203 | Optional arg VERSION is a version to annotate from." | 260 | Optional arg VERSION is a version to annotate from." |
| @@ -229,30 +286,83 @@ Optional arg VERSION is a version to annotate from." | |||
| 229 | (when (>= newrev 0) | 286 | (when (>= newrev 0) |
| 230 | (number-to-string newrev)))) | 287 | (number-to-string newrev)))) |
| 231 | 288 | ||
| 289 | (defun vc-hg-next-version (file rev) | ||
| 290 | (let ((newrev (1+ (string-to-number rev))) | ||
| 291 | (tip-version | ||
| 292 | (with-temp-buffer | ||
| 293 | (vc-hg-command t nil nil "tip") | ||
| 294 | (goto-char (point-min)) | ||
| 295 | (re-search-forward "^changeset:[ \t]*\\([0-9]+\\):") | ||
| 296 | (string-to-number (match-string-no-properties 1))))) | ||
| 297 | ;; We don't want to exceed the maximum possible version number, ie | ||
| 298 | ;; the tip version. | ||
| 299 | (when (<= newrev tip-version) | ||
| 300 | (number-to-string newrev)))) | ||
| 301 | |||
| 302 | ;; Modelled after the similar function in vc-bzr.el | ||
| 303 | (defun vc-hg-delete-file (file) | ||
| 304 | "Delete FILE and delete it in the hg repository." | ||
| 305 | (condition-case () | ||
| 306 | (delete-file file) | ||
| 307 | (file-error nil)) | ||
| 308 | (vc-hg-command nil nil file "remove" "--after" "--force")) | ||
| 309 | |||
| 310 | ;; Modelled after the similar function in vc-bzr.el | ||
| 311 | (defun vc-hg-rename-file (old new) | ||
| 312 | "Rename file from OLD to NEW using `hg mv'." | ||
| 313 | (vc-hg-command nil nil new old "mv")) | ||
| 314 | |||
| 232 | (defun vc-hg-register (file &optional rev comment) | 315 | (defun vc-hg-register (file &optional rev comment) |
| 233 | "Register FILE under hg. | 316 | "Register FILE under hg. |
| 234 | REV is ignored. | 317 | REV is ignored. |
| 235 | COMMENT is ignored." | 318 | COMMENT is ignored." |
| 236 | (vc-hg-command nil nil file "add")) | 319 | (vc-hg-command nil nil file "add")) |
| 237 | 320 | ||
| 321 | (defalias 'vc-hg-responsible-p 'vc-hg-root) | ||
| 322 | |||
| 323 | ;; Modelled after the similar function in vc-bzr.el | ||
| 324 | (defun vc-hg-could-register (file) | ||
| 325 | "Return non-nil if FILE could be registered under hg." | ||
| 326 | (and (vc-hg-responsible-p file) ; shortcut | ||
| 327 | (condition-case () | ||
| 328 | (with-temp-buffer | ||
| 329 | (vc-hg-command t nil file "add" "--dry-run")) | ||
| 330 | ;; The command succeeds with no output if file is | ||
| 331 | ;; registered. | ||
| 332 | (error)))) | ||
| 333 | |||
| 334 | ;; XXX This would remove the file. Is that correct? | ||
| 335 | ;; (defun vc-hg-unregister (file) | ||
| 336 | ;; "Unregister FILE from hg." | ||
| 337 | ;; (vc-hg-command nil nil file "remove")) | ||
| 338 | |||
| 238 | (defun vc-hg-checkin (file rev comment) | 339 | (defun vc-hg-checkin (file rev comment) |
| 239 | "HG-specific version of `vc-backend-checkin'. | 340 | "HG-specific version of `vc-backend-checkin'. |
| 240 | REV is ignored." | 341 | REV is ignored." |
| 241 | (vc-hg-command nil nil file "commit" "-m" comment)) | 342 | (vc-hg-command nil nil file "commit" "-m" comment)) |
| 242 | 343 | ||
| 243 | ;; Modelled after the similar function in vc-bzr.el | 344 | (defun vc-hg-find-version (file rev buffer) |
| 244 | (defun vc-hg-checkout (file &optional editable rev workfile) | ||
| 245 | "Retrieve a revision of FILE into a WORKFILE. | ||
| 246 | EDITABLE is ignored. | ||
| 247 | REV is the revision to check out into WORKFILE." | ||
| 248 | (unless workfile | ||
| 249 | (setq workfile (vc-version-backup-file-name file rev))) | ||
| 250 | (let ((coding-system-for-read 'binary) | 345 | (let ((coding-system-for-read 'binary) |
| 251 | (coding-system-for-write 'binary)) | 346 | (coding-system-for-write 'binary)) |
| 252 | (with-temp-file workfile | ||
| 253 | (if rev | 347 | (if rev |
| 254 | (vc-hg-command t nil file "cat" "-r" rev) | 348 | (vc-hg-command buffer nil file "cat" "-r" rev) |
| 255 | (vc-hg-command t nil file "cat"))))) | 349 | (vc-hg-command buffer nil file "cat")))) |
| 350 | |||
| 351 | ;; Modelled after the similar function in vc-bzr.el | ||
| 352 | ;; This should not be needed, `vc-hg-find-version' provides the same | ||
| 353 | ;; functionality. | ||
| 354 | ;; (defun vc-hg-checkout (file &optional editable rev workfile) | ||
| 355 | ;; "Retrieve a revision of FILE into a WORKFILE. | ||
| 356 | ;; EDITABLE is ignored. | ||
| 357 | ;; REV is the revision to check out into WORKFILE." | ||
| 358 | ;; (unless workfile | ||
| 359 | ;; (setq workfile (vc-version-backup-file-name file rev))) | ||
| 360 | ;; (let ((coding-system-for-read 'binary) | ||
| 361 | ;; (coding-system-for-write 'binary)) | ||
| 362 | ;; (with-temp-file workfile | ||
| 363 | ;; (if rev | ||
| 364 | ;; (vc-hg-command t nil file "cat" "-r" rev) | ||
| 365 | ;; (vc-hg-command t nil file "cat"))))) | ||
| 256 | 366 | ||
| 257 | (defun vc-hg-checkout-model (file) | 367 | (defun vc-hg-checkout-model (file) |
| 258 | 'implicit) | 368 | 'implicit) |
| @@ -274,6 +384,9 @@ and that it passes `vc-hg-global-switches' to it before FLAGS." | |||
| 274 | (append vc-hg-global-switches | 384 | (append vc-hg-global-switches |
| 275 | flags)))) | 385 | flags)))) |
| 276 | 386 | ||
| 387 | (defun vc-hg-root (file) | ||
| 388 | (vc-find-root file ".hg")) | ||
| 389 | |||
| 277 | (provide 'vc-hg) | 390 | (provide 'vc-hg) |
| 278 | 391 | ||
| 279 | ;;; vc-hg.el ends here | 392 | ;;; vc-hg.el ends here |