diff options
| author | Glenn Morris | 2012-12-04 20:49:31 -0500 |
|---|---|---|
| committer | Glenn Morris | 2012-12-04 20:49:31 -0500 |
| commit | 49596095d09227d828ffb6fed955ba0b660b4d92 (patch) | |
| tree | c3d733d7d5f1288711c59dabbadfa59e43decd48 | |
| parent | f2484dffa2bb96d245839eeae94153cf70209d42 (diff) | |
| download | emacs-49596095d09227d828ffb6fed955ba0b660b4d92.tar.gz emacs-49596095d09227d828ffb6fed955ba0b660b4d92.zip | |
Add conflict detection/resolution to vc-hg (bug#10709)
* lisp/vc/vc-hg.el (vc-hg-resolve-when-done, vc-hg-find-file-hook):
New functions, for detecting and resolving conflicts.
| -rw-r--r-- | lisp/ChangeLog | 5 | ||||
| -rw-r--r-- | lisp/vc/vc-hg.el | 31 |
2 files changed, 35 insertions, 1 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index ff9b0e2a86f..45fa38042a0 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,8 @@ | |||
| 1 | 2012-12-05 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * vc/vc-hg.el (vc-hg-resolve-when-done, vc-hg-find-file-hook): | ||
| 4 | New functions, for detecting and resolving conflicts. (Bug#10709) | ||
| 5 | |||
| 1 | 2012-12-04 Jambunathan K <kjambunathan@gmail.com> | 6 | 2012-12-04 Jambunathan K <kjambunathan@gmail.com> |
| 2 | 7 | ||
| 3 | * hi-lock.el (hi-lock-auto-select-face): New user variable. | 8 | * hi-lock.el (hi-lock-auto-select-face): New user variable. |
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index 50678fad075..a240fdeb658 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el | |||
| @@ -93,7 +93,7 @@ | |||
| 93 | ;; - clear-headers () ?? | 93 | ;; - clear-headers () ?? |
| 94 | ;; - delete-file (file) TEST IT | 94 | ;; - delete-file (file) TEST IT |
| 95 | ;; - rename-file (old new) OK | 95 | ;; - rename-file (old new) OK |
| 96 | ;; - find-file-hook () PROBABLY NOT NEEDED | 96 | ;; - find-file-hook () added for bug#10709 |
| 97 | 97 | ||
| 98 | ;; 2) Implement Stefan Monnier's advice: | 98 | ;; 2) Implement Stefan Monnier's advice: |
| 99 | ;; vc-hg-registered and vc-hg-state | 99 | ;; vc-hg-registered and vc-hg-state |
| @@ -464,6 +464,35 @@ REV is the revision to check out into WORKFILE." | |||
| 464 | (vc-hg-command t 0 file "cat" "-r" rev) | 464 | (vc-hg-command t 0 file "cat" "-r" rev) |
| 465 | (vc-hg-command t 0 file "cat"))))) | 465 | (vc-hg-command t 0 file "cat"))))) |
| 466 | 466 | ||
| 467 | (defun vc-hg-resolve-when-done () | ||
| 468 | "Call \"hg resolve -m\" if the conflict markers have been removed." | ||
| 469 | (save-excursion | ||
| 470 | (goto-char (point-min)) | ||
| 471 | (unless (re-search-forward "^<<<<<<< " nil t) | ||
| 472 | (vc-hg-command nil 0 buffer-file-name "resolve" "-m") | ||
| 473 | ;; Remove the hook so that it is not called multiple times. | ||
| 474 | (remove-hook 'after-save-hook 'vc-hg-resolve-when-done t)))) | ||
| 475 | |||
| 476 | (defun vc-hg-find-file-hook () | ||
| 477 | (when (and buffer-file-name | ||
| 478 | (file-exists-p (concat buffer-file-name ".orig")) | ||
| 479 | ;; Hg does not seem to have a "conflict" status, eg | ||
| 480 | ;; hg http://bz.selenic.com/show_bug.cgi?id=2724 | ||
| 481 | (memq (vc-file-getprop buffer-file-name 'vc-state) | ||
| 482 | '(edited conflict)) | ||
| 483 | ;; Maybe go on to check that "hg resolve -l" says "U"? | ||
| 484 | ;; If "hg resolve -l" says there's a conflict but there are no | ||
| 485 | ;; conflict markers, it's not clear what we should do. | ||
| 486 | (save-excursion | ||
| 487 | (goto-char (point-min)) | ||
| 488 | (re-search-forward "^<<<<<<< " nil t))) | ||
| 489 | ;; Hg may not recognize "conflict" as a state, but we can do better. | ||
| 490 | (vc-file-setprop buffer-file-name 'vc-state 'conflict) | ||
| 491 | (smerge-start-session) | ||
| 492 | (add-hook 'after-save-hook 'vc-hg-resolve-when-done nil t) | ||
| 493 | (message "There are unresolved conflicts in this file"))) | ||
| 494 | |||
| 495 | |||
| 467 | ;; Modeled after the similar function in vc-bzr.el | 496 | ;; Modeled after the similar function in vc-bzr.el |
| 468 | (defun vc-hg-workfile-unchanged-p (file) | 497 | (defun vc-hg-workfile-unchanged-p (file) |
| 469 | (eq 'up-to-date (vc-hg-state file))) | 498 | (eq 'up-to-date (vc-hg-state file))) |