summaryrefslogtreecommitdiffstats
path: root/tools/emacs/trybot.el
diff options
context:
space:
mode:
authorscottbyer@google.com <scottbyer@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-02 00:11:11 +0000
committerscottbyer@google.com <scottbyer@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-12-02 00:11:11 +0000
commit08062acaa16fa22532e9698fb3e1ad4d9761ae48 (patch)
tree05df2d6ec83b974209d6a40f65adfdba0001e0df /tools/emacs/trybot.el
parent867b76d63d12736535ab4519ba706d08fbd3ad77 (diff)
downloadchromium_src-08062acaa16fa22532e9698fb3e1ad4d9761ae48.zip
chromium_src-08062acaa16fa22532e9698fb3e1ad4d9761ae48.tar.gz
chromium_src-08062acaa16fa22532e9698fb3e1ad4d9761ae48.tar.bz2
Expand the file name match so that the match end can be used to limit path character substitution.
BUG=none TEST=Run on trybot-windows.txt, \base\ remains that way in the first warning. Review URL: http://codereview.chromium.org/5298012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67911 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools/emacs/trybot.el')
-rw-r--r--tools/emacs/trybot.el41
1 files changed, 35 insertions, 6 deletions
diff --git a/tools/emacs/trybot.el b/tools/emacs/trybot.el
index 5953ade..6ced9b6 100644
--- a/tools/emacs/trybot.el
+++ b/tools/emacs/trybot.el
@@ -16,6 +16,30 @@
(defun get-chrome-root ()
(or chrome-root default-directory))
+; Hunt down from the top, case correcting each path component as needed.
+; Currently does not keep a cache. Returns nil if no matching file can be
+; figured out.
+(defun case-corrected-filename (filename)
+ (save-match-data
+ (let ((path-components (split-string filename "/"))
+ (corrected-path (file-name-as-directory (get-chrome-root))))
+ (mapc
+ (function
+ (lambda (elt)
+ (if corrected-path
+ (let ((next-component
+ (car (member-ignore-case
+ elt (directory-files corrected-path)))))
+ (setq corrected-path
+ (and next-component
+ (file-name-as-directory
+ (concat corrected-path next-component))))))))
+ path-components)
+ (if corrected-path
+ (file-relative-name (directory-file-name corrected-path)
+ (get-chrome-root))
+ nil))))
+
(defun trybot-fixup ()
"Parse and fixup the contents of the current buffer as trybot output."
@@ -31,15 +55,20 @@
(goto-char (point-min))
; Fix Windows paths ("d:\...\src\").
; TODO: need to fix case; e.g. third_party/webkit -> third_party/WebKit. :(
- (while (re-search-forward "^.:\\\\.*\\\\src\\\\" nil t)
- (replace-match "")
+ (while (re-search-forward "\\(^.:\\\\.*\\\\src\\\\\\)\\(.*?\\)[(:]" nil t)
+ (replace-match "" nil t nil 1)
; Line now looks like:
; foo\bar\baz.cc error message here
; We want to fixup backslashes in path into forward slashes, without
- ; modifying the error message.
- ; XXX current eats backslashes after the filename; how can I limit it to
- ; changing from current point up to the first space?
- (subst-char-in-region (point) (line-end-position) ?\\ ?/))
+ ; modifying the error message - by matching up to the first colon above
+ ; (which will be just beyond the end of the filename) we can use the end of
+ ; the match as a limit.
+ (subst-char-in-region (point) (match-end 0) ?\\ ?/)
+ ; See if we can correct the file name casing.
+ (let ((filename (buffer-substring (match-beginning 2) (match-end 2))))
+ (if (and (not (file-exists-p filename))
+ (setq filename (case-corrected-filename filename)))
+ (replace-match filename t t nil 2))))
(goto-char (point-min))
;; Switch into compilation mode.