/vendor/xhg-revision.el

https://github.com/demery/.emacs.d · Emacs Lisp · 126 lines · 82 code · 19 blank · 25 comment · 1 complexity · e1ddedaaabbfd36877d23039ccb7fb40 MD5 · raw file

  1. ;;; xhg-revision.el --- Management of revision lists in xhg
  2. ;; Copyright (C) 2006, 2007 by all contributors
  3. ;; Author: Stefan Reichoer, <stefan@xsteve.at>
  4. ;; Keywords:
  5. ;; DVC is free software; you can redistribute it and/or modify
  6. ;; it under the terms of the GNU General Public License as published by
  7. ;; the Free Software Foundation; either version 2, or (at your option)
  8. ;; any later version.
  9. ;; DVC is distributed in the hope that it will be useful,
  10. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. ;; GNU General Public License for more details.
  13. ;; You should have received a copy of the GNU General Public License
  14. ;; along with GNU Emacs; see the file COPYING. If not, write to
  15. ;; the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  16. ;; Boston, MA 02110-1301, USA.
  17. ;;; Commentary:
  18. ;;
  19. ;;; Code:
  20. (require 'dvc-revlist)
  21. (eval-when-compile (require 'cl))
  22. (defstruct (xhg-revision-st)
  23. changeset
  24. message
  25. creator
  26. tag
  27. date)
  28. ;; xhg dvc revision list
  29. (defun xhg-revision-list-entry-patch-printer (elem)
  30. (insert (if (dvc-revlist-entry-patch-marked elem)
  31. (concat " " dvc-mark " ") " "))
  32. (let ((struct (dvc-revlist-entry-patch-struct elem)))
  33. (insert (dvc-face-add "changeset: " 'dvc-header)
  34. (dvc-face-add (xhg-revision-st-changeset struct) 'dvc-revision-name)
  35. "\n")
  36. (when dvc-revisions-shows-creator
  37. (insert " " (dvc-face-add "user: " 'dvc-header)
  38. (or (xhg-revision-st-creator struct) "?") "\n"))
  39. (when dvc-revisions-shows-date
  40. (insert " " (dvc-face-add "timestamp: " 'dvc-header)
  41. (or (xhg-revision-st-date struct) "?") "\n"))
  42. (when (xhg-revision-st-tag struct)
  43. (insert " " (dvc-face-add "tag: " 'dvc-header)
  44. (xhg-revision-st-tag struct) "\n"))
  45. (when dvc-revisions-shows-summary
  46. (insert " " (dvc-face-add "summary: " 'dvc-header)
  47. (or (xhg-revision-st-message struct) "?") "\n"))))
  48. ;;; xhg dvc log
  49. (defun xhg-dvc-log-parse (log-buffer location)
  50. (goto-char (point-min))
  51. (let ((root location)
  52. (elem (make-xhg-revision-st))
  53. (field)
  54. (field-value))
  55. (while (> (point-max) (point))
  56. (beginning-of-line)
  57. (when (looking-at "^\\([a-z][a-z ]*[a-z]\\): +\\(.+\\)$")
  58. (setq field (match-string-no-properties 1))
  59. (setq field-value (match-string-no-properties 2))
  60. ;; (dvc-trace "field: %s, field-value: %s" field field-value)
  61. (cond ((string= field "changeset")
  62. (setf (xhg-revision-st-changeset elem) field-value))
  63. ((string= field "user")
  64. (setf (xhg-revision-st-creator elem) field-value))
  65. ((string= field "tag")
  66. (setf (xhg-revision-st-tag elem) field-value))
  67. ((string= field "date")
  68. (setf (xhg-revision-st-date elem) field-value))
  69. ((string= field "summary")
  70. (setf (xhg-revision-st-message elem) field-value))
  71. (t (dvc-trace "xhg-dvc-log-parse: unmanaged field %S" field)))
  72. (forward-line 1))
  73. (when (looking-at "^$")
  74. ;; (dvc-trace "empty line")
  75. (with-current-buffer log-buffer
  76. (ewoc-enter-last
  77. dvc-revlist-cookie
  78. `(entry-patch
  79. ,(make-dvc-revlist-entry-patch
  80. :dvc 'xhg
  81. :struct elem
  82. :rev-id `(xhg (revision (local ,root ,(xhg-revision-st-changeset elem))))))))
  83. (setq elem (make-xhg-revision-st))
  84. (forward-line 1))))
  85. (with-current-buffer log-buffer
  86. (goto-char (point-min))))
  87. ;;;###autoload
  88. (defun xhg-dvc-log (path last-n)
  89. "Show a dvc formatted log for xhg."
  90. (interactive (list default-directory nil))
  91. (dvc-build-revision-list 'xhg 'log (xhg-tree-root (or path default-directory)) '("log") 'xhg-dvc-log-parse
  92. t last-n path
  93. (dvc-capturing-lambda ()
  94. (xhg-dvc-log (capture path) (capture last-n)))))
  95. (defun xhg-revlog-get-revision (rev-id)
  96. (let ((rev (car (dvc-revision-get-data rev-id))))
  97. (case (car rev)
  98. (local
  99. (dvc-run-dvc-sync 'xhg `("log" "-r" ,(nth 2 rev))
  100. :finished 'dvc-output-buffer-handler))
  101. (t (error "Not implemented (rev=%s)" rev)))))
  102. (defun xhg-name-construct (rev-id)
  103. (case (car rev-id)
  104. (local (nth 1 rev-id))
  105. (t (error "Not implemented (rev-id=%s)" rev-id))))
  106. (provide 'xhg-revision)
  107. ;;; xhg-revision.el ends here