From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.ciao.gmane.io!not-for-mail From: Tassilo Horn Newsgroups: gmane.emacs.devel Subject: Re: RFC: Automatic setup for bug-reference-mode Date: Sun, 14 Jun 2020 18:30:26 +0200 Message-ID: <87tuzdsj8d.fsf@gnu.org> References: <87r1uihtsu.fsf@gnu.org> <87h7vd3cbs.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="ciao.gmane.io:159.69.161.202"; logging-data="82179"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: emacs-devel@gnu.org To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sun Jun 14 18:31:37 2020 Return-path: Envelope-to: ged-emacs-devel@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 1jkVXk-000LLq-VB for ged-emacs-devel@m.gmane-mx.org; Sun, 14 Jun 2020 18:31:37 +0200 Original-Received: from localhost ([::1]:43248 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jkVXj-000805-W8 for ged-emacs-devel@m.gmane-mx.org; Sun, 14 Jun 2020 12:31:36 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:49692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1jkVWj-0007TG-6Z for emacs-devel@gnu.org; Sun, 14 Jun 2020 12:30:33 -0400 Original-Received: from fencepost.gnu.org ([2001:470:142:3::e]:48364) by eggs.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jkVWi-0006ez-NN; Sun, 14 Jun 2020 12:30:32 -0400 Original-Received: from auth1-smtp.messagingengine.com ([66.111.4.227]:58983) by fencepost.gnu.org with esmtpsa (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.82) (envelope-from ) id 1jkVWi-0000iE-BC; Sun, 14 Jun 2020 12:30:32 -0400 Original-Received: from compute7.internal (compute7.nyi.internal [10.202.2.47]) by mailauth.nyi.internal (Postfix) with ESMTP id 2281327C0054; Sun, 14 Jun 2020 12:30:31 -0400 (EDT) Original-Received: from mailfrontend1 ([10.202.2.162]) by compute7.internal (MEProxy); Sun, 14 Jun 2020 12:30:31 -0400 X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduhedrudeiiedguddtgecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmd enucfjughrpefhvffufhffjgfkfgggtgesmhdtreertdertdenucfhrhhomhepvfgrshhs ihhlohcujfhorhhnuceothhsughhsehgnhhurdhorhhgqeenucggtffrrghtthgvrhhnpe fggfefgedtvdefudfhgefgvdeuleekfeeuvdelveeihfekffdukeejgeevfeejteenucfk phepleefrddvfeeirddufeeirdefudenucevlhhushhtvghrufhiiigvpedtnecurfgrrh grmhepmhgrihhlfhhrohhmpehthhhorhhnodhmvghsmhhtphgruhhthhhpvghrshhonhgr lhhithihqdekieejfeekjeekgedqieefhedvleekqdhtshguhheppehgnhhurdhorhhgse hfrghsthhmrghilhdrfhhm X-ME-Proxy: Original-Received: from thinkpad-t440p (p5dec881f.dip0.t-ipconnect.de [93.236.136.31]) by mail.messagingengine.com (Postfix) with ESMTPA id D6E9A328005D; Sun, 14 Jun 2020 12:30:28 -0400 (EDT) Mail-Followup-To: Stefan Monnier , emacs-devel@gnu.org In-Reply-To: <87h7vd3cbs.fsf@gnu.org> (Tassilo Horn's message of "Sun, 14 Jun 2020 17:18:47 +0200") X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:252235 Archived-At: --=-=-= Content-Type: text/plain Tassilo Horn writes: >>> + (let* ((backend (vc-responsible-backend (buffer-file-name) t)) >>> + (url (pcase backend >>> + ('Git (string-trim >>> + (shell-command-to-string >>> + "git ls-remote --get-url")))))) >> >> This should be moved to a new VC function. Ok, I have implemented a new repository-url VC command for all VC systems I have installed and were able to test: Git, Hg, Bzr, and SVN. Looks right? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-New-VC-command-repository-url.patch >From f117a8517dc32330aa9ed32f531b68daba2d7b62 Mon Sep 17 00:00:00 2001 From: Tassilo Horn Date: Sun, 14 Jun 2020 18:24:14 +0200 Subject: [PATCH] New VC command repository-url --- lisp/vc/vc-bzr.el | 8 ++++++++ lisp/vc/vc-git.el | 7 +++++++ lisp/vc/vc-hg.el | 7 +++++++ lisp/vc/vc-svn.el | 9 ++++++++- lisp/vc/vc.el | 4 ++++ 5 files changed, 34 insertions(+), 1 deletion(-) diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el index e5d307e7ed..504d3dcdda 100644 --- a/lisp/vc/vc-bzr.el +++ b/lisp/vc/vc-bzr.el @@ -1316,6 +1316,14 @@ vc-bzr-revision-completion-table vc-bzr-revision-keywords)) string pred))))) +(defun vc-bzr-repository-url (file-or-dir) + (let ((default-directory (vc-bzr-root file-or-dir))) + (with-temp-buffer + (vc-bzr-command "info" (current-buffer) nil nil) + (goto-char (point-min)) + (when (re-search-forward "parent branch: \\(.*\\)$") + (match-string 1))))) + (provide 'vc-bzr) ;;; vc-bzr.el ends here diff --git a/lisp/vc/vc-git.el b/lisp/vc/vc-git.el index dcb5228265..8c9feb0e9d 100644 --- a/lisp/vc/vc-git.el +++ b/lisp/vc/vc-git.el @@ -101,6 +101,7 @@ ;; - rename-file (old new) OK ;; - find-file-hook () OK ;; - conflicted-files OK +;; - repository-url (file-or-dir) OK ;;; Code: @@ -1082,6 +1083,12 @@ vc-git-conflicted-files "DU" "AA" "UU")) (push (expand-file-name file directory) files))))))) +(defun vc-git-repository-url (file-or-dir) + (let ((default-directory (vc-git-root file-or-dir))) + (with-temp-buffer + (vc-git--call (current-buffer) "ls-remote" "--get-url") + (buffer-substring-no-properties (point-min) (1- (point-max)))))) + ;; Everywhere but here, follows vc-git-command, which uses vc-do-command ;; from vc-dispatcher. (autoload 'vc-resynch-buffer "vc-dispatcher") diff --git a/lisp/vc/vc-hg.el b/lisp/vc/vc-hg.el index 40d7573806..b5cdf5a3a2 100644 --- a/lisp/vc/vc-hg.el +++ b/lisp/vc/vc-hg.el @@ -1525,6 +1525,13 @@ vc-hg-command (defun vc-hg-root (file) (vc-find-root file ".hg")) +(defun vc-hg-repository-url (file-or-dir) + (let ((default-directory (vc-hg-root file-or-dir))) + (with-temp-buffer + (vc-hg-command (current-buffer) nil nil + "config" "paths.default") + (buffer-substring-no-properties (point-min) (1- (point-max)))))) + (provide 'vc-hg) ;;; vc-hg.el ends here diff --git a/lisp/vc/vc-svn.el b/lisp/vc/vc-svn.el index d039bf3c6a..c439082390 100644 --- a/lisp/vc/vc-svn.el +++ b/lisp/vc/vc-svn.el @@ -816,7 +816,14 @@ vc-svn-revision-table (push (match-string 1 loglines) vc-svn-revisions) (setq start (+ start (match-end 0))) (setq loglines (buffer-substring-no-properties start (point-max))))) - vc-svn-revisions))) + vc-svn-revisions))) + +(defun vc-svn-repository-url (file-or-dir) + (let ((default-directory (vc-svn-root file-or-dir))) + (with-temp-buffer + (vc-svn-command (current-buffer) nil nil + "info" "--show-item" "repos-root-url") + (buffer-substring-no-properties (point-min) (1- (point-max)))))) (provide 'vc-svn) diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el index c640ba0420..5c335ebfaa 100644 --- a/lisp/vc/vc.el +++ b/lisp/vc/vc.el @@ -553,6 +553,10 @@ ;; Return the list of files where conflict resolution is needed in ;; the project that contains DIR. ;; FIXME: what should it do with non-text conflicts? +;; +;; - repository-url (file) +;; +;; Returns the URL of the repository of the current checkout. ;;; Changes from the pre-25.1 API: ;; -- 2.27.0 --=-=-= Content-Type: text/plain Bye, Tassilo --=-=-=--