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: Mon, 14 Oct 2013 08:38:45 +0200 Message-ID: References: <87a9is6g2a.fsf@igel.home> <87pprokewg.fsf@wanadoo.es> <0fk3hg3jg6.fsf@fencepost.gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: ger.gmane.org 1381732730 18225 80.91.229.3 (14 Oct 2013 06:38:50 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 14 Oct 2013 06:38:50 +0000 (UTC) Cc: Emacs development discussions To: Glenn Morris Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Mon Oct 14 08:38:55 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 1VVbnp-000612-1f for ged-emacs-devel@m.gmane.org; Mon, 14 Oct 2013 08:38:53 +0200 Original-Received: from localhost ([::1]:35509 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVbno-0000LE-N9 for ged-emacs-devel@m.gmane.org; Mon, 14 Oct 2013 02:38:52 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:49783) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVbnl-0000L8-PO for emacs-devel@gnu.org; Mon, 14 Oct 2013 02:38:50 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VVbnk-0003YT-Ds for emacs-devel@gnu.org; Mon, 14 Oct 2013 02:38:49 -0400 Original-Received: from mail-lb0-x22f.google.com ([2a00:1450:4010:c04::22f]:55170) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VVbni-0003Xr-QW; Mon, 14 Oct 2013 02:38:47 -0400 Original-Received: by mail-lb0-f175.google.com with SMTP id y6so5209189lbh.6 for ; Sun, 13 Oct 2013 23:38:45 -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=ToRuvEj6y0A7JR4MKEXWfB+V5vuluBDGc15CD9V1pyo=; b=lNujtGZpwBieT+LVwtmhoh3ar9NBMGpKY4VE0tOMO0nMl3w/YZDGvCQFLYSfANR0sz FpaBn0rApCWTpKhDFTYBh/ounvaGR/miDrmsEp2Dm5WZRrIKpNq2fHfKoUoV0zUnB7ga 0jS2QFDltqbD5FpIjMRrcrVz4jN77sE0Z8vVKsJoZHxIE3jkQk1fo6AfccQiO9u5SfpU h+B4mleA23ApE35hAHAfb8al9LJaLyr4V5V+WaFlLr/W7S+5YzbbEBZKJiO2hfhQPthB s8Itw2pupRoAtn5s0ZEAwBpilGVPIfjBcMkXs3XZPey7H8rGSgYwcg+kXni4DILQd/ia M8Cw== X-Received: by 10.152.115.176 with SMTP id jp16mr29341668lab.17.1381732725446; Sun, 13 Oct 2013 23:38:45 -0700 (PDT) Original-Received: by 10.114.176.231 with HTTP; Sun, 13 Oct 2013 23:38:45 -0700 (PDT) In-Reply-To: <0fk3hg3jg6.fsf@fencepost.gnu.org> X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4010:c04::22f 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:164192 Archived-At: >> Actually that patch was lacking a change in loadup.el: The call to >> `emacs-bzr-get-version' now has to pass `t' in the EXTERNAL argument, >> to open the possibility of asking the external version control program >> (bzr or git) if the "internal" method fails. > > The existing bzr implementation intentionally does not call any external > executable during building Emacs. (I have no opinion on/interest in what > any git version should do.) Ok, but note that in practice, no external executable would be called in the bzr case, because EXTERNAL is `t' (not `force'), and that means that the "internal" method will be tried first; only if that method fails (should never fail), the bzr executable would be called. IOW, the bzr case would work exactly as it does now. But if that argument doesn't convince you, there are alternative ways of doing this. For example this one (not tested yet): diff --git a/lisp/loadup.el b/lisp/loadup.el index c32bd00..093f34c 100644 --- a/lisp/loadup.el +++ b/lisp/loadup.el @@ -299,7 +299,9 @@ (string-to-number (substring name (length base) exelen)))) files))) - (setq emacs-bzr-version (condition-case nil (emacs-bzr-get-version) + (setq emacs-bzr-version (condition-case nil + (or (emacs-bzr-get-version) + (emacs-bzr-get-version-git)) (error nil))) ;; `emacs-version' is a constant, so we shouldn't change it with `setq'. (defconst emacs-version diff --git a/lisp/version.el b/lisp/version.el index 9667456..6c2c9c4 100644 --- a/lisp/version.el +++ b/lisp/version.el @@ -173,6 +173,27 @@ Otherwise only ask bzr if we cannot find any information ourselves." (external (emacs-bzr-version-bzr dir))))))) +(defun emacs-bzr-get-version-git (&optional dir) + "Try to return as a string the bzr revision of the Emacs sources. +The format is: [revno] revision_id, where revno may be absent. +Value is nil if we could not determine the revision. Note that +this reports on the current state of the sources, which may not +correspond to the running Emacs. + +Optional argument DIR is a directory to use instead of +`source-directory'. This directory should correspond to a git +mirror of a bzr branch, where the bzr revision data should be +stored as notes in each git revision." + (or dir (setq dir source-directory)) + (when (file-directory-p (expand-file-name ".git" dir)) + (message "Waiting for git...") + (with-temp-buffer + (if (zerop + (call-process "git" nil '(t nil) nil "log" + "-1" + "--pretty=format:%N")) + (replace-regexp-in-string "\n" "" (buffer-string)))))) + ;; 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)) " $\n")) -- Dani Moncayo