unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* vc-bzr sha1sum dependency patch #2
@ 2009-04-23 19:36 Mike Mattie
  2009-04-23 21:15 ` Chong Yidong
  2009-05-07  3:20 ` Stefan Monnier
  0 siblings, 2 replies; 6+ messages in thread
From: Mike Mattie @ 2009-04-23 19:36 UTC (permalink / raw)
  To: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 1474 bytes --]

Here is a corrected version of the patch I sent in the message vc-bzr sha1sum dependency

--- emacs-2009-4-21/lisp/vc-bzr.el	2009-04-06 21:06:42.000000000 -0700
+++ vc-bzr.el	2009-04-23 12:32:51.574872930 -0700
@@ -141,7 +141,24 @@
       (apply 'process-file prog (file-relative-name file) t nil args)
       (buffer-substring (point-min) (+ (point-min) 40)))))
 
+(defvar vc-bzr-optimized-status (executable-find "sha1sum")
+  "enable the bzr status optimization only if the sha1sum program exists")
+
 (defun vc-bzr-state-heuristic (file)
+  "a wrapper for two methods of determining the bzr status of a file."
+  (condition-case trap-status
+    (funcall (if vc-bzr-optimized-status
+               'vc-bzr-state-fast
+               'vc-bzr-state) file)
+    (error
+      (if vc-bzr-optimized-status
+        (progn
+          (setq vc-bzr-optimized-status nil)
+          (message "vc-bzr: error %s determining status of %s ; retrying with optimization disabled." (princ trap-status) file)
+          (vc-bzr-state file))
+        (message "vc-bzr-registered could not determine status of %s even with optimization disabled." file))) ))
+
+(defun vc-bzr-state-fast (file)
   "Like `vc-bzr-state' but hopefully without running Bzr."
   ;; `bzr status' is excrutiatingly slow with large histories and
   ;; pending merges, so try to avoid using it until they fix their


-- 
GnuPG Key: B9012279 is available from HKP server pgp.mit.edu

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: vc-bzr sha1sum dependency patch #2
  2009-04-23 19:36 vc-bzr sha1sum dependency patch #2 Mike Mattie
@ 2009-04-23 21:15 ` Chong Yidong
  2009-04-23 21:42   ` Stefan Monnier
  2009-05-07  3:20 ` Stefan Monnier
  1 sibling, 1 reply; 6+ messages in thread
From: Chong Yidong @ 2009-04-23 21:15 UTC (permalink / raw)
  To: Mike Mattie; +Cc: emacs-devel

Mike Mattie <codermattie@gmail.com> writes:

> Here is a corrected version of the patch I sent in the message vc-bzr
> sha1sum dependency

Since `bzr status' can take a long time to complete, wouldn't this lead
to slowdowns in, e.g., simply visiting files under bzr?




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: vc-bzr sha1sum dependency patch #2
  2009-04-23 21:15 ` Chong Yidong
@ 2009-04-23 21:42   ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2009-04-23 21:42 UTC (permalink / raw)
  To: Chong Yidong; +Cc: Mike Mattie, emacs-devel

>> Here is a corrected version of the patch I sent in the message vc-bzr
>> sha1sum dependency
> Since `bzr status' can take a long time to complete, wouldn't this lead
> to slowdowns in, e.g., simply visiting files under bzr?

Actually, with recent enough versions of bzr, the time it takes to "bzr
status" a file is not that bad.


        Stefan




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: vc-bzr sha1sum dependency patch #2
  2009-04-23 19:36 vc-bzr sha1sum dependency patch #2 Mike Mattie
  2009-04-23 21:15 ` Chong Yidong
@ 2009-05-07  3:20 ` Stefan Monnier
  2009-05-14  5:25   ` Mike Mattie
  1 sibling, 1 reply; 6+ messages in thread
From: Stefan Monnier @ 2009-05-07  3:20 UTC (permalink / raw)
  To: Mike Mattie; +Cc: emacs-devel

> Here is a corrected version of the patch I sent in the message vc-bzr sha1sum dependency

Can you test the patch below instead?


        Stefan


--- vc-bzr.el.~1.77.~	2009-04-08 20:09:55.000000000 -0400
+++ vc-bzr.el	2009-05-06 23:19:06.000000000 -0400
@@ -143,7 +143,7 @@
 
 (defun vc-bzr-state-heuristic (file)
   "Like `vc-bzr-state' but hopefully without running Bzr."
-  ;; `bzr status' is excrutiatingly slow with large histories and
+  ;; `bzr status' was excrutiatingly slow with large histories and
   ;; pending merges, so try to avoid using it until they fix their
   ;; performance problems.
   ;; This function tries first to parse Bzr internal file
@@ -158,8 +158,7 @@
       ;; This looks at internal files.  May break if they change
       ;; their format.
       (lexical-let ((dirstate (expand-file-name vc-bzr-admin-dirstate root)))
-        (if (not (file-readable-p dirstate))
-            (vc-bzr-state file)         ; Expensive.
+        (condition-case nil
           (with-temp-buffer
             (insert-file-contents dirstate)
             (goto-char (point-min))
@@ -201,7 +200,13 @@
                                   (vc-bzr-sha1 file)))
                       'up-to-date)
                      (t 'edited))
-                  'unregistered)))))))))
+                    'unregistered))))
+          ;; Either the dirstate file can't be read, or the sha1
+          ;; executable is missing, or ...
+          ;; In either case, recent versions of Bzr aren't that slow
+          ;; any more.
+          (error (vc-bzr-state file)))))))
+
 
 (defun vc-bzr-registered (file)
   "Return non-nil if FILE is registered with bzr."




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: vc-bzr sha1sum dependency patch #2
  2009-05-07  3:20 ` Stefan Monnier
@ 2009-05-14  5:25   ` Mike Mattie
  2009-05-17  3:39     ` Stefan Monnier
  0 siblings, 1 reply; 6+ messages in thread
From: Mike Mattie @ 2009-05-14  5:25 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: emacs-devel

[-- Attachment #1: Type: text/plain, Size: 2068 bytes --]

I tested your patch and it worked fine. Your patch is a far better solution
than mine in all respects. My thumb's up for applying it.


On Wed, May 06, 2009 at 11:20:01PM -0400, Stefan Monnier wrote:
> > Here is a corrected version of the patch I sent in the message vc-bzr sha1sum dependency
> 
> Can you test the patch below instead?
> 
> 
>         Stefan
> 
> 
> --- vc-bzr.el.~1.77.~	2009-04-08 20:09:55.000000000 -0400
> +++ vc-bzr.el	2009-05-06 23:19:06.000000000 -0400
> @@ -143,7 +143,7 @@
>  
>  (defun vc-bzr-state-heuristic (file)
>    "Like `vc-bzr-state' but hopefully without running Bzr."
> -  ;; `bzr status' is excrutiatingly slow with large histories and
> +  ;; `bzr status' was excrutiatingly slow with large histories and
>    ;; pending merges, so try to avoid using it until they fix their
>    ;; performance problems.
>    ;; This function tries first to parse Bzr internal file
> @@ -158,8 +158,7 @@
>        ;; This looks at internal files.  May break if they change
>        ;; their format.
>        (lexical-let ((dirstate (expand-file-name vc-bzr-admin-dirstate root)))
> -        (if (not (file-readable-p dirstate))
> -            (vc-bzr-state file)         ; Expensive.
> +        (condition-case nil
>            (with-temp-buffer
>              (insert-file-contents dirstate)
>              (goto-char (point-min))
> @@ -201,7 +200,13 @@
>                                    (vc-bzr-sha1 file)))
>                        'up-to-date)
>                       (t 'edited))
> -                  'unregistered)))))))))
> +                    'unregistered))))
> +          ;; Either the dirstate file can't be read, or the sha1
> +          ;; executable is missing, or ...
> +          ;; In either case, recent versions of Bzr aren't that slow
> +          ;; any more.
> +          (error (vc-bzr-state file)))))))
> +
>  
>  (defun vc-bzr-registered (file)
>    "Return non-nil if FILE is registered with bzr."

-- 
GnuPG Key: B9012279 is available from HKP server pgp.mit.edu

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: vc-bzr sha1sum dependency patch #2
  2009-05-14  5:25   ` Mike Mattie
@ 2009-05-17  3:39     ` Stefan Monnier
  0 siblings, 0 replies; 6+ messages in thread
From: Stefan Monnier @ 2009-05-17  3:39 UTC (permalink / raw)
  To: Mike Mattie; +Cc: emacs-devel

> I tested your patch and it worked fine. Your patch is a far better solution
> than mine in all respects. My thumb's up for applying it.

Thanks, installed,


        Stefan




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2009-05-17  3:39 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-23 19:36 vc-bzr sha1sum dependency patch #2 Mike Mattie
2009-04-23 21:15 ` Chong Yidong
2009-04-23 21:42   ` Stefan Monnier
2009-05-07  3:20 ` Stefan Monnier
2009-05-14  5:25   ` Mike Mattie
2009-05-17  3:39     ` Stefan Monnier

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).