unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Andrii Kolomoiets <andreyk.mad@gmail.com>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 22860@debbugs.gnu.org
Subject: bug#22860: [PATCH] vc-hg: prompt for branch to merge
Date: Mon, 25 Nov 2019 23:55:16 +0200	[thread overview]
Message-ID: <E1D228E4-AA3F-4ECC-8AFF-061E71636D1E@gmail.com> (raw)
In-Reply-To: <bc99be97-1766-3d16-99ad-346b61ac46f8@yandex.ru>

[-- Attachment #1: Type: text/plain, Size: 1584 bytes --]

On 25 Nov 2019, at 16:41, Dmitry Gutov <dgutov@yandex.ru> wrote:
> 
> Hi Andrii,

Hi Dmitry,

> On 23.11.2019 22:15, Andrii Kolomoiets wrote:
>> * etc/NEWS Mention changes of vc-hg.el
> 
> It's missing a colon after "NEWS" (":").

Fixed.

>> +to the current repository).  On Mercurial, this prompts for argument to
>> +pass to @command{hg merge}, with branch and tag names completion. The
>> +output from running the merge command is shown in a separate buffer.
> 
> The fact that there is completion here is incidental. I'd omit that from this particular place in the manual.

Fixed. In my defense, that sentence was modelled after git's one :)

>> +*** The Hg (Mercurial) back-end now prompts for revision to merge on
>> +'C-x v m' ('vc-merge').
> 
> Branch or revision? I understand that in practice the difference is minimal, but we should pick one or the other wording and use it consistently. Here, in the functions' docstrings, and in the prompt string as well.
> 
> I'd prefer "branch" since it's usually what someone merges, but saying "revision" everywhere should also be okay.

Initially it was "branch". But vc-hg doesn't work with branches at the moment. Even vc-create-tag creates bookmark instead of branch, see bug#17586 (but let's leave it to the future patches).
Besides that, "revision" is used in the "merge" command manual. "revision" can mean a lot of things, see "hg help revisions". Thats why I decide to replace "branch" with "revision".

Please see attached patch. Besides fixes, "bookmarks" added to completion candidates.


[-- Attachment #2: 0001-vc-hg-prompt-for-branch-to-merge.patch --]
[-- Type: application/octet-stream, Size: 4313 bytes --]

From cf764cbe233eb162e3afa9d3f25acc96875e3f8e Mon Sep 17 00:00:00 2001
From: Andrii Kolomoiets <andreyk.mad@gmail.com>
Date: Sat, 23 Nov 2019 18:43:47 +0200
Subject: [PATCH] vc-hg: prompt for branch to merge

* lisp/vc/vc-hg.el (vc-hg-merge-branch): Prompt for revision to merge.
(vc-hg-revision-table): Use branches, tags and bookmarks as competion
candidates.

* etc/NEWS: Mention changes of vc-hg.el

* doc/emacs/maintaining.texi (Switching Branches): Mention 'hg update'
command.
(Merging): Mention 'hg merge' command.

This fixes bug#22860

diff --git a/doc/emacs/maintaining.texi b/doc/emacs/maintaining.texi
index 33a1ec0be0..67072b5e92 100644
--- a/doc/emacs/maintaining.texi
+++ b/doc/emacs/maintaining.texi
@@ -1427,7 +1427,9 @@ Switching Branches
 working tree to match the branch you switch to.  Bazaar also supports
 co-located branches, in which case the @command{bzr switch} command
 will switch branches in the current directory.  With Subversion, you
-switch to another branch using the @command{svn switch} command.
+switch to another branch using the @command{svn switch} command.  On
+Mercurial, command @command{hg update} is used to swith to another
+branch.
 
   The VC command to switch to another branch in the current directory
 is @kbd{C-x v r @var{branch-name} @key{RET}} (@code{vc-retrieve-tag}).
@@ -1542,8 +1544,9 @@ Merging
 the exact arguments to pass to @command{bzr merge}, offering a
 sensible default if possible.  On Git, this prompts for the name of a
 branch to merge from, with completion (based on the branch names known
-to the current repository).  The output from running the merge command
-is shown in a separate buffer.
+to the current repository).  On Mercurial, this prompts for argument to
+pass to @command{hg merge}. The output from running the merge command is
+shown in a separate buffer.
 
   On a centralized version control system like CVS, @kbd{C-x v m}
 prompts for a branch ID, or a pair of revision IDs (@pxref{Switching
diff --git a/etc/NEWS b/etc/NEWS
index ad349b1613..4a718e1357 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -933,6 +933,12 @@ values.
 The 'C-x v h' command now works in buffers that visit files controlled
 by Hg.
 
+*** The Hg (Mercurial) back-end now prompts for revision to merge on
+'C-x v m' ('vc-merge').
+
+*** The Hg (Mercurial) back-end now use tags, branches and bookmarks
+instead of revision numbers as completion candidates on reading revision.
+
 +++
 *** 'C-u C-x v D' ('vc-root-version-diff') prompts for two revisions
 and compares their entire trees.
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index 17d38fa400..4d45ea1ccc 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -564,7 +564,9 @@ vc-hg-expanded-log-entry
 (defun vc-hg-revision-table (files)
   (let ((default-directory (file-name-directory (car files))))
     (with-temp-buffer
-      (vc-hg-command t nil files "log" "--template" "{rev} ")
+      (vc-hg-command t nil nil "branches" "-q")
+      (vc-hg-command t nil nil "bookmarks" "-q")
+      (vc-hg-command t nil nil "tags" "-q")
       (split-string
        (buffer-substring-no-properties (point-min) (point-max))))))
 
@@ -1483,13 +1485,16 @@ vc-hg-push
   (vc-hg--pushpull "push" prompt nil (called-interactively-p 'interactive)))
 
 (defun vc-hg-merge-branch ()
-  "Merge incoming changes into the current working directory.
+  "Prompt for revision and merge it into working directory.
 This runs the command \"hg merge\"."
   (let* ((root (vc-hg-root default-directory))
 	 (buffer (format "*vc-hg : %s*" (expand-file-name root)))
          ;; Disable pager.
-         (process-environment (cons "HGPLAIN=1" process-environment)))
-    (apply 'vc-do-async-command buffer root vc-hg-program '("--config" "ui.report_untrusted=0" "merge"))
+         (process-environment (cons "HGPLAIN=1" process-environment))
+         (branch (vc-read-revision "Revision to merge: ")))
+    (apply 'vc-do-async-command buffer root vc-hg-program
+           (append '("--config" "ui.report_untrusted=0" "merge")
+                   (unless (string= branch "") (list branch))))
     (with-current-buffer buffer (vc-run-delayed (vc-compilation-mode 'hg)))
     (vc-set-async-update buffer)))
 
-- 
2.15.1


  reply	other threads:[~2019-11-25 21:55 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-29 20:56 bug#22860: 24.3; hg merge not too functional Ross Boylan
2019-11-23 18:12 ` bug#22860: [PATCH] vc-hg: prompt for branch to merge Andrii Kolomoiets
2019-11-23 18:34   ` Eli Zaretskii
2019-11-23 18:46     ` Dmitry Gutov
2019-11-23 18:51       ` Eli Zaretskii
2019-11-23 18:53         ` Dmitry Gutov
2019-11-23 18:51     ` Andrii Kolomoiets
2019-11-23 19:01       ` Eli Zaretskii
2019-11-23 20:15         ` Andrii Kolomoiets
2019-11-25 14:41           ` Dmitry Gutov
2019-11-25 21:55             ` Andrii Kolomoiets [this message]
2019-11-25 22:57               ` Dmitry Gutov
2019-11-26 18:19                 ` Eli Zaretskii
2019-11-26 18:16               ` Eli Zaretskii
2019-11-26 19:28                 ` Andrii Kolomoiets
2019-11-30 12:02                   ` Eli Zaretskii

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=E1D228E4-AA3F-4ECC-8AFF-061E71636D1E@gmail.com \
    --to=andreyk.mad@gmail.com \
    --cc=22860@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    /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).