emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Setting the value of `emacs-bzr-version' also from a git checkout


From: Dani Moncayo
Subject: Re: Setting the value of `emacs-bzr-version' also from a git checkout
Date: Mon, 14 Oct 2013 08:38:45 +0200

>> 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 via email to

[Prev in Thread] Current Thread [Next in Thread]