all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dani Moncayo <dmoncayo@gmail.com>
To: Stefan Monnier <monnier@iro.umontreal.ca>
Cc: "Óscar Fuentes" <ofv@wanadoo.es>,
	"Emacs development discussions" <emacs-devel@gnu.org>
Subject: Re: Setting the value of `emacs-bzr-version' also from a git checkout
Date: Sat, 12 Oct 2013 12:22:29 +0200	[thread overview]
Message-ID: <CAH8Pv0i2Bo5NaCZsxV+EdX_JNBBdLNbKkkc8rZL4PXwm3vP_aw@mail.gmail.com> (raw)
In-Reply-To: <jwvk3hwfrod.fsf-monnier+emacs@gnu.org>

On Wed, Oct 2, 2013 at 2:22 AM, Stefan Monnier <monnier@iro.umontreal.ca> 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



  parent reply	other threads:[~2013-10-12 10:22 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 [this message]
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
  -- 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=CAH8Pv0i2Bo5NaCZsxV+EdX_JNBBdLNbKkkc8rZL4PXwm3vP_aw@mail.gmail.com \
    --to=dmoncayo@gmail.com \
    --cc=emacs-devel@gnu.org \
    --cc=monnier@iro.umontreal.ca \
    --cc=ofv@wanadoo.es \
    /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.