GNU bug report logs - #10709
Feature request: vc-hg should activate smerge-mode for conflicts

Previous Next

Package: emacs;

Reported by: Wolfgang Schnerring <wosc <at> wosc.de>

Date: Fri, 3 Feb 2012 16:32:01 UTC

Severity: wishlist

Fixed in version 24.4

Done: Glenn Morris <rgm <at> gnu.org>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 10709 in the body.
You can then email your comments to 10709 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#10709; Package emacs. (Fri, 03 Feb 2012 16:32:01 GMT) Full text and rfc822 format available.

Acknowledgement sent to Wolfgang Schnerring <wosc <at> wosc.de>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Fri, 03 Feb 2012 16:32:01 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Wolfgang Schnerring <wosc <at> wosc.de>
To: bug-gnu-emacs <at> gnu.org
Subject: Feature request: vc-hg should activate smerge-mode for conflicts
Date: Fri, 3 Feb 2012 17:30:29 +0100
[Message part 1 (text/plain, inline)]
Hello,

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.

My elisp is rather weak, so I probably won't be of much help here, but
do let me know if there's something I can do.

Wolfgang
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10709; Package emacs. (Fri, 03 Feb 2012 17:06:01 GMT) Full text and rfc822 format available.

Message #8 received at 10709 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Wolfgang Schnerring <wosc <at> wosc.de>
Cc: 10709 <at> debbugs.gnu.org
Subject: Re: bug#10709: Feature request: vc-hg should activate smerge-mode for
	conflicts
Date: Fri, 03 Feb 2012 12:04:54 -0500
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 you need to get hg to generate standard conflict markers. Ref:

https://lists.ubuntu.com/archives/bazaar/2012q1/074313.html




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10709; Package emacs. (Fri, 03 Feb 2012 17:13:02 GMT) Full text and rfc822 format available.

Message #11 received at 10709 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Wolfgang Schnerring <wosc <at> wosc.de>
Cc: 10709 <at> debbugs.gnu.org
Subject: Re: bug#10709: Feature request: vc-hg should activate smerge-mode for
	conflicts
Date: Fri, 03 Feb 2012 12:11:57 -0500
Glenn Morris wrote:

> I guess you need to get hg to generate standard conflict markers. Ref:

Actually I guess vc-hg would need some changes too.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10709; Package emacs. (Fri, 03 Feb 2012 18:29:02 GMT) Full text and rfc822 format available.

Message #14 received at 10709 <at> debbugs.gnu.org (full text, mbox):

From: Wolfgang Schnerring <wosc <at> wosc.de>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 10709 <at> debbugs.gnu.org
Subject: Re: bug#10709: Feature request: vc-hg should activate smerge-mode
	for conflicts
Date: Fri, 3 Feb 2012 19:27:36 +0100
[Message part 1 (text/plain, inline)]
* Glenn Morris <rgm <at> gnu.org> [2012-02-03 12:11]:
> Glenn Morris wrote:
> > I guess you need to get hg to generate standard conflict markers. Ref:

You could configure diff3 as the default merge program.
However, in my experience, using smerge-mode on the "internal:merge"
results of hg worked, too.
 
> Actually I guess vc-hg would need some changes too.

Yep, I guess you'd need changes on both ends.

Wolfgang
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10709; Package emacs. (Fri, 03 Feb 2012 18:44:02 GMT) Full text and rfc822 format available.

Message #17 received at 10709 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 10709 <at> debbugs.gnu.org, Wolfgang Schnerring <wosc <at> wosc.de>
Subject: Re: bug#10709: Feature request: vc-hg should activate smerge-mode for
	conflicts
Date: Fri, 03 Feb 2012 13:43:01 -0500
>> 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 you need to get hg to generate standard conflict markers. Ref:
> https://lists.ubuntu.com/archives/bazaar/2012q1/074313.html

Note: I do not know that hg uses non-standard conflict markers.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10709; Package emacs. (Fri, 03 Feb 2012 19:34:01 GMT) Full text and rfc822 format available.

Message #20 received at 10709 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Wolfgang Schnerring <wosc <at> wosc.de>
Cc: 10709 <at> debbugs.gnu.org, Glenn Morris <rgm <at> gnu.org>
Subject: Re: bug#10709: Feature request: vc-hg should activate smerge-mode for
	conflicts
Date: Fri, 03 Feb 2012 14:32:38 -0500
>> > I guess you need to get hg to generate standard conflict markers. Ref:
> You could configure diff3 as the default merge program.
> However, in my experience, using smerge-mode on the "internal:merge"
> results of hg worked, too.

So you're saying that hg uses standard conflict markers in its
internal:merge code?  Wonderful.

>> Actually I guess vc-hg would need some changes too.
> Yep, I guess you'd need changes on both ends.

Apparently only vc-hg.el needs to be changed, then.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10709; Package emacs. (Sat, 04 Feb 2012 09:48:02 GMT) Full text and rfc822 format available.

Message #23 received at 10709 <at> debbugs.gnu.org (full text, mbox):

From: Wolfgang Schnerring <wosc <at> wosc.de>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 10709 <at> debbugs.gnu.org, Glenn Morris <rgm <at> gnu.org>
Subject: Re: bug#10709: Feature request: vc-hg should activate smerge-mode
	for conflicts
Date: Sat, 4 Feb 2012 10:46:29 +0100
[Message part 1 (text/plain, inline)]
* Stefan Monnier <monnier <at> iro.umontreal.ca> [2012-02-03 14:32]:
> So you're saying that hg uses standard conflict markers in its
> internal:merge code?  Wonderful.

I've just double-checked: yes, it does. Here's an example of a file
with conflicts:

<<<<<<< local
foo = baz
=======
foo = qux
>>>>>>> other

This matches the markers defined in smerge-mode, and invoking
smerge-mode manually on the example file works just fine, just as I
remembered.

> >> Actually I guess vc-hg would need some changes too.
> > Yep, I guess you'd need changes on both ends.
> 
> Apparently only vc-hg.el needs to be changed, then.

Yup, this brings me back to my original chain of thought: vc-hg needs
to learn to detect conflicted files, and the vc-find-file-hook needs
to be ported/abstracted from vc-svn.

Wolfgang
[signature.asc (application/pgp-signature, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10709; Package emacs. (Mon, 06 Feb 2012 13:29:01 GMT) Full text and rfc822 format available.

Message #26 received at 10709 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Wolfgang Schnerring <wosc <at> wosc.de>
Cc: 10709 <at> debbugs.gnu.org, Glenn Morris <rgm <at> gnu.org>
Subject: Re: bug#10709: Feature request: vc-hg should activate smerge-mode for
	conflicts
Date: Mon, 06 Feb 2012 08:27:27 -0500
>> So you're saying that hg uses standard conflict markers in its
>> internal:merge code?  Wonderful.
> I've just double-checked: yes, it does. Here's an example of a file
> with conflicts:

> <<<<<<< local
> foo = baz
> =======
> foo = qux
>>>>>>>> other

> This matches the markers defined in smerge-mode, and invoking
> smerge-mode manually on the example file works just fine, just as I
> remembered.

>> >> Actually I guess vc-hg would need some changes too.
>> > Yep, I guess you'd need changes on both ends.
>> 
>> Apparently only vc-hg.el needs to be changed, then.

> Yup, this brings me back to my original chain of thought: vc-hg needs
> to learn to detect conflicted files, and the vc-find-file-hook needs
> to be ported/abstracted from vc-svn.

You can also check vc-bzr.el which has similar code.


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10709; Package emacs. (Sat, 01 Dec 2012 01:16:01 GMT) Full text and rfc822 format available.

Message #29 received at 10709 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Wolfgang Schnerring <wosc <at> wosc.de>
Cc: 10709 <at> debbugs.gnu.org
Subject: Re: bug#10709: Feature request: vc-hg should activate smerge-mode for
	conflicts
Date: Fri, 30 Nov 2012 20:12:54 -0500
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)))




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10709; Package emacs. (Sat, 01 Dec 2012 04:45:02 GMT) Full text and rfc822 format available.

Message #32 received at 10709 <at> debbugs.gnu.org (full text, mbox):

From: Stefan Monnier <monnier <at> iro.umontreal.ca>
To: Glenn Morris <rgm <at> gnu.org>
Cc: 10709 <at> debbugs.gnu.org, Wolfgang Schnerring <wosc <at> wosc.de>
Subject: Re: bug#10709: Feature request: vc-hg should activate smerge-mode for
	conflicts
Date: Fri, 30 Nov 2012 23:42:04 -0500
> The detection of a conflict is poor and Needs Work. With bzr we have

Maybe we should ask on a Mercurial list how it can be done (and turn it
into a feature request if there's no good answer)?


        Stefan




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#10709; Package emacs. (Wed, 05 Dec 2012 01:54:02 GMT) Full text and rfc822 format available.

Message #35 received at 10709 <at> debbugs.gnu.org (full text, mbox):

From: Glenn Morris <rgm <at> gnu.org>
To: Stefan Monnier <monnier <at> iro.umontreal.ca>
Cc: 10709 <at> debbugs.gnu.org, Wolfgang Schnerring <wosc <at> wosc.de>
Subject: Re: bug#10709: Feature request: vc-hg should activate smerge-mode for
	conflicts
Date: Tue, 04 Dec 2012 20:53:45 -0500
Stefan Monnier wrote:

>> The detection of a conflict is poor and Needs Work. With bzr we have
>
> Maybe we should ask on a Mercurial list how it can be done (and turn it
> into a feature request if there's no good answer)?

AFAICS they have set their face against it, eg

http://bz.selenic.com/show_bug.cgi?id=2724  # RESOLVED FIXED

I think checking for state = 'edited, plus .orig file, plus conflict
markers is good enough for a start, so I installed that to trunk and we
can see how it works out for people.

BTW, I think this stuff should be abstracted to a general
vc-find-file-hook/after-save-hook that calls vc-BACKEND-conflicted-p.




bug marked as fixed in version 24.4, send any further explanations to 10709 <at> debbugs.gnu.org and Wolfgang Schnerring <wosc <at> wosc.de> Request was from Glenn Morris <rgm <at> gnu.org> to control <at> debbugs.gnu.org. (Wed, 05 Dec 2012 01:55:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Wed, 02 Jan 2013 12:24:03 GMT) Full text and rfc822 format available.

This bug report was last modified 12 years and 168 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.