diff options
| -rw-r--r-- | lisp/ChangeLog | 9 | ||||
| -rw-r--r-- | lisp/vc/vc-bzr.el | 20 | ||||
| -rw-r--r-- | lisp/version.el | 73 |
3 files changed, 28 insertions, 74 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog index 2cc878d1ddd..018c6dfc2c4 100644 --- a/lisp/ChangeLog +++ b/lisp/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2015-01-17 Ulrich Müller <ulm@gentoo.org> | ||
| 2 | |||
| 3 | * version.el (emacs-bzr-version-dirstate, emacs-bzr-version-bzr): | ||
| 4 | Remove. | ||
| 5 | (emacs-repository-get-version): Discard the Bazaar case. | ||
| 6 | * vc/vc-bzr.el (vc-bzr-version-dirstate): Rename from | ||
| 7 | emacs-bzr-version-dirstate and move from version.el to here. | ||
| 8 | (vc-bzr-working-revision): Use it. | ||
| 9 | |||
| 1 | 2015-01-17 Stefan Monnier <monnier@iro.umontreal.ca> | 10 | 2015-01-17 Stefan Monnier <monnier@iro.umontreal.ca> |
| 2 | 11 | ||
| 3 | * emacs-lisp/eieio-generic.el (call-next-method): Don't bother checking | 12 | * emacs-lisp/eieio-generic.el (call-next-method): Don't bother checking |
diff --git a/lisp/vc/vc-bzr.el b/lisp/vc/vc-bzr.el index 163df1fdb5e..94574fdec62 100644 --- a/lisp/vc/vc-bzr.el +++ b/lisp/vc/vc-bzr.el | |||
| @@ -493,6 +493,22 @@ in the branch repository (or whose status not be determined)." | |||
| 493 | (add-hook 'after-save-hook 'vc-bzr-resolve-when-done nil t) | 493 | (add-hook 'after-save-hook 'vc-bzr-resolve-when-done nil t) |
| 494 | (message "There are unresolved conflicts in this file"))) | 494 | (message "There are unresolved conflicts in this file"))) |
| 495 | 495 | ||
| 496 | (defun vc-bzr-workfile-unchanged-p (file) | ||
| 497 | (eq 'unchanged (car (vc-bzr-status file)))) | ||
| 498 | |||
| 499 | (defun vc-bzr-version-dirstate (dir) | ||
| 500 | "Try to return as a string the bzr revision ID of directory DIR. | ||
| 501 | This uses the dirstate file's parent revision entry. | ||
| 502 | Returns nil if unable to find this information." | ||
| 503 | (let ((file (expand-file-name ".bzr/checkout/dirstate" dir))) | ||
| 504 | (when (file-readable-p file) | ||
| 505 | (with-temp-buffer | ||
| 506 | (insert-file-contents file) | ||
| 507 | (and (looking-at "#bazaar dirstate flat format 3") | ||
| 508 | (forward-line 3) | ||
| 509 | (looking-at "[0-9]+\0\\([^\0\n]+\\)\0") | ||
| 510 | (match-string 1)))))) | ||
| 511 | |||
| 496 | (defun vc-bzr-working-revision (file) | 512 | (defun vc-bzr-working-revision (file) |
| 497 | (let* ((rootdir (vc-bzr-root file)) | 513 | (let* ((rootdir (vc-bzr-root file)) |
| 498 | (branch-format-file (expand-file-name vc-bzr-admin-branch-format-file | 514 | (branch-format-file (expand-file-name vc-bzr-admin-branch-format-file |
| @@ -538,8 +554,8 @@ in the branch repository (or whose status not be determined)." | |||
| 538 | ;; files exist. | 554 | ;; files exist. |
| 539 | (and (file-exists-p branch-format-file) | 555 | (and (file-exists-p branch-format-file) |
| 540 | (file-exists-p lastrev-file) | 556 | (file-exists-p lastrev-file) |
| 541 | (equal (emacs-bzr-version-dirstate l-c-parent-dir) | 557 | (equal (vc-bzr-version-dirstate l-c-parent-dir) |
| 542 | (emacs-bzr-version-dirstate rootdir)))))) | 558 | (vc-bzr-version-dirstate rootdir)))))) |
| 543 | t))) | 559 | t))) |
| 544 | (with-temp-buffer | 560 | (with-temp-buffer |
| 545 | (insert-file-contents branch-format-file) | 561 | (insert-file-contents branch-format-file) |
diff --git a/lisp/version.el b/lisp/version.el index 75763b3f682..43778739ba6 100644 --- a/lisp/version.el +++ b/lisp/version.el | |||
| @@ -93,41 +93,6 @@ or if we could not determine the revision.") | |||
| 93 | (define-obsolete-variable-alias 'emacs-bzr-version | 93 | (define-obsolete-variable-alias 'emacs-bzr-version |
| 94 | 'emacs-repository-version "24.4") | 94 | 'emacs-repository-version "24.4") |
| 95 | 95 | ||
| 96 | (defun emacs-bzr-version-dirstate (dir) | ||
| 97 | "Try to return as a string the bzr revision ID of directory DIR. | ||
| 98 | This uses the dirstate file's parent revision entry. | ||
| 99 | Returns nil if unable to find this information." | ||
| 100 | (let ((file (expand-file-name ".bzr/checkout/dirstate" dir))) | ||
| 101 | (when (file-readable-p file) | ||
| 102 | (with-temp-buffer | ||
| 103 | (insert-file-contents file) | ||
| 104 | (and (looking-at "#bazaar dirstate flat format 3") | ||
| 105 | (forward-line 3) | ||
| 106 | (looking-at "[0-9]+\0\\([^\0\n]+\\)\0") | ||
| 107 | (match-string 1)))))) | ||
| 108 | |||
| 109 | (defun emacs-bzr-version-bzr (dir) | ||
| 110 | "Ask bzr itself for the version information for directory DIR." | ||
| 111 | ;; Comments on `bzr version-info': | ||
| 112 | ;; i) Unknown files also cause clean != 1. | ||
| 113 | ;; ii) It can be slow, contacting the upstream repo to get the | ||
| 114 | ;; branch nick if one is not set locally, even with a custom | ||
| 115 | ;; template that is not asking for the nick (as used here). You'd | ||
| 116 | ;; think the latter part would be trivial to fix: | ||
| 117 | ;; https://bugs.launchpad.net/bzr/+bug/882541/comments/3 | ||
| 118 | ;; https://bugs.launchpad.net/bzr/+bug/629150 | ||
| 119 | ;; You can set the nick locally with `bzr nick ...', which speeds | ||
| 120 | ;; things up enormously. `bzr revno' does not have this issue, but | ||
| 121 | ;; has no way to print the revision_id AFAICS. | ||
| 122 | (message "Waiting for bzr...") | ||
| 123 | (with-temp-buffer | ||
| 124 | (if (zerop | ||
| 125 | (call-process "bzr" nil '(t nil) nil "version-info" | ||
| 126 | "--custom" | ||
| 127 | "--template={revno} {revision_id} (clean = {clean})" | ||
| 128 | dir)) | ||
| 129 | (buffer-string)))) | ||
| 130 | |||
| 131 | (define-obsolete-function-alias 'emacs-bzr-get-version | 96 | (define-obsolete-function-alias 'emacs-bzr-get-version |
| 132 | 'emacs-repository-get-version "24.4") | 97 | 'emacs-repository-get-version "24.4") |
| 133 | 98 | ||
| @@ -145,43 +110,7 @@ maybe ask the VCS itself, if the sources appear to be under | |||
| 145 | version control. If `force', always ask. the VCS. Otherwise | 110 | version control. If `force', always ask. the VCS. Otherwise |
| 146 | only ask the VCS if we cannot find any information ourselves." | 111 | only ask the VCS if we cannot find any information ourselves." |
| 147 | (or dir (setq dir source-directory)) | 112 | (or dir (setq dir source-directory)) |
| 148 | (cond ((file-directory-p (expand-file-name ".bzr/branch" dir)) | 113 | (cond ((file-directory-p (expand-file-name ".git" dir)) |
| 149 | (if (eq external 'force) | ||
| 150 | (emacs-bzr-version-bzr dir) | ||
| 151 | (let (file loc rev) | ||
| 152 | (cond ((file-readable-p | ||
| 153 | (setq file (expand-file-name | ||
| 154 | ".bzr/branch/last-revision" dir))) | ||
| 155 | (with-temp-buffer | ||
| 156 | (insert-file-contents file) | ||
| 157 | (goto-char (point-max)) | ||
| 158 | (if (looking-back "\n") | ||
| 159 | (delete-char -1)) | ||
| 160 | (buffer-string))) | ||
| 161 | ;; OK, no last-revision. Is it a lightweight checkout? | ||
| 162 | ((file-readable-p | ||
| 163 | (setq file (expand-file-name ".bzr/branch/location" dir))) | ||
| 164 | (setq rev (emacs-bzr-version-dirstate dir)) | ||
| 165 | ;; If parent branch is local, try looking there for the rev. | ||
| 166 | ;; Note: there is no guarantee that the parent branch's rev | ||
| 167 | ;; corresponds to this branch. This branch could have | ||
| 168 | ;; been made with a specific -r revno argument, or the | ||
| 169 | ;; parent could have been updated since this branch was | ||
| 170 | ;; created. | ||
| 171 | ;; To try and detect this, we check the dirstate revids | ||
| 172 | ;; to see if they match. | ||
| 173 | (if (and (setq loc (with-temp-buffer | ||
| 174 | (insert-file-contents file) | ||
| 175 | (if (looking-at "file://\\(.*\\)") | ||
| 176 | (match-string 1)))) | ||
| 177 | (equal rev (emacs-bzr-version-dirstate loc))) | ||
| 178 | (emacs-repository-get-version loc) | ||
| 179 | ;; If parent does not match, the best we can do without | ||
| 180 | ;; calling external commands is to use the dirstate rev. | ||
| 181 | rev)) | ||
| 182 | (external | ||
| 183 | (emacs-bzr-version-bzr dir)))))) | ||
| 184 | ((file-directory-p (expand-file-name ".git" dir)) | ||
| 185 | (message "Waiting for git...") | 114 | (message "Waiting for git...") |
| 186 | (with-temp-buffer | 115 | (with-temp-buffer |
| 187 | (let ((default-directory (file-name-as-directory dir))) | 116 | (let ((default-directory (file-name-as-directory dir))) |