From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Dani Moncayo Newsgroups: gmane.emacs.devel Subject: Re: Setting the value of `emacs-bzr-version' also from a git checkout Date: Sat, 12 Oct 2013 12:22:29 +0200 Message-ID: References: <87a9is6g2a.fsf@igel.home> <87pprokewg.fsf@wanadoo.es> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1381573351 12129 80.91.229.3 (12 Oct 2013 10:22:31 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 12 Oct 2013 10:22:31 +0000 (UTC) Cc: =?ISO-8859-1?Q?=D3scar_Fuentes?= , Emacs development discussions To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Oct 12 12:22:36 2013 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1VUwLD-0000eQ-Gj for ged-emacs-devel@m.gmane.org; Sat, 12 Oct 2013 12:22:35 +0200 Original-Received: from localhost ([::1]:57605 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUwLC-0007JS-Ps for ged-emacs-devel@m.gmane.org; Sat, 12 Oct 2013 06:22:34 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUwLA-0007JK-4N for emacs-devel@gnu.org; Sat, 12 Oct 2013 06:22:33 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VUwL9-0002iQ-5K for emacs-devel@gnu.org; Sat, 12 Oct 2013 06:22:32 -0400 Original-Received: from mail-lb0-x230.google.com ([2a00:1450:4010:c04::230]:44774) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VUwL8-0002iM-Tx for emacs-devel@gnu.org; Sat, 12 Oct 2013 06:22:31 -0400 Original-Received: by mail-lb0-f176.google.com with SMTP id y6so4171929lbh.7 for ; Sat, 12 Oct 2013 03:22:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=XK7fzOT5xrDE5YjFN6lgWLwunulRA+DUZfHG49z2b5o=; b=QQDT78HIo9V6MAkiQXBXoW5stJqm6TrP8PLLXPkzrdH07ODob/3e3HYkI83et3hDaK 7ddOncVwf128ijY3lUvmxBJwzsxzeL8ES1I5TxMS3Ns4+0WFf0kvS2SkB9pcsaMKGkqV eoWnN3ZWxMuW/D3GHFQNMTo09BYcowt27yqbYEkKrreJjV4cULX55K4xyO6FndThEfeS t5SGCxqIZQ5FRLxZ+HaKIJj+nuoMUbwypm/+tOtADaZ0p/fcIKAGQLBa3xVfxpirsYxn iAiyCC1anMx38zQ61FUsNx0JIV3gVwinvV7j+tCvHgBtxzloVXjWut8Ds7TvOzkTpZuL 6QkQ== X-Received: by 10.152.116.7 with SMTP id js7mr20503986lab.11.1381573349912; Sat, 12 Oct 2013 03:22:29 -0700 (PDT) Original-Received: by 10.114.176.231 with HTTP; Sat, 12 Oct 2013 03:22:29 -0700 (PDT) In-Reply-To: X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::230 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 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.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:164134 Archived-At: On Wed, Oct 2, 2013 at 2:22 AM, Stefan Monnier wrote: >> Therefore, what I'd like is that "emacs-bzr-version" gave the exact >> same string from an Emacs built from either bzr-trunk or git-master. > > Patch welcome, The below patch works for me. But in order to get the intended behavior (see above paragraph), it is necessary that the savannah git repository includes also the bzr revno (in addition to the bzr revid) in each note. E.g.: "114635 eliz@gnu.org-20131012090021-bau450cmd6gk61ag" ^^^^^^^ This part is currently missing. We need it. diff --git a/lisp/version.el b/lisp/version.el index 9667456..030386a 100644 --- a/lisp/version.el +++ b/lisp/version.el @@ -126,6 +126,21 @@ Returns nil if unable to find this information." "dir")) (buffer-string)))) +(defun emacs-bzr-version-git (dir) + "Ask git for the bzr version information for directory DIR. +The official git repository of GNU Emacs stores this information +as notes in each revision" + (message "Waiting for git...") + (with-temp-buffer + (if (zerop + (call-process "git" nil '(t nil) nil + (concat "--git-dir=" dir ".git") + "log" + "-1" + "--pretty=format:%N")) + (replace-regexp-in-string "\n" "" (buffer-string))))) + + (defun emacs-bzr-get-version (&optional dir external) "Try to return as a string the bzr revision of the Emacs sources. The format is: [revno] revision_id, where revno may be absent. @@ -138,8 +153,8 @@ Optional argument EXTERNAL non-nil means to maybe ask `bzr' itself, if the sources appear to be under bzr. If `force', always ask bzr. Otherwise only ask bzr if we cannot find any information ourselves." (or dir (setq dir source-directory)) - (when (file-directory-p (expand-file-name ".bzr/branch" dir)) - (if (eq external 'force) + (cond ((file-directory-p (expand-file-name ".bzr/branch" dir)) + ((if (eq external 'force) (emacs-bzr-version-bzr dir) (let (file loc rev) (cond ((file-readable-p @@ -172,6 +187,9 @@ Otherwise only ask bzr if we cannot find any information ourselves." rev)) (external (emacs-bzr-version-bzr dir))))))) + ((file-directory-p (expand-file-name ".git" dir)) + (if external + (emacs-bzr-version-git dir))))) ;; We put version info into the executable in the form that `ident' uses. (purecopy (concat "\n$Id: " (subst-char-in-string ?\n ?\s (emacs-version)) -- Dani Moncayo