aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/version.el
diff options
context:
space:
mode:
authorPaul Eggert2012-04-21 17:53:32 -0700
committerPaul Eggert2012-04-21 17:53:32 -0700
commitbbd347f5f7e99da1a559dad818b5fa8f59c0901e (patch)
tree77c1fc54c2240b08d2859109d18cac8812a8ffb1 /lisp/version.el
parente4ecdc9c71af4199129d5dd2db1a32ff6b725fe4 (diff)
parent9ee7d8b93cb143b473e6dffb708e777bc6fe5bd0 (diff)
downloademacs-bbd347f5f7e99da1a559dad818b5fa8f59c0901e.tar.gz
emacs-bbd347f5f7e99da1a559dad818b5fa8f59c0901e.zip
Merge from trunk.
Diffstat (limited to 'lisp/version.el')
-rw-r--r--lisp/version.el49
1 files changed, 33 insertions, 16 deletions
diff --git a/lisp/version.el b/lisp/version.el
index a4bc4fd54a6..d7fb05ea465 100644
--- a/lisp/version.el
+++ b/lisp/version.el
@@ -81,28 +81,45 @@ to the system configuration; look at `system-configuration' instead."
81 81
82;; Set during dumping, this is a defvar so that it can be setq'd. 82;; Set during dumping, this is a defvar so that it can be setq'd.
83(defvar emacs-bzr-version nil "\ 83(defvar emacs-bzr-version nil "\
84String giving the bzr revision number from which this Emacs was built. 84String giving the bzr revision from which this Emacs was built.
85This is nil if Emacs was not built from a bzr checkout, or if we could 85Value is the bzr revision number and a revision ID separated by a blank.
86Value is nil if Emacs was not built from a bzr checkout, or if we could
86not determine the revision.") 87not determine the revision.")
87 88
88(defun emacs-bzr-get-version () "\ 89(defun emacs-bzr-get-version (&optional dir) "\
89Try to return as a string the bzr revision number of the Emacs sources. 90Try to return as a string the bzr revision number of the Emacs sources.
90Returns nil if the sources do not seem to be under bzr, or if we could 91Value is the bzr revision number and a revision ID separated by a blank.
92Value is nil if the sources do not seem to be under bzr, or if we could
91not determine the revision. Note that this reports on the current state 93not determine the revision. Note that this reports on the current state
92of the sources, which may not correspond to the running Emacs." 94of the sources, which may not correspond to the running Emacs.
93 (let ((file (expand-file-name ".bzr/branch/last-revision" source-directory))) 95
94 (if (file-readable-p file) 96Optional argument DIR is a directory to use instead of `source-directory'."
95 (with-temp-buffer 97 (or dir (setq dir source-directory))
96 (insert-file-contents file) 98 (when (file-directory-p (setq dir (expand-file-name ".bzr/branch" dir)))
97 (goto-char (point-max)) 99 (let (file loc)
98 (if (looking-back "\n") 100 (cond ((file-readable-p
99 (delete-char -1)) 101 (setq file (expand-file-name "last-revision" dir)))
100 (buffer-string))))) 102 (with-temp-buffer
103 (insert-file-contents file)
104 (goto-char (point-max))
105 (if (looking-back "\n")
106 (delete-char -1))
107 (buffer-string)))
108 ;; OK, no last-revision. Is it a lightweight checkout?
109 ((file-readable-p
110 (setq file (expand-file-name "location" dir)))
111 ;; If the parent branch is local, try looking there for the revid.
112 (if (setq loc (with-temp-buffer
113 (insert-file-contents file)
114 (if (looking-at "file://\\(.*\\)")
115 (match-string 1))))
116 (emacs-bzr-get-version loc)))
117 ;; Could fall back to eg `bzr testament' at this point.
118 ))))
101 119
102;; We put version info into the executable in the form that `ident' uses. 120;; We put version info into the executable in the form that `ident' uses.
103(or (eq system-type 'windows-nt) 121(purecopy (concat "\n$Id: " (subst-char-in-string ?\n ?\s (emacs-version))
104 (purecopy (concat "\n$Id: " (subst-char-in-string ?\n ?\s (emacs-version)) 122 " $\n"))
105 " $\n")))
106 123
107;; Local Variables: 124;; Local Variables:
108;; version-control: never 125;; version-control: never