diff options
Diffstat (limited to 'lisp/version.el')
| -rw-r--r-- | lisp/version.el | 49 |
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 "\ |
| 84 | String giving the bzr revision number from which this Emacs was built. | 84 | String giving the bzr revision from which this Emacs was built. |
| 85 | This is nil if Emacs was not built from a bzr checkout, or if we could | 85 | Value is the bzr revision number and a revision ID separated by a blank. |
| 86 | Value is nil if Emacs was not built from a bzr checkout, or if we could | ||
| 86 | not determine the revision.") | 87 | not determine the revision.") |
| 87 | 88 | ||
| 88 | (defun emacs-bzr-get-version () "\ | 89 | (defun emacs-bzr-get-version (&optional dir) "\ |
| 89 | Try to return as a string the bzr revision number of the Emacs sources. | 90 | Try to return as a string the bzr revision number of the Emacs sources. |
| 90 | Returns nil if the sources do not seem to be under bzr, or if we could | 91 | Value is the bzr revision number and a revision ID separated by a blank. |
| 92 | Value is nil if the sources do not seem to be under bzr, or if we could | ||
| 91 | not determine the revision. Note that this reports on the current state | 93 | not determine the revision. Note that this reports on the current state |
| 92 | of the sources, which may not correspond to the running Emacs." | 94 | of 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) | 96 | Optional 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 |