GNU bug report logs - #79408
31.0.50; VC commands for cherry-picking

Previous Next

Package: emacs;

Reported by: Sean Whitton <spwhitton <at> spwhitton.name>

Date: Mon, 8 Sep 2025 11:28:02 UTC

Severity: normal

Found in version 31.0.50

Full log


View this message in rfc822 format

From: Sean Whitton <spwhitton <at> spwhitton.name>
To: 79408 <at> debbugs.gnu.org
Cc: eliz <at> gnu.org, sbaugh <at> janestreet.com, dmitry <at> gutov.dev, juri <at> linkov.net
Subject: bug#79408: 31.0.50; VC commands for cherry-picking
Date: Mon, 08 Sep 2025 12:27:02 +0100
X-debbugs-cc: eliz <at> gnu.org, sbaugh <at> janestreet.com, dmitry <at> gutov.dev, juri <at> linkov.net

Hello,

I'd like to add VC commands to cherry-pick changes.
These are my proposed additions to the VC API:

;; - cherry-pick (files comment rev reverse)
;;
;;   Copy a REV's changes, log message, author and author timestamp as a
;;   new commit on the current branch.  If REVERSE, reverse REV's changes.
;;   FILES is for forward-compatibility; existing implementations aren't
;;   able to limit the changes copied from REV to those made to FILES.
;;
;; - cherry-apply (files rev reverse)
;;
;;   Copy REV's changes to FILES to this working directory.  If REVERSE,
;;   reverse REV's changes.  (When REVERSE is nil, typically REV will be
;;   a revision from another branch.)
;;
;; - cherry-pick-comment (files rev reverse)
;;
;;   Return a string to be appended to the log message when
;;   cherry-picking REV onto another branch.  This is Git's "(cherry
;;   picked from commit ...)" and Mercurial's "(grafted from ...)",
;;   or if REVERSE, Git's "This reverts commit ...".
;;   FILES is for forward-compatibility; existing implementations care
;;   only about REV.

These are my proposed commands:

vc-cherry-pick:
 - Gets the log message for REV with get-change-comment API function.
 - Gets the string to append with cherry-pick-comment API function.
 - Puts these together, starts a Log Edit session for the user to amend
   the message (e.g. for Git, doing C-c C-s to add a sign-off).
 - On C-c C-c, calls the cherry-pick API function for the backend to do
   the cherry-pick.
   Examples: vc-git-cherry-pick would invoke 'git cherry-pick' or
   'git revert' depending on whether REVERT.
   vc-hg-cherry-pick would invoke 'hg graft' or 'hg backout'.

 Will have vc-checkin's COMMENT, INITIAL-CONTENTS arguments so calling
 from Lisp can skip the Log Edit session.

 A prefix argument might toggle whether to append the cherry-pick
 comment.

 We'll be expecting the user to invoke this from Log View mode.  If
 multiple commits are marked, then I think we have to skip the Log Edit
 session, for now, because we don't have a nice way to prompt for
 multiple messages.

vc-undo-revision (vc-revert is taken):
 Same as vc-cherry-pick, except passes REVERSE non-nil at the
 appropriate points.  No prefix argument.

vc-cherry-apply:
 The advantage of having a backend API function for this is that the
 backend can use its full merging logic.
 A generic vc-default-cherry-apply can be implementated similarly to
 vc-apply-to-other-working-tree.

vc-undo-apply:
 Like vc-cherry-apply except passes REVERSE non-nil at the appropriate
 point.  Similarly there can be a vc-default-reverse-cherry-apply.

I think this is a good way to divide up the functionality on the
frontend, but I'm open to suggestions.  Thanks!

-- 
Sean Whitton




This bug report was last modified today.

Previous Next


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