Hi 

I am not sure how many mercurial users, also use GNU emacs for their
work. I do, and I am mostly happy with vc-hg.el provided by GNU emacs.

There is however one feature I really miss, 

 hg ci -i 

So that you can just commit certain hunks. 

Well using 
[ui]
interface = curses

The online command is ok, but I'd prefer an emacs interface for that,
since navigation, manipulating hunks (splitting them) is much nicer in
emacs.

One possibility (and I think I mentioned it here) to obtain an  Emacs
Interface is to use 
commit-patch, 

https://porkrind.org/commit-patch

A perl script (also a emacs lisp pkg is included) that allows you to
operate directly in the vc-diff buffer. 
It works in Ubuntu (16.04, but I presume it works on other flavours as
well) and on MacOS if the correct perl module is installed. I have no
idea about windows.

Be it as it may, right now, GNU emacs starts to support that feature
natively!
It is already implemented for git on the master branch for the developer
version.

And just today Dmitry Gutov kindly sent me a patch.


Dmitry unfortunately uses only git and is not very acquainted with
mercurial so he asked me to test it. I did and found a bit strange
behavior that I would like to discuss below. 
So I am looking for mercurial+emacs users who are interested in this
issue and would like to test the patch and send their comments or
recommendations, best would be to the emacs dev list or to me.

Let me describe how is this is supposed to work


    1. In a file of your hg repository you start vc-diff (or
       diff-hl-diff-goto-hunk which is also provided Dmitry and I can
       only recommend).

    2. You visit the diff buffer and manipulates the hunks as you wish:
       delete some, split others etc 

    3. You call  vc-next-action a windows appears for the commit message
       (if you use commit-patch, you would use bound to   C-c C-c)

    4. It seems to work fine, the only problem I faced is that contrary
       to  commit-patch
       @ is *not* updated, that is hg up tip has not been run. I think
       it should, since this is the standard behavior. What do others think


How to test it?

    1. Clone or pull git://git.savannah.gnu.org/emacs.git (I recommend
       to use git, since hg with hg-git needs hours)

    2. Apply the attached patch with git apply

    3. Configure and compiles

    4. Either install it or  cd $HOME/src/emacs-git/src (or wherever you
       have your source code) and run        ./emacs

Regards

Uwe Brauer 





-- 
I strongly condemn Putin's war of aggression against the Ukraine.
I support to deliver weapons to Ukraine's military. 
I support the ban of Russia from SWIFT.
I support the EU membership of the Ukraine. 
diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el
index f4a44df3c2..d5740b6e21 100644
--- a/lisp/vc/vc-hg.el
+++ b/lisp/vc/vc-hg.el
@@ -1185,19 +1185,33 @@ vc-hg-log-edit-mode
   "Major mode for editing Hg log messages.
 It is based on `log-edit-mode', and has Hg-specific extensions.")
 
+(defvar vc-hg-patch-string nil)
+
 (defun vc-hg-checkin (files comment &optional _rev)
   "Hg-specific version of `vc-backend-checkin'.
 REV is ignored."
-  (let ((amend-extract-fn
-         (lambda (value)
-           (when (equal value "yes")
-             (list "--amend")))))
-    (apply #'vc-hg-command nil 0 files
-           (nconc (list "commit" "-m")
-                  (log-edit-extract-headers `(("Author" . "--user")
-                                              ("Date" . "--date")
-                                              ("Amend" . ,amend-extract-fn))
-                                            comment)))))
+  (apply #'vc-hg-command nil 0 files
+         (nconc (list "commit"
+                      "-m")
+                (vc-hg--extract-headers comment))))
+
+(defun vc-hg-checkin-patch (patch-string comment)
+  (let ((patch-file (make-temp-file "hg-patch")))
+    (with-temp-file patch-file
+      (insert patch-string))
+    (unwind-protect
+        (apply #'vc-hg-command nil 0 nil
+               (nconc (list "import" "--bypass" patch-file "-m")
+                      (vc-hg--extract-headers comment)))
+      (delete-file patch-file))))
+
+(defun vc-hg--extract-headers (comment)
+  (log-edit-extract-headers `(("Author" . "--user")
+                              ("Date" . "--date")
+                              ("Amend" . (lambda (value)
+                                           (when (equal value "yes")
+                                             (list "--amend")))))
+                            comment))
 
 (defun vc-hg-find-revision (file rev buffer)
   (let ((coding-system-for-read 'binary)

Attachment: smime.p7s
Description: S/MIME cryptographic signature

_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@lists.mercurial-scm.org
https://lists.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to