unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Glenn Morris <rgm@gnu.org>
To: Wolfgang Schnerring <wosc@wosc.de>
Cc: 10709@debbugs.gnu.org
Subject: bug#10709: Feature request: vc-hg should activate smerge-mode for conflicts
Date: Fri, 30 Nov 2012 20:12:54 -0500	[thread overview]
Message-ID: <mhy5hiinhl.fsf@fencepost.gnu.org> (raw)
In-Reply-To: <20120203163029.GB1786@elzar.wosc.de> (Wolfgang Schnerring's message of "Fri, 3 Feb 2012 17:30:29 +0100")

Wolfgang Schnerring wrote:

> vc-svn has the useful behaviour (via vc-svn-find-file-hook) that when
> you visit a file with conflicts, it drops you into smerge-mode, and
> automatically marks the file as resolved once you've removed all
> conflict markers. This makes for a very seamless editing experience. :-)
>
> It would be nice if vc-hg did the same. I guess most of the behaviour
> can be lifted straight from vc-svn, however I didn't find anything to
> suggest that vc-hg talks to "hg resolve -l" at the moment, which is
> needed to find out whether the current file is conflicted. So I guess
> that would be the starting point.

Maybe something like this, copied from vc-bzr?

The detection of a conflict is poor and Needs Work. With bzr we have
.BASE, .OTHER, and .THIS files present. With hg, conflicts don't even
seem to show up in "hg status". It's probably not a good idea to call
"hg resolve -l" on every single visit to an hg controlled file.
Nor is it probably a good idea to search the entirety of every file for
<<<< markers without some other clue suggesting a conflict. I used .orig
files because I seemed to get one in my two minutes playing with hg.
These don't seem to get cleaned up on hg resolve, so maybe
vc-hg-resolve-when-done should do that too? However, .orig is a very
vague, general file name.

*** lisp/vc/vc-hg.el	2012-07-19 14:38:01 +0000
--- lisp/vc/vc-hg.el	2012-12-01 01:01:18 +0000
***************
*** 464,469 ****
--- 464,492 ----
          (vc-hg-command t 0 file "cat" "-r" rev)
        (vc-hg-command t 0 file "cat")))))
  
+ (defun vc-hg-resolve-when-done ()
+   "Call \"hg resolve -m\" if the conflict markers have been removed."
+   (save-excursion
+     (goto-char (point-min))
+     (unless (re-search-forward "^<<<<<<< " nil t)
+       (vc-hg-command nil 0 buffer-file-name "resolve" "-m")
+       ;; Remove the hook so that it is not called multiple times.
+       (remove-hook 'after-save-hook 'vc-hg-resolve-when-done t))))
+ 
+ (defun vc-hg-find-file-hook ()
+   (when (and buffer-file-name
+              (file-exists-p (concat buffer-file-name ".orig"))
+              ;; FIXME: We should check that "hg resolve -l" says "U".
+              ;; If "hg resolve -l" says there's a conflict but there are no
+              ;; conflict markers, it's not clear what we should do.
+              (save-excursion
+                (goto-char (point-min))
+                (re-search-forward "^<<<<<<< " nil t)))
+     (smerge-start-session)
+     (add-hook 'after-save-hook 'vc-hg-resolve-when-done nil t)
+     (message "There are unresolved conflicts in this file")))
+ 
+ 
  ;; Modeled after the similar function in vc-bzr.el
  (defun vc-hg-workfile-unchanged-p (file)
    (eq 'up-to-date (vc-hg-state file)))





  parent reply	other threads:[~2012-12-01  1:12 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-03 16:30 bug#10709: Feature request: vc-hg should activate smerge-mode for conflicts Wolfgang Schnerring
2012-02-03 17:04 ` Glenn Morris
2012-02-03 17:11   ` Glenn Morris
2012-02-03 18:27     ` Wolfgang Schnerring
2012-02-03 19:32       ` Stefan Monnier
2012-02-04  9:46         ` Wolfgang Schnerring
2012-02-06 13:27           ` Stefan Monnier
2012-02-03 18:43   ` Stefan Monnier
2012-12-01  1:12 ` Glenn Morris [this message]
2012-12-01  4:42   ` Stefan Monnier
2012-12-05  1:53     ` Glenn Morris

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=mhy5hiinhl.fsf@fencepost.gnu.org \
    --to=rgm@gnu.org \
    --cc=10709@debbugs.gnu.org \
    --cc=wosc@wosc.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).