all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dani Moncayo <dmoncayo@gmail.com>
To: Glenn Morris <rgm@gnu.org>
Cc: Emacs development discussions <emacs-devel@gnu.org>
Subject: Re: Setting the value of `emacs-bzr-version' also from a git checkout
Date: Mon, 14 Oct 2013 08:38:45 +0200	[thread overview]
Message-ID: <CAH8Pv0jqhtdmcF_DJCHD7hY1B8zSxHuA2b82TtpqU3NtaD-RYA@mail.gmail.com> (raw)
In-Reply-To: <0fk3hg3jg6.fsf@fencepost.gnu.org>

>> 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



  reply	other threads:[~2013-10-14  6:38 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-10-01 16:45 Setting the value of `emacs-bzr-version' also from a git checkout (was: Emacs trunk binary on Dropbox) Dani Moncayo
2013-10-01 17:04 ` Setting the value of `emacs-bzr-version' also from a git checkout Óscar Fuentes
2013-10-01 17:45 ` Andreas Schwab
2013-10-01 18:37   ` Dani Moncayo
2013-10-01 18:46     ` Óscar Fuentes
2013-10-01 21:15       ` Dani Moncayo
2013-10-02  0:22         ` Stefan Monnier
2013-10-02 14:36           ` Josh
2013-10-12 10:22           ` Dani Moncayo
2013-10-12 10:33             ` Eli Zaretskii
2013-10-12 10:42               ` Dani Moncayo
2013-10-12 10:51                 ` Óscar Fuentes
2013-10-12 10:58                   ` Dani Moncayo
2013-10-12 11:16                   ` Dani Moncayo
2013-10-12 11:40                     ` Eli Zaretskii
2013-10-12 12:04                       ` Dani Moncayo
2013-10-12 19:04                     ` Óscar Fuentes
2013-10-12 20:36                       ` Juanma Barranquero
2013-10-12 20:51                         ` Óscar Fuentes
2013-10-12 20:57                           ` Juanma Barranquero
2013-10-12 21:16                             ` Óscar Fuentes
2013-10-12 21:33                               ` Juanma Barranquero
2013-10-12 20:56                       ` Stefan Monnier
2013-10-12 21:25                       ` Dani Moncayo
2013-10-12 21:38                         ` Óscar Fuentes
2013-10-12 10:58                 ` Eli Zaretskii
2013-10-12 11:06                   ` Dani Moncayo
2013-10-12 11:37                     ` Eli Zaretskii
2013-10-13 20:49             ` Dani Moncayo
2013-10-13 22:16               ` Glenn Morris
2013-10-14  6:38                 ` Dani Moncayo [this message]
  -- strict thread matches above, loose matches on Subject: below --
2013-10-01 20:23 Dani Moncayo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CAH8Pv0jqhtdmcF_DJCHD7hY1B8zSxHuA2b82TtpqU3NtaD-RYA@mail.gmail.com \
    --to=dmoncayo@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=rgm@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.