From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Glenn Morris Newsgroups: gmane.emacs.bugs Subject: bug#10709: Feature request: vc-hg should activate smerge-mode for conflicts Date: Fri, 30 Nov 2012 20:12:54 -0500 Message-ID: References: <20120203163029.GB1786@elzar.wosc.de> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1354324438 31697 80.91.229.3 (1 Dec 2012 01:13:58 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 1 Dec 2012 01:13:58 +0000 (UTC) Cc: 10709@debbugs.gnu.org To: Wolfgang Schnerring Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Sat Dec 01 02:14:10 2012 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Tebek-0002PN-5M for geb-bug-gnu-emacs@m.gmane.org; Sat, 01 Dec 2012 02:14:10 +0100 Original-Received: from localhost ([::1]:52706 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TebeY-0003fQ-AF for geb-bug-gnu-emacs@m.gmane.org; Fri, 30 Nov 2012 20:13:58 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:45637) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TebeV-0003f6-1C for bug-gnu-emacs@gnu.org; Fri, 30 Nov 2012 20:13:56 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TebeT-00023g-Rj for bug-gnu-emacs@gnu.org; Fri, 30 Nov 2012 20:13:54 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:37394) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TebeT-00023c-OG for bug-gnu-emacs@gnu.org; Fri, 30 Nov 2012 20:13:53 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TebgX-000670-O0 for bug-gnu-emacs@gnu.org; Fri, 30 Nov 2012 20:16:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Glenn Morris Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 01 Dec 2012 01:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 10709 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 10709-submit@debbugs.gnu.org id=B10709.135432450723393 (code B ref 10709); Sat, 01 Dec 2012 01:16:01 +0000 Original-Received: (at 10709) by debbugs.gnu.org; 1 Dec 2012 01:15:07 +0000 Original-Received: from localhost ([127.0.0.1]:47623 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tebff-00065G-AU for submit@debbugs.gnu.org; Fri, 30 Nov 2012 20:15:07 -0500 Original-Received: from fencepost.gnu.org ([208.118.235.10]:46119) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1Tebfc-000655-GC for 10709@debbugs.gnu.org; Fri, 30 Nov 2012 20:15:05 -0500 Original-Received: from rgm by fencepost.gnu.org with local (Exim 4.71) (envelope-from ) id 1TebdW-0001oO-Ou; Fri, 30 Nov 2012 20:12:54 -0500 X-Spook: infowar brigand Lexis-Nexis DES New World Order Bellcore X-Ran: @?qY/jDOJdh`d8xgfo?kr[}u~O8TdkAvZa2H%<0Lnw-$:OCc0wrFF{teEj,C]!;!*j;us7 X-Hue: green X-Attribution: GM In-Reply-To: <20120203163029.GB1786@elzar.wosc.de> (Wolfgang Schnerring's message of "Fri, 3 Feb 2012 17:30:29 +0100") User-Agent: Gnus (www.gnus.org), GNU Emacs (www.gnu.org/software/emacs/) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:67704 Archived-At: 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)))