aboutsummaryrefslogtreecommitdiffstats
path: root/lisp
diff options
context:
space:
mode:
authorJoakim Verona2013-01-07 00:03:49 +0100
committerJoakim Verona2013-01-07 00:03:49 +0100
commitbe73be611d160876f9df633ff3a2d86eb78f65c7 (patch)
treeda818705af78c54104d99583e7895d7e0d0f5cb6 /lisp
parentb18e01b65e651d3b626b4edcaaa2aa636fe25b69 (diff)
parent84f6744ab74d1c5f201e88273fc6faa65956a440 (diff)
downloademacs-be73be611d160876f9df633ff3a2d86eb78f65c7.tar.gz
emacs-be73be611d160876f9df633ff3a2d86eb78f65c7.zip
auto upstream
Diffstat (limited to 'lisp')
-rw-r--r--lisp/ChangeLog37
-rw-r--r--lisp/net/tramp-adb.el163
-rw-r--r--lisp/vc/vc-hooks.el28
-rw-r--r--lisp/vc/vc.el15
4 files changed, 179 insertions, 64 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 5b54d34743c..9425ca5cdc2 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,40 @@
12013-01-06 Jürgen Hötzel <juergen@archlinux.org>
2
3 * net/tramp-adb.el (tramp-methods): Add `tramp-tmpdir' entry.
4
52013-01-06 Michael Albinus <michael.albinus@gmx.de>
6
7 * net/tramp-adb.el (tramp-adb-ls-toolbox-regexp): The file size can
8 consist of mor than one digit.
9 (tramp-adb-file-name-handler-alist): Use
10 `tramp-handle-file-exists-p' consistently.
11 (tramp-adb-file-name-handler): Don't tweak `tramp-default-host'.
12 (tramp-adb-handle-file-exists-p): Remove function.
13 (tramp-adb-file-name-host): New defun.
14 (tramp-adb-execute-adb-command, tramp-adb-maybe-open-connection):
15 Use it.
16 (tramp-adb-maybe-open-connection): Set "remote-path" property.
17
182013-01-06 Chong Yidong <cyd@gnu.org>
19
20 * vc/vc.el (vc-next-action): Detect buffer modifications
21 conflicting with locking VCS operation (Bug#11490).
22
23 * vc/vc-hooks.el (vc-after-save): DTRT for locking VCSes.
24
252013-01-05 Michael Albinus <michael.albinus@gmx.de>
26
27 * net/tramp-adb.el (tramp-do-parse-file-attributes-with-ls):
28 (tramp-adb-handle-directory-files-and-attributes): Fix typos.
29
302013-01-05 Jürgen Hötzel <juergen@archlinux.org>
31
32 * net/tramp-adb.el (tramp-adb-handle-file-attributes): More robust
33 parsing of ls output using regular expression (handle filenames
34 with spaces). Use virtual device number.
35 (tramp-do-parse-file-attributes-with-ls): New defun (Code
36 cleanup).
37
12013-01-04 Daiki Ueno <ueno@gnu.org> 382013-01-04 Daiki Ueno <ueno@gnu.org>
2 39
3 * epg.el: Silence byte-compiler warnings. 40 * epg.el: Silence byte-compiler warnings.
diff --git a/lisp/net/tramp-adb.el b/lisp/net/tramp-adb.el
index b5f99ffc93c..bb9ff015ac3 100644
--- a/lisp/net/tramp-adb.el
+++ b/lisp/net/tramp-adb.el
@@ -56,8 +56,18 @@
56(defconst tramp-adb-ls-date-regexp 56(defconst tramp-adb-ls-date-regexp
57 "[[:space:]][0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9][[:space:]][0-9][0-9]:[0-9][0-9][[:space:]]") 57 "[[:space:]][0-9]\\{4\\}-[0-9][0-9]-[0-9][0-9][[:space:]][0-9][0-9]:[0-9][0-9][[:space:]]")
58 58
59(defconst tramp-adb-ls-toolbox-regexp
60 (concat
61 "^[[:space:]]*\\([-[:alpha:]]+\\)" ; \1 permissions
62 "[[:space:]]*\\([^[:space:]]+\\)" ; \2 username
63 "[[:space:]]+\\([^[:space:]]+\\)" ; \3 group
64 "[[:space:]]+\\([[:digit:]]+\\)" ; \4 size
65 "[[:space:]]+\\([-[:digit:]]+[[:space:]][:[:digit:]]+\\)" ; \5 date
66 "[[:space:]]+\\(.*\\)$")) ; \6 filename
67
59;;;###tramp-autoload 68;;;###tramp-autoload
60(add-to-list 'tramp-methods `(,tramp-adb-method)) 69(add-to-list 'tramp-methods `(,tramp-adb-method
70 (tramp-tmpdir "/data/local/tmp")))
61 71
62;;;###tramp-autoload 72;;;###tramp-autoload
63(eval-after-load 'tramp 73(eval-after-load 'tramp
@@ -86,8 +96,8 @@
86 (file-directory-p . tramp-adb-handle-file-directory-p) 96 (file-directory-p . tramp-adb-handle-file-directory-p)
87 (file-symlink-p . tramp-handle-file-symlink-p) 97 (file-symlink-p . tramp-handle-file-symlink-p)
88 ;; FIXME: This is too sloppy. 98 ;; FIXME: This is too sloppy.
89 (file-executable-p . file-exists-p) 99 (file-executable-p . tramp-handle-file-exists-p)
90 (file-exists-p . tramp-adb-handle-file-exists-p) 100 (file-exists-p . tramp-handle-file-exists-p)
91 (file-readable-p . tramp-handle-file-exists-p) 101 (file-readable-p . tramp-handle-file-exists-p)
92 (file-writable-p . tramp-adb-handle-file-writable-p) 102 (file-writable-p . tramp-adb-handle-file-writable-p)
93 (file-local-copy . tramp-adb-handle-file-local-copy) 103 (file-local-copy . tramp-adb-handle-file-local-copy)
@@ -95,6 +105,9 @@
95 (expand-file-name . tramp-adb-handle-expand-file-name) 105 (expand-file-name . tramp-adb-handle-expand-file-name)
96 (find-backup-file-name . tramp-handle-find-backup-file-name) 106 (find-backup-file-name . tramp-handle-find-backup-file-name)
97 (directory-files . tramp-handle-directory-files) 107 (directory-files . tramp-handle-directory-files)
108 (directory-files-and-attributes
109 . tramp-adb-handle-directory-files-and-attributes)
110 (file-name-all-completions . tramp-sh-handle-file-name-all-completions)
98 (make-directory . tramp-adb-handle-make-directory) 111 (make-directory . tramp-adb-handle-make-directory)
99 (delete-directory . tramp-adb-handle-delete-directory) 112 (delete-directory . tramp-adb-handle-delete-directory)
100 (delete-file . tramp-adb-handle-delete-file) 113 (delete-file . tramp-adb-handle-delete-file)
@@ -127,13 +140,7 @@
127 "Invoke the ADB handler for OPERATION. 140 "Invoke the ADB handler for OPERATION.
128First arg specifies the OPERATION, second arg is a list of arguments to 141First arg specifies the OPERATION, second arg is a list of arguments to
129pass to the OPERATION." 142pass to the OPERATION."
130 (let ((fn (assoc operation tramp-adb-file-name-handler-alist)) 143 (let ((fn (assoc operation tramp-adb-file-name-handler-alist)))
131 ;; `tramp-default-host's default value is (system-name). Not
132 ;; useful for us.
133 (tramp-default-host
134 (unless (equal (eval (car (get 'tramp-default-host 'standard-value)))
135 tramp-default-host)
136 tramp-default-host)))
137 (if fn 144 (if fn
138 (save-match-data (apply (cdr fn) args)) 145 (save-match-data (apply (cdr fn) args))
139 (tramp-run-real-handler operation args)))) 146 (tramp-run-real-handler operation args))))
@@ -280,30 +287,73 @@ pass to the OPERATION."
280 (tramp-shell-quote-argument localname)) "") 287 (tramp-shell-quote-argument localname)) "")
281 (with-current-buffer (tramp-get-buffer v) 288 (with-current-buffer (tramp-get-buffer v)
282 (tramp-adb-sh-fix-ls-output) 289 (tramp-adb-sh-fix-ls-output)
283 (let* ((columns (split-string (buffer-string))) 290 (cdar (tramp-do-parse-file-attributes-with-ls v id-format)))))))
284 (mod-string (nth 0 columns)) 291
285 (is-dir (eq ?d (aref mod-string 0))) 292(defun tramp-do-parse-file-attributes-with-ls (vec &optional id-format)
286 (is-symlink (eq ?l (aref mod-string 0))) 293 "Parse `file-attributes' for Tramp files using the ls(1) command."
287 (symlink-target 294 (with-current-buffer (tramp-get-buffer vec)
288 (and is-symlink 295 (goto-char (point-min))
289 (cadr (split-string (buffer-string) "\\( -> \\|\n\\)")))) 296 (let ((file-properties nil))
290 (uid (nth 1 columns)) 297 (while (re-search-forward tramp-adb-ls-toolbox-regexp nil t)
291 (gid (nth 2 columns)) 298 (let* ((mod-string (match-string 1))
292 (date (format "%s %s" (nth 4 columns) (nth 5 columns))) 299 (is-dir (eq ?d (aref mod-string 0)))
293 (size (string-to-number (nth 3 columns)))) 300 (is-symlink (eq ?l (aref mod-string 0)))
294 (list 301 (uid (match-string 2))
295 (or is-dir symlink-target) 302 (gid (match-string 3))
296 1 ;link-count 303 (size (string-to-number (match-string 4)))
297 ;; no way to handle numeric ids in Androids ash 304 (date (match-string 5))
298 (if (eq id-format 'integer) 0 uid) 305 (name (match-string 6))
299 (if (eq id-format 'integer) 0 gid) 306 (symlink-target
300 '(0 0) ; atime 307 (and is-symlink
301 (date-to-time date) ; mtime 308 (cadr (split-string name "\\( -> \\|\n\\)")))))
302 '(0 0) ; ctime 309 (push (list
303 size 310 name
304 mod-string 311 (or is-dir symlink-target)
305 ;; fake 312 1 ;link-count
306 t 1 1))))))) 313 ;; no way to handle numeric ids in Androids ash
314 (if (eq id-format 'integer) 0 uid)
315 (if (eq id-format 'integer) 0 gid)
316 '(0 0) ; atime
317 (date-to-time date) ; mtime
318 '(0 0) ; ctime
319 size
320 mod-string
321 ;; fake
322 t 1
323 (tramp-get-device vec))
324 file-properties)))
325 file-properties)))
326
327(defun tramp-adb-handle-directory-files-and-attributes
328 (directory &optional full match nosort id-format)
329 "Like `directory-files-and-attributes' for Tramp files."
330 (when (file-directory-p directory)
331 (with-parsed-tramp-file-name (expand-file-name directory) nil
332 (with-tramp-file-property
333 v localname (format "directory-files-attributes-%s-%s-%s-%s"
334 full match id-format nosort)
335 (tramp-adb-barf-unless-okay
336 v (format "%s -a -l %s"
337 (tramp-adb-get-ls-command v)
338 (tramp-shell-quote-argument localname)) "")
339 (with-current-buffer (tramp-get-buffer v)
340 (tramp-adb-sh-fix-ls-output)
341 (let ((result (tramp-do-parse-file-attributes-with-ls
342 v (or id-format 'integer))))
343 (when full
344 (setq result
345 (mapcar
346 (lambda (x)
347 (cons (expand-file-name (car x) directory) (cdr x)))
348 result)))
349 (unless nosort
350 (setq result
351 (sort result (lambda (x y) (string< (car x) (car y))))))
352 (delq nil
353 (mapcar (lambda (x)
354 (if (or (not match) (string-match match (car x)))
355 x))
356 result))))))))
307 357
308(defun tramp-adb-get-ls-command (vec) 358(defun tramp-adb-get-ls-command (vec)
309 (with-tramp-connection-property vec "ls" 359 (with-tramp-connection-property vec "ls"
@@ -885,20 +935,19 @@ PRESERVE-UID-GID and PRESERVE-EXTENDED-ATTRIBUTES are completely ignored."
885 (tramp-set-connection-property v "process-name" nil) 935 (tramp-set-connection-property v "process-name" nil)
886 (tramp-set-connection-property v "process-buffer" nil))))) 936 (tramp-set-connection-property v "process-buffer" nil)))))
887 937
888;; Android < 4 doesn't provide test command.
889
890(defun tramp-adb-handle-file-exists-p (filename)
891 "Like `file-exists-p' for Tramp files."
892 (with-parsed-tramp-file-name filename nil
893 (with-tramp-file-property v localname "file-exists-p"
894 (file-attributes filename))))
895
896;; Helper functions. 938;; Helper functions.
897 939
940(defun tramp-adb-file-name-host (vec)
941 "Return host component of VEC.
942If it is equal to the default value of `tramp-default-host', `nil' is returned."
943 (let ((host (tramp-file-name-host vec)))
944 (unless (equal host (eval (car (get 'tramp-default-host 'standard-value))))
945 host)))
946
898(defun tramp-adb-execute-adb-command (vec &rest args) 947(defun tramp-adb-execute-adb-command (vec &rest args)
899 "Returns nil on success error-output on failure." 948 "Returns nil on success error-output on failure."
900 (when (tramp-file-name-host vec) 949 (when (tramp-adb-file-name-host vec)
901 (setq args (append (list "-s" (tramp-file-name-host vec)) args))) 950 (setq args (append (list "-s" (tramp-adb-file-name-host vec)) args)))
902 (with-temp-buffer 951 (with-temp-buffer
903 (prog1 952 (prog1
904 (unless (zerop (apply 'call-process (tramp-adb-program) nil t nil args)) 953 (unless (zerop (apply 'call-process (tramp-adb-program) nil t nil args))
@@ -1006,21 +1055,21 @@ connection if a previous connection has died for some reason."
1006 (when (and p (processp p)) (delete-process p)) 1055 (when (and p (processp p)) (delete-process p))
1007 (if (not devices) 1056 (if (not devices)
1008 (tramp-error vec 'file-error "No device connected")) 1057 (tramp-error vec 'file-error "No device connected"))
1009 (if (and (tramp-file-name-host vec) 1058 (if (and (tramp-adb-file-name-host vec)
1010 (not (member (tramp-file-name-host vec) devices))) 1059 (not (member (tramp-adb-file-name-host vec) devices)))
1011 (tramp-error 1060 (tramp-error
1012 vec 'file-error 1061 vec 'file-error
1013 "Device %s not connected" (tramp-file-name-host vec))) 1062 "Device %s not connected" (tramp-adb-file-name-host vec)))
1014 (if (and (not (eq (length devices) 1)) 1063 (if (and (not (eq (length devices) 1))
1015 (not (tramp-file-name-host vec))) 1064 (not (tramp-adb-file-name-host vec)))
1016 (tramp-error 1065 (tramp-error
1017 vec 'file-error 1066 vec 'file-error
1018 "Multiple Devices connected: No Host/Device specified")) 1067 "Multiple Devices connected: No Host/Device specified"))
1019 (with-tramp-progress-reporter vec 3 "Opening adb shell connection" 1068 (with-tramp-progress-reporter vec 3 "Opening adb shell connection"
1020 (let* ((coding-system-for-read 'utf-8-dos) ;is this correct? 1069 (let* ((coding-system-for-read 'utf-8-dos) ;is this correct?
1021 (process-connection-type tramp-process-connection-type) 1070 (process-connection-type tramp-process-connection-type)
1022 (args (if (tramp-file-name-host vec) 1071 (args (if (tramp-adb-file-name-host vec)
1023 (list "-s" (tramp-file-name-host vec) "shell") 1072 (list "-s" (tramp-adb-file-name-host vec) "shell")
1024 (list "shell"))) 1073 (list "shell")))
1025 (p (let ((default-directory 1074 (p (let ((default-directory
1026 (tramp-compat-temporary-file-directory))) 1075 (tramp-compat-temporary-file-directory)))
@@ -1056,7 +1105,19 @@ connection if a previous connection has died for some reason."
1056 vec 3 1105 vec 3
1057 "Connection reset, because remote host changed from `%s' to `%s'" 1106 "Connection reset, because remote host changed from `%s' to `%s'"
1058 old-getprop new-getprop) 1107 old-getprop new-getprop)
1059 (tramp-adb-maybe-open-connection vec))))))))) 1108 (tramp-adb-maybe-open-connection vec)))
1109
1110 ;; Set "remote-path" connection property. This is needed
1111 ;; for eshell.
1112 (tramp-adb-send-command vec "echo \\\"$PATH\\\"")
1113 (tramp-set-connection-property
1114 vec "remote-path"
1115 (split-string
1116 (with-current-buffer (tramp-get-connection-buffer vec)
1117 ;; Read the expression.
1118 (goto-char (point-min))
1119 (read (current-buffer)))
1120 ":" 'omit-nulls))))))))
1060 1121
1061(provide 'tramp-adb) 1122(provide 'tramp-adb)
1062;;; tramp-adb.el ends here 1123;;; tramp-adb.el ends here
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index 5a2b47bb34f..99436303fa2 100644
--- a/lisp/vc/vc-hooks.el
+++ b/lisp/vc/vc-hooks.el
@@ -703,19 +703,21 @@ Before doing that, check if there are any old backups and get rid of them."
703 ;; the state to 'edited and redisplay the mode line. 703 ;; the state to 'edited and redisplay the mode line.
704 (let* ((file buffer-file-name) 704 (let* ((file buffer-file-name)
705 (backend (vc-backend file))) 705 (backend (vc-backend file)))
706 (and backend 706 (cond
707 (or (and (equal (vc-file-getprop file 'vc-checkout-time) 707 ((null backend))
708 (nth 5 (file-attributes file))) 708 ((eq (vc-checkout-model backend (list file)) 'implicit)
709 ;; File has been saved in the same second in which 709 ;; If the file was saved in the same second in which it was
710 ;; it was checked out. Clear the checkout-time 710 ;; checked out, clear the checkout-time to avoid confusion.
711 ;; to avoid confusion. 711 (if (equal (vc-file-getprop file 'vc-checkout-time)
712 (vc-file-setprop file 'vc-checkout-time nil)) 712 (nth 5 (file-attributes file)))
713 t) 713 (vc-file-setprop file 'vc-checkout-time nil))
714 (eq (vc-checkout-model backend (list file)) 'implicit) 714 (if (vc-state-refresh file backend)
715 (vc-state-refresh file backend) 715 (vc-mode-line file backend)))
716 (vc-mode-line file backend)) 716 ;; If we saved an unlocked file on a locking based VCS, that
717 ;; Try to avoid unnecessary work, a *vc-dir* buffer is 717 ;; file is not longer up-to-date.
718 ;; present if this is true. 718 ((eq (vc-file-getprop file 'vc-state) 'up-to-date)
719 (vc-file-setprop file 'vc-state nil)))
720 ;; Resynch *vc-dir* buffers, if any are present.
719 (when vc-dir-buffers 721 (when vc-dir-buffers
720 (vc-dir-resynch-file file)))) 722 (vc-dir-resynch-file file))))
721 723
diff --git a/lisp/vc/vc.el b/lisp/vc/vc.el
index fe259806267..9b8b94916c4 100644
--- a/lisp/vc/vc.el
+++ b/lisp/vc/vc.el
@@ -659,6 +659,10 @@
659(eval-when-compile 659(eval-when-compile
660 (require 'dired)) 660 (require 'dired))
661 661
662(declare-function dired-get-filename "dired" (&optional localp noerror))
663(declare-function dired-move-to-filename "dired" (&optional err eol))
664(declare-function dired-marker-regexp "dired" ())
665
662(unless (assoc 'vc-parent-buffer minor-mode-alist) 666(unless (assoc 'vc-parent-buffer minor-mode-alist)
663 (setq minor-mode-alist 667 (setq minor-mode-alist
664 (cons '(vc-parent-buffer vc-parent-buffer-name) 668 (cons '(vc-parent-buffer vc-parent-buffer-name)
@@ -1072,6 +1076,17 @@ For old-style locking-based version control systems, like RCS:
1072 ;; among all the `files'. 1076 ;; among all the `files'.
1073 (model (nth 4 vc-fileset))) 1077 (model (nth 4 vc-fileset)))
1074 1078
1079 ;; If a buffer has unsaved changes, a checkout would discard those
1080 ;; changes, so treat the buffer as having unlocked changes.
1081 (when (and (not (eq model 'implicit)) (eq state 'up-to-date))
1082 (let ((files files))
1083 (while files
1084 (let ((buffer (get-file-buffer (car files))))
1085 (and buffer
1086 (buffer-modified-p buffer)
1087 (setq state 'unlocked-changes
1088 files nil))))))
1089
1075 ;; Do the right thing 1090 ;; Do the right thing
1076 (cond 1091 (cond
1077 ((eq state 'missing) 1092 ((eq state 'missing)