diff options
| author | Glenn Morris | 2012-04-09 19:03:33 -0400 |
|---|---|---|
| committer | Glenn Morris | 2012-04-09 19:03:33 -0400 |
| commit | 263f20cd0a60e791e14ead267b5aefe7ad3e2dea (patch) | |
| tree | cab6bb9a26138c18302cbba94553d3c33cec4092 /lisp | |
| parent | 05920a43fc18e696b464387e781e7cfdcea5b5af (diff) | |
| download | emacs-263f20cd0a60e791e14ead267b5aefe7ad3e2dea.tar.gz emacs-263f20cd0a60e791e14ead267b5aefe7ad3e2dea.zip | |
emacs-bzr-get-version tweak
* lisp/version.el (emacs-bzr-get-version):
Handle lightweight checkouts of local branches.
Diffstat (limited to 'lisp')
| -rw-r--r-- | lisp/ChangeLog | 8 | ||||
| -rw-r--r-- | lisp/version.el | 36 |
2 files changed, 32 insertions, 12 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 954daf68510..a3f992eb9dc 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,7 +1,11 @@ | |||
| 1 | 2012-04-09 Glenn Morris <rgm@gnu.org> | ||
| 2 | |||
| 3 | * version.el (emacs-bzr-get-version): | ||
| 4 | Handle lightweight checkouts of local branches. | ||
| 5 | |||
| 1 | 2012-04-09 Andreas Schwab <schwab@linux-m68k.org> | 6 | 2012-04-09 Andreas Schwab <schwab@linux-m68k.org> |
| 2 | 7 | ||
| 3 | * international/characters.el: Recover lost case pairs. | 8 | * international/characters.el: Recover lost case pairs. (Bug#11209) |
| 4 | (Bug#11209) | ||
| 5 | 9 | ||
| 6 | 2012-04-09 Chong Yidong <cyd@gnu.org> | 10 | 2012-04-09 Chong Yidong <cyd@gnu.org> |
| 7 | 11 | ||
diff --git a/lisp/version.el b/lisp/version.el index a4bc4fd54a6..56e19147b2c 100644 --- a/lisp/version.el +++ b/lisp/version.el | |||
| @@ -85,19 +85,35 @@ String giving the bzr revision number from which this Emacs was built. | |||
| 85 | This is nil if Emacs was not built from a bzr checkout, or if we could | 85 | This is nil if Emacs was not built from a bzr checkout, or if we could |
| 86 | not determine the revision.") | 86 | not determine the revision.") |
| 87 | 87 | ||
| 88 | (defun emacs-bzr-get-version () "\ | 88 | (defun emacs-bzr-get-version (&optional dir) "\ |
| 89 | Try to return as a string the bzr revision number of the Emacs sources. | 89 | 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 | 90 | Returns 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 | 91 | not determine the revision. Note that this reports on the current state |
| 92 | of the sources, which may not correspond to the running Emacs." | 92 | of the sources, which may not correspond to the running Emacs. |
| 93 | (let ((file (expand-file-name ".bzr/branch/last-revision" source-directory))) | 93 | |
| 94 | (if (file-readable-p file) | 94 | Optional argument DIR is a directory to use instead of `source-directory'." |
| 95 | (with-temp-buffer | 95 | (or dir (setq dir source-directory)) |
| 96 | (insert-file-contents file) | 96 | (when (file-directory-p (setq dir (expand-file-name ".bzr/branch" dir))) |
| 97 | (goto-char (point-max)) | 97 | (let (file loc) |
| 98 | (if (looking-back "\n") | 98 | (cond ((file-readable-p |
| 99 | (delete-char -1)) | 99 | (setq file (expand-file-name "last-revision" dir))) |
| 100 | (buffer-string))))) | 100 | (with-temp-buffer |
| 101 | (insert-file-contents file) | ||
| 102 | (goto-char (point-max)) | ||
| 103 | (if (looking-back "\n") | ||
| 104 | (delete-char -1)) | ||
| 105 | (buffer-string))) | ||
| 106 | ;; OK, no last-revision. Is it a lightweight checkout? | ||
| 107 | ((file-readable-p | ||
| 108 | (setq file (expand-file-name "location" dir))) | ||
| 109 | ;; If the parent branch is local, try looking there for the revid. | ||
| 110 | (if (setq loc (with-temp-buffer | ||
| 111 | (insert-file-contents file) | ||
| 112 | (if (looking-at "file://\\(.*\\)") | ||
| 113 | (match-string 1)))) | ||
| 114 | (emacs-bzr-get-version loc))) | ||
| 115 | ;; Could fall back to eg `bzr testament' at this point. | ||
| 116 | )))) | ||
| 101 | 117 | ||
| 102 | ;; We put version info into the executable in the form that `ident' uses. | 118 | ;; We put version info into the executable in the form that `ident' uses. |
| 103 | (or (eq system-type 'windows-nt) | 119 | (or (eq system-type 'windows-nt) |