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: Sat, 12 Oct 2013 12:22:29 +0200

On Wed, Oct 2, 2013 at 2:22 AM, Stefan Monnier <address@hidden> 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 address@hidden"
 ^^^^^^^
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



reply via email to

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