]> git.eshelyaron.com Git - emacs.git/commitdiff
Add to do items.
authorDan Nicolaescu <dann@ics.uci.edu>
Thu, 21 Jun 2007 05:44:54 +0000 (05:44 +0000)
committerDan Nicolaescu <dann@ics.uci.edu>
Thu, 21 Jun 2007 05:44:54 +0000 (05:44 +0000)
(vc-hg-diff): Add support for comparing different revisions.
(vc-hg-diff, vc-hg-annotate-command, vc-hg-annotate-time)
(vc-hg-annotate-extract-revision-at-line)
(vc-hg-previous-version, vc-hg-checkin): New functions.
(vc-hg-annotate-re): New constant.

lisp/ChangeLog
lisp/vc-hg.el

index c2d25f1ca3077bfd6ab5a720fc5c4469a75eb3d6..5df52f8f0b8a7d4cd0c791039bfc2bb27fe7daf6 100644 (file)
@@ -1,3 +1,12 @@
+2007-06-21  Dan Nicolaescu  <dann@ics.uci.edu>
+
+       * vc-hg.el: Add to do items.
+       (vc-hg-diff): Add support for comparing different revisions.
+       (vc-hg-diff, vc-hg-annotate-command, vc-hg-annotate-time)
+       (vc-hg-annotate-extract-revision-at-line)
+       (vc-hg-previous-version, vc-hg-checkin): New functions.
+       (vc-hg-annotate-re): New constant.
+
 2007-06-20  Jay Belanger  <jay.p.belanger@gmail.com>
 
        * calc/calc.el (math-standard-ops): Fix precedence of
index d1ad447b9b9169e379ff09e8cc345a81d1847afd..c7bcda7ebc547dff6374cd9909ad10603db7e2ce 100644 (file)
 
 ;;; Todo:
 
-;; Implement the rest of the vc interface
+;; Implement the rest of the vc interface:
+;; - regexps for log-view to understand the "hg log" output
+;; - dired
+;; - snapshot?
 
 ;; Implement Stefan Monnier's advice: 
 ;; vc-hg-registered and vc-hg-state
    (if (and (vc-stay-local-p file) (fboundp 'start-process)) 'async 0)
    file "log"))
 
-(defun vc-hg-diff (file &optional oldvers newvers buffers)
+(defun vc-hg-diff (file &optional oldvers newvers buffer)
   "Get a difference report using hg between two versions of FILE."
-  (when buffers (message buffers))
-  (unless buffers (setq buffers "*vc-diff*"))
-  (when oldvers (message oldvers))
-  (when newvers (message newvers))
-  (call-process "hg" nil buffers nil
-                "--cwd" (file-name-directory file)
-                "diff" (file-name-nondirectory file)))
+  (let ((working (vc-workfile-version file)))
+    (if (and (equal oldvers working) (not newvers))
+       (setq oldvers nil))
+    (if (and (not oldvers) newvers)
+       (setq oldvers working))
+    (apply 'call-process "hg" nil (or buffer "*vc-diff*") nil
+          "--cwd" (file-name-directory file) "diff" 
+          (append 
+           (if oldvers
+               (if newvers
+                   (list "-r" oldvers "-r" newvers)
+                 (list "-r" oldvers))
+             (list ""))
+          (list (file-name-nondirectory file))))))
+
+(defun vc-hg-annotate-command (file buffer &optional version)
+  "Execute \"hg annotate\" on FILE, inserting the contents in BUFFER.
+Optional arg VERSION is a version to annotate from."
+  (vc-hg-command buffer 0 file "annotate" "-d" "-n" (if version (concat "-r" version)))
+  (with-current-buffer buffer
+    (goto-char (point-min))
+    (re-search-forward "^[0-9]")
+    (delete-region (point-min) (1- (point)))))
+
+
+;;; The format for one line output by "hg annotate -d -n" looks like this:
+;;;215 Wed Jun 20 21:22:58 2007 -0700: CONTENTS
+;;; i.e: VERSION_NUMBER DATE: CONTENTS
+(defconst vc-hg-annotate-re "^[ \t]*\\([0-9]+\\) \\(.\\{30\\}\\): ")
+
+(defun vc-hg-annotate-time ()
+  (when (looking-at vc-hg-annotate-re)
+    (goto-char (match-end 0))
+    (vc-annotate-convert-time 
+     (date-to-time (match-string-no-properties 2)))))
+
+(defun vc-hg-annotate-extract-revision-at-line ()
+  (save-excursion
+    (beginning-of-line)
+    (if (looking-at vc-hg-annotate-re) (match-string-no-properties 1))))
+
+(defun vc-hg-previous-version (file rev)
+  (let ((newrev (1- (string-to-number rev))))
+    (when (>= newrev 0)
+      (number-to-string newrev))))
 
 (defun vc-hg-register (file &optional rev comment)
   "Register FILE under hg.
@@ -124,6 +165,11 @@ REV is ignored.
 COMMENT is ignored."
   (vc-hg-command nil nil file "add"))
 
+(defun vc-hg-checkin (file rev comment)
+  "HG-specific version of `vc-backend-checkin'.
+REV is ignored."
+  (vc-hg-command nil nil file  "commit" "-m" comment))
+
 ;;; Modelled after the similar function in vc-bzr.el
 (defun vc-hg-checkout (file &optional editable rev workfile)
   "Retrieve a revision of FILE into a WORKFILE.