 
 (defun vc-darcs-mode-line-string (file)
   "Return the mode line string to show for FILE."
-  (format "darcs/%s" (vc-state file)))
+  (let ((state (vc-state file)))
+    (if (eq state 'up-to-date)
+        "darcs"
+        (format "darcs/%s" (vc-state file)))))
 
 (defun vc-darcs-register (file &optional rev comment)
- "Add FILE to the darcs repository, and record this.
-  REV must be NIL, COMMENT is ignored."
+  "Add FILE to the darcs repository, and record this.
+REV and COMMENT are ignored."
+  (vc-darcs-do-command 'add 0 file))
+
+(defun vc-darcs-checkin (file rev comment)
+  "Record FILE to darcs.  COMMENT is the new comment."
   (when (not (null rev))
-    (error "Cannot specify register revision with darcs."))
- (vc-darcs-do-command 'add 0 file (file-name-nondirectory file)))
-
-(defun vc-darcs-checkin (file rev comment)
-  "Record FILE to darcs. REV should always be nil and is ignored,
-COMMENT is the new comment."
-  (when (not (null rev))
-    (error "Cannot specify checkin revision with darcs."))
+    (error "Cannot specify check-in revision with darcs."))
   (let* ((date (format-time-string "%Y%m%d%H%M%S" nil t))
          (match (string-match "\n" comment))
          (patch-name (if match 

                     (year (substring date 0 4))
                     (month (substring date 4 6))
                     (day (substring date 6 8))
                     (begin (point)))
                (insert (format "%-7s %s/%s/%s %s\n"
                                (if (> (length author) 7)
                                    (substring author 0 7)
                                    author)
                                day month year
                                line))))))))))

(defun vc-darcs-parse-integer (s)
  (let ((value 0)
        (index 0)
        (len (length s)))
    (while (< index len)
      (setq value (+ (* 10 value) (- (aref s index) ?0)))
      (incf index))
    value))

(defun vc-darcs-annotate-time ()
  (when (looking-at "........[0-9]")
    (forward-char 8)
    (and
     (looking-at "\\(..\\)/\\(..\\)/\\(....\\)")
     (let ((day (vc-darcs-parse-integer (match-string 1)))
           (month (vc-darcs-parse-integer (match-string 2)))
           (year (vc-darcs-parse-integer (match-string 3))))
       (vc-annotate-convert-time
        (encode-time 0 0 0 day month year))))))

;;; protection against editing files under _darcs
;;; adapted from an idea by Rob Giardine

(defun vc-darcs-find-file-hook ()
  (let ((f (buffer-file-name (current-buffer))))
    (and f (string-match "/_darcs" f) (not (string-match "/_darcs/prefs" f))
         (let ((open-instead
                (yes-or-no-p
                 "This is a _darcs file, open the real file instead? ")))
           (cond
             (open-instead
              (let* ((f (buffer-file-name (current-buffer)))
                     (match
                      (and f (string-match
                              "/_darcs/\\(current\\|pristine\\)/" f))))
                (unless match
                  (error "Couldn't find alternate file name"))
                (find-alternate-file
                 (concat (substring f 0 (match-beginning 0))
                         "/"
                         (substring f (match-end 0))))))
             (t
              (setq buffer-read-only t)
              (push '(:propertize "_DARCS-FILE:" face font-lock-warning-face)


(defun vc-darcs-rev-to-hash (rev file &optional off-by-one)
  (cond
    ((or (null rev) (eq rev t) (equal rev "")) nil)
    ((not off-by-one)
     (cond
       ((vc-darcs-hash-p rev) rev)
