Re: mercurial.el and hg-version-other-window
authorjon.christopher@Rigaku.com
Sat, 14 Jul 2007 11:27:58 -0500
changeset 4875 97dbf330069a
parent 4874 d9e385a7a806
child 4876 001e8a745834
Re: mercurial.el and hg-version-other-window hg-version-other window is unimplemented in mercurial.el. The version below works for me, YMMV.
contrib/mercurial.el
--- a/contrib/mercurial.el	Fri Jul 06 12:02:43 2007 +0200
+++ b/contrib/mercurial.el	Sat Jul 14 11:27:58 2007 -0500
@@ -1261,9 +1261,22 @@
   (interactive)
   (error "not implemented"))
 
-(defun hg-version-other-window ()
-  (interactive)
-  (error "not implemented"))
+(defun hg-version-other-window (rev)
+  "Visit version REV of the current file in another window.
+If the current file is named `F', the version is named `F.~REV~'.
+If `F.~REV~' already exists, use it instead of checking it out again."
+  (interactive "sVersion to visit (default is workfile version): ")
+  (let* ((file buffer-file-name)
+       	 (version (if (string-equal rev "")
+		       "tip"
+		        rev))
+ 	 (automatic-backup (vc-version-backup-file-name file version))
+          (manual-backup (vc-version-backup-file-name file version 'manual)))
+     (unless (file-exists-p manual-backup)
+       (if (file-exists-p automatic-backup)
+           (rename-file automatic-backup manual-backup nil)
+         (hg-run0 "-q" "cat" "-r" version "-o" manual-backup file)))
+     (find-file-other-window manual-backup)))
 
 
 (provide 'mercurial)