changeset 1024:5b257e419816

Sync buffers prior to doing a diff.
author bos@serpentine.internal.keyresearch.com
date Tue, 23 Aug 2005 15:27:17 -0700
parents d06420c90d8b
children a5539638c5a3
files contrib/mercurial.el
diffstat 1 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/mercurial.el	Tue Aug 23 14:51:52 2005 -0700
+++ b/contrib/mercurial.el	Tue Aug 23 15:27:17 2005 -0700
@@ -47,6 +47,7 @@
 (require 'cl)
 (require 'diff-mode)
 (require 'easymenu)
+(require 'executable)
 (require 'vc)
 
 
@@ -295,6 +296,17 @@
 	       (car res))
       (cdr res))))
 
+(defun hg-sync-buffers (path)
+  "Sync buffers visiting PATH with their on-disk copies.
+If PATH is not being visited, but is under the repository root, sync
+all buffers visiting files in the repository."
+  (let ((buf (find-buffer-visiting path)))
+    (if buf
+	(with-current-buffer buf
+	  (vc-buffer-sync))
+      (hg-do-across-repo path
+	(vc-buffer-sync)))))
+  
 (defun hg-buffer-commands (pnt)
   "Use the properties of a character to do something sensible."
   (interactive "d")
@@ -732,8 +744,7 @@
 	modified-files)
     (unless root
       (error "Cannot commit outside a repository!"))
-    (hg-do-across-repo
-	(vc-buffer-sync))
+    (hg-sync-buffers root)
     (setq modified-files (hg-chomp (hg-run0 "--cwd" root "status" "-arm")))
     (when (and (= (length modified-files) 0)
 	       (not hg-commit-allow-empty-file-list))
@@ -789,6 +800,7 @@
 		       (and (not (eq rev2 'working-dir)) rev2))))
   (unless rev1
     (setq rev1 "-1"))
+  (hg-sync-buffers path)
   (let ((a-path (hg-abbrev-file-name path))
 	diff)
     (hg-view-output ((if (equal rev1 rev2)