From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Juri Linkov Newsgroups: gmane.emacs.bugs Subject: bug#50344: C-x v keybinding for vc-print-branch-log Date: Tue, 05 Oct 2021 20:43:35 +0300 Organization: LINKOV.NET Message-ID: <878rz72wqg.fsf@mail.linkov.net> References: <87mtoux1ha.fsf@mail.linkov.net> <1f39aa34-6626-3d0b-d764-2c9908787d99@yandex.ru> <87o8998wf4.fsf@mail.linkov.net> <84e4e2ef-6c8d-3645-9e1e-3129981dd45f@yandex.ru> <875yvgvohe.fsf@gnus.org> <87y28burzd.fsf@mail.linkov.net> <87o896kt5k.fsf@gnus.org> <87sfyhj3qw.fsf@mail.linkov.net> <87zgsoctoc.fsf@gnus.org> <59a05468-2309-c6e7-5a2a-51426c208966@yandex.ru> <87tuiv4hvc.fsf@gnus.org> <87fsudsngq.fsf@mail.linkov.net> <85dfa858-091b-80df-b9d1-bd1136c2b91e@yandex.ru> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="5185"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (x86_64-pc-linux-gnu) Cc: 50344@debbugs.gnu.org, Lars Ingebrigtsen , Dmitry Gutov To: Filipp Gunbin Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Tue Oct 05 20:50:51 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mXpWc-000103-HU for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 05 Oct 2021 20:50:50 +0200 Original-Received: from localhost ([::1]:60140 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mXpVb-00009z-Rj for geb-bug-gnu-emacs@m.gmane-mx.org; Tue, 05 Oct 2021 14:49:47 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:38470) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mXoWs-00053g-A5 for bug-gnu-emacs@gnu.org; Tue, 05 Oct 2021 13:47:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:58543) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mXoWr-00029e-MD for bug-gnu-emacs@gnu.org; Tue, 05 Oct 2021 13:47:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mXoWr-0005p9-Iz for bug-gnu-emacs@gnu.org; Tue, 05 Oct 2021 13:47:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Juri Linkov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Tue, 05 Oct 2021 17:47:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50344 X-GNU-PR-Package: emacs Original-Received: via spool by 50344-submit@debbugs.gnu.org id=B50344.163345599522338 (code B ref 50344); Tue, 05 Oct 2021 17:47:01 +0000 Original-Received: (at 50344) by debbugs.gnu.org; 5 Oct 2021 17:46:35 +0000 Original-Received: from localhost ([127.0.0.1]:41853 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mXoWR-0005oD-2N for submit@debbugs.gnu.org; Tue, 05 Oct 2021 13:46:35 -0400 Original-Received: from relay10.mail.gandi.net ([217.70.178.230]:52687) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mXoWO-0005nu-Uv for 50344@debbugs.gnu.org; Tue, 05 Oct 2021 13:46:34 -0400 Original-Received: (Authenticated sender: juri@linkov.net) by relay10.mail.gandi.net (Postfix) with ESMTPSA id B8D53240009; Tue, 5 Oct 2021 17:46:24 +0000 (UTC) In-Reply-To: (Filipp Gunbin's message of "Fri, 17 Sep 2021 18:15:46 +0300") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:216490 Archived-At: --=-=-= Content-Type: text/plain >>> Maybe I should express this wish in a separate bug, but: >>> >>> It would be nice if vc-create-tag allowed to specify start-point >>> conveniently: >>> >>> git checkout -b new-branch-name START-POINT >>> >>> Currently I do this in shell. >> >> Perhaps we could do that with 'C-u C-u'. >> >> Yes, a separate feature request is preferable. > > I'm also thinking of a separate command for branch creation, wrote all > that in bug#50643. Thanks. The following patch adds two new branch commands. > However, I don't use tags much (besides creation - only "git fetch > --tags"), so I cannot add anything meaningful here. > Otherwise, the plan for C-x v b prefix looks great. > Other commands, like maybe "C-x v b r" - rename, could be added then. I can't find the existing vc API method for renaming tags/branches. > The command could have a mode for specifying START-POINT, so for Git the > command becomes "git checkout -b new-branch-name START-POINT". This > could be on C-u (unless there're other frequent "customization" cases). The existing API method has no argument for START-POINT. Maybe every backend could handle its prefix arg directly from current-prefix-arg? For example, (defun vc-git-create-tag (dir name branchp) (if current-prefix-arg (completion-read "Start point: ") ... --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=vc-switch-branch.patch diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el index b7760e3bba..2b6ebdfb74 100644 --- a/lisp/vc/vc-hooks.el +++ b/lisp/vc/vc-hooks.el @@ -865,6 +865,9 @@ vc-prefix-map (let ((map (make-sparse-keymap))) (define-key map "a" #'vc-update-change-log) (define-key map "b" #'vc-switch-backend) + (define-key map "Bc" #'vc-create-branch) + (define-key map "Bl" #'vc-print-branch-log) + (define-key map "Bs" #'vc-switch-branch) (define-key map "d" #'vc-dir) (define-key map "g" #'vc-annotate) (define-key map "G" #'vc-ignore) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index edc4169465..cdebf4a3d3 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -2350,7 +2372,23 @@ vc-create-tag (message "Making %s... done" (if branchp "branch" "tag"))) ;;;###autoload -(defun vc-retrieve-tag (dir name) +(defun vc-create-branch (dir name) + "Descending recursively from DIR, make a branch called NAME. +After a new branch is made, the files are checked out in that new branch. +Uses `vc-create-tag' with the non-nil arg `branchp'." + (interactive + (let ((granularity + (vc-call-backend (vc-responsible-backend default-directory) + 'revision-granularity))) + (list + (if (eq granularity 'repository) + default-directory + (read-directory-name "Directory: " default-directory default-directory t)) + (read-string "New branch name: " nil 'vc-revision-history)))) + (vc-create-tag dir name t)) + +;;;###autoload +(defun vc-retrieve-tag (dir name &optional branchp) "For each file in or below DIR, retrieve their tagged version NAME. NAME can name a branch, in which case this command will switch to the named branch in the directory DIR. @@ -2375,15 +2413,21 @@ vc-retrieve-tag (read-directory-name "Directory: " default-directory nil t)))) (list dir - (vc-read-revision (format-prompt "Tag name to retrieve" "latest revisions") + (vc-read-revision (format-prompt + (if current-prefix-arg + "Branch name to retrieve" + "Tag name to retrieve") + "latest revisions") (list dir) - (vc-responsible-backend dir))))) + (vc-responsible-backend dir)) + current-prefix-arg))) (let* ((backend (vc-responsible-backend dir)) (update (when (vc-call-backend backend 'update-on-retrieve-tag) (yes-or-no-p "Update any affected buffers? "))) (msg (if (or (not name) (string= name "")) (format "Updating %s... " (abbreviate-file-name dir)) - (format "Retrieving tag %s into %s... " + (format "Retrieving %s %s into %s... " + (if branchp "branch" "tag") name (abbreviate-file-name dir))))) (message "%s" msg) (vc-call-backend backend 'retrieve-tag dir name update) @@ -2391,6 +2435,25 @@ vc-retrieve-tag (run-hooks 'vc-retrieve-tag-hook) (message "%s" (concat msg "done")))) +;;;###autoload +(defun vc-switch-branch (dir name) + "Switch to the branch NAME in the directory DIR. +If NAME is empty, it refers to the latest revisions of the current branch. +Uses `vc-retrieve-tag' with the non-nil arg `branchp'." + (interactive + (let* ((granularity + (vc-call-backend (vc-responsible-backend default-directory) + 'revision-granularity)) + (dir + (if (eq granularity 'repository) + (expand-file-name (vc-root-dir)) + (read-directory-name "Directory: " default-directory nil t)))) + (list + dir + (vc-read-revision (format-prompt "Branch name to retrieve" "latest revisions") + (list dir) + (vc-responsible-backend dir))))) + (vc-retrieve-tag dir name t)) ;; Miscellaneous other entry points --=-=-=--