aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGlenn Morris2012-04-09 19:03:33 -0400
committerGlenn Morris2012-04-09 19:03:33 -0400
commit263f20cd0a60e791e14ead267b5aefe7ad3e2dea (patch)
treecab6bb9a26138c18302cbba94553d3c33cec4092
parent05920a43fc18e696b464387e781e7cfdcea5b5af (diff)
downloademacs-263f20cd0a60e791e14ead267b5aefe7ad3e2dea.tar.gz
emacs-263f20cd0a60e791e14ead267b5aefe7ad3e2dea.zip
emacs-bzr-get-version tweak
* lisp/version.el (emacs-bzr-get-version): Handle lightweight checkouts of local branches.
-rw-r--r--lisp/ChangeLog8
-rw-r--r--lisp/version.el36
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 @@
12012-04-09 Glenn Morris <rgm@gnu.org>
2
3 * version.el (emacs-bzr-get-version):
4 Handle lightweight checkouts of local branches.
5
12012-04-09 Andreas Schwab <schwab@linux-m68k.org> 62012-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
62012-04-09 Chong Yidong <cyd@gnu.org> 102012-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.
85This is nil if Emacs was not built from a bzr checkout, or if we could 85This is nil if Emacs was not built from a bzr checkout, or if we could
86not determine the revision.") 86not determine the revision.")
87 87
88(defun emacs-bzr-get-version () "\ 88(defun emacs-bzr-get-version (&optional dir) "\
89Try to return as a string the bzr revision number of the Emacs sources. 89Try 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 90Returns 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 91not determine the revision. Note that this reports on the current state
92of the sources, which may not correspond to the running Emacs." 92of 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) 94Optional 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)