# # patch "contrib/monotone.el" # from [fb5b222bf7e82951093d659e0d3100d264113f45] # to [a4d4e79c12a521038d669310c3a86de36f1e252c] # --- contrib/monotone.el +++ contrib/monotone.el @@ -342,6 +342,15 @@ (interactive "smonotone ") (monotone-cmd string)) +(defun monotone-rerun () + "Rerun the last monotone command." + (interactive) + (let ((args monotone-cmd-last-args)) + (when (or (null args) (not (listp args))) + (error "no last args to rerun")) + (monotone-cmd args))) +;; (monotone-cmd "list known") + ;; check for common errors and args. (defun monotone-cmd-buf (global buf cmds) "Run a simple monotone command for this buffer. (passwordless) @@ -591,19 +600,60 @@ (error "Unable to find MT directory")) (find-file-other-window (concat mt-top "MT/log")))) +;; (monotone-vc-update-change-log) -(defun monotone-rerun () - "Rerun the last monotone command." +(defun monotone-vc-revision () + (monotone-cmd '("cat" "revision"))) + +;;;;;;;;;; + +(defvar monotone-id-regexp "\\([0-9A-Fa-f]\\{40\\}\\)" + "A regexp matching a monotone id.") + +(defun monotone-id-at-point () (interactive) - (let ((args monotone-cmd-last-args)) - (when (or (null args) (not (listp args))) - (error "no last args to rerun")) - (monotone-cmd args))) -;; (monotone-cmd "list known") + (save-excursion + (skip-chars-backward "0-9A-Fa-f" (- (point) 40)) + (if (looking-at monotone-id-regexp) + (match-string 1) + nil))) -;; (monotone-vc-update-change-log) +(defun monotone-id-at-point-prompt (what) + "Get the id at point or prompt for one." + (let ((id (monotone-id-at-point))) + (when (not id) + (let ((prompt (capitalize (format "%s: " what)))) + (setq id (read-string prompt)))) + id)) +;; (monotone-id-at-point-prompt 'file) +(defun monotone-cat-id (what id) + (when id + (let ((what (format "%s" what)) + (name (format "*monotone %s %s*" what id))) + (monotone-cmd (list "cat" what id)) + ;; dont duplicate the buffers + (if (get-buffer name) + (kill-buffer name)) + (rename-buffer name)))) + +(defun monotone-cat-fileid (&optional id) + "Display the file with ID." + (interactive) + (monotone-cat-id 'file (or id (monotone-id-at-point-prompt 'file)))) + +(defun monotone-cat-manifestid (&optional id) + "Display the manifest with ID." + (interactive) + (monotone-cat-id 'manifest (or id (monotone-id-at-point-prompt 'manifest)))) + +(defun monotone-cat-revisionid (&optional id) + "Display the revision with ID." + (interactive) + (monotone-cat-id 'revision (or id (monotone-id-at-point-prompt 'revision)))) + + ;;;;;;;;;; (defvar monotone-menu @@ -613,6 +663,10 @@ (define-key map [monotone-vc-log] '(menu-item "Log" monotone-vc-log)) (define-key map [monotone-vc-status] '(menu-item "Status" monotone-vc-status)) (define-key map [monotone-separator] '("--")) + (define-key map [monotone-cat-fid] '(menu-item "Cat this file id" monotone-cat-fileid)) + (define-key map [monotone-cat-mid] '(menu-item "Cat this manifest id" monotone-cat-manifestid)) + (define-key map [monotone-cat-rid] '(menu-item "Cat this revision id" monotone-cat-revisionid)) + (define-key map [monotone-separator] '("--")) (define-key map [monotone-vc-pull] '(menu-item "DB Pull" monotone-vc-pull)) (define-key map [monotone-vc-push] '(menu-item "DB Push" monotone-vc-push)) (define-key map [monotone-vc-sync] '(menu-item "DB Sync" monotone-vc-sync))