Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(992)

Unified Diff: tools/emacs/trybot.el

Issue 5298012: Expand the file name match so that the match end can be used to limit path character substitution. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/tools/emacs
Patch Set: Fix a bad habit. Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/emacs/trybot-windows.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/emacs/trybot.el
diff --git a/tools/emacs/trybot.el b/tools/emacs/trybot.el
index 5953ade02fb29be14df5d6bb9f2dc340779ad6e8..6ced9b60d6e4a6be1794095207205c36289dc7c0 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.
« no previous file with comments | « no previous file | tools/emacs/trybot-windows.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698