pcvs-parse.el 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. ;;; pcvs-parse.el --- the CVS output parser
  2. ;; Copyright (C) 1991-2012 Free Software Foundation, Inc.
  3. ;; Author: Stefan Monnier <monnier@iro.umontreal.ca>
  4. ;; Keywords: pcl-cvs
  5. ;; Package: pcvs
  6. ;; This file is part of GNU Emacs.
  7. ;; GNU Emacs is free software: you can redistribute it and/or modify
  8. ;; it under the terms of the GNU General Public License as published by
  9. ;; the Free Software Foundation, either version 3 of the License, or
  10. ;; (at your option) any later version.
  11. ;; GNU Emacs is distributed in the hope that it will be useful,
  12. ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. ;; GNU General Public License for more details.
  15. ;; You should have received a copy of the GNU General Public License
  16. ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
  17. ;;; Commentary:
  18. ;;; Bugs:
  19. ;; - when merging a modified file, if the merge says that the file already
  20. ;; contained in the changes, it marks the file as `up-to-date' although
  21. ;; it might still contain further changes.
  22. ;; Example: merging a zero-change commit.
  23. ;;; Code:
  24. (eval-when-compile (require 'cl))
  25. (require 'pcvs-util)
  26. (require 'pcvs-info)
  27. ;; imported from pcvs.el
  28. (defvar cvs-execute-single-dir)
  29. ;; parse vars
  30. (defcustom cvs-update-prog-output-skip-regexp "$"
  31. "A regexp that matches the end of the output from all cvs update programs.
  32. That is, output from any programs that are run by CVS (by the flag -u
  33. in the `modules' file - see cvs(5)) when `cvs update' is performed should
  34. terminate with a line that this regexp matches. It is enough that
  35. some part of the line is matched.
  36. The default (a single $) fits programs without output."
  37. :group 'pcl-cvs
  38. :type '(regexp :value "$"))
  39. (defcustom cvs-parse-ignored-messages
  40. '("Executing ssh-askpass to query the password.*$"
  41. ".*Remote host denied X11 forwarding.*$")
  42. "A list of regexps matching messages that should be ignored by the parser.
  43. Each regexp should match a whole set of lines and should hence be terminated
  44. by `$'."
  45. :group 'pcl-cvs
  46. :type '(repeat regexp))
  47. ;; a few more defvars just to shut up the compiler
  48. (defvar cvs-start)
  49. (defvar cvs-current-dir)
  50. (defvar cvs-current-subdir)
  51. (defvar dont-change-disc)
  52. ;;;; The parser
  53. (defconst cvs-parse-known-commands
  54. '("status" "add" "commit" "update" "remove" "checkout" "ci")
  55. "List of CVS commands whose output is understood by the parser.")
  56. (defun cvs-parse-buffer (parse-spec dont-change-disc &optional subdir)
  57. "Parse current buffer according to PARSE-SPEC.
  58. PARSE-SPEC is a function of no argument advancing the point and returning
  59. either a fileinfo or t (if the matched text should be ignored) or
  60. nil if it didn't match anything.
  61. DONT-CHANGE-DISC just indicates whether the command was changing the disc
  62. or not (useful to tell the difference between `cvs-examine' and `cvs-update'
  63. output.
  64. The path names should be interpreted as relative to SUBDIR (defaults
  65. to the `default-directory').
  66. Return a list of collected entries, or t if an error occurred."
  67. (goto-char (point-min))
  68. (let ((fileinfos ())
  69. (cvs-current-dir "")
  70. (case-fold-search nil)
  71. (cvs-current-subdir (or subdir "")))
  72. (while (not (or (eobp) (eq fileinfos t)))
  73. (let ((ret (cvs-parse-run-table parse-spec)))
  74. (cond
  75. ;; it matched a known information message
  76. ((cvs-fileinfo-p ret) (push ret fileinfos))
  77. ;; it didn't match anything at all (impossible)
  78. ((and (consp ret) (cvs-fileinfo-p (car ret)))
  79. (setq fileinfos (append ret fileinfos)))
  80. ((null ret) (setq fileinfos t))
  81. ;; it matched something that should be ignored
  82. (t nil))))
  83. (nreverse fileinfos)))
  84. ;; All those parsing macros/functions should return a success indicator
  85. (defsubst cvs-parse-msg () (buffer-substring cvs-start (1- (point))))
  86. ;;(defsubst COLLECT (exp) (push exp *result*))
  87. ;;(defsubst PROG (e) t)
  88. ;;(defmacro SEQ (&rest seqs) (cons 'and seqs))
  89. (defmacro cvs-match (re &rest matches)
  90. "Try to match RE and extract submatches.
  91. If RE matches, advance the point until the line after the match and
  92. then assign the variables as specified in MATCHES (via `setq')."
  93. (cons 'cvs-do-match
  94. (cons re (mapcar (lambda (match)
  95. `(cons ',(first match) ,(second match)))
  96. matches))))
  97. (defun cvs-do-match (re &rest matches)
  98. "Internal function for the `cvs-match' macro.
  99. Match RE and if successful, execute MATCHES."
  100. ;; Is it a match?
  101. (when (looking-at re)
  102. (goto-char (match-end 0))
  103. ;; Skip the newline (unless we already are at the end of the buffer).
  104. (when (and (eolp) (< (point) (point-max))) (forward-char))
  105. ;; assign the matches
  106. (dolist (match matches t)
  107. (let ((val (cdr match)))
  108. (set (car match) (if (integerp val) (match-string val) val))))))
  109. (defmacro cvs-or (&rest alts)
  110. "Try each one of the ALTS alternatives until one matches."
  111. `(let ((-cvs-parse-point (point)))
  112. ,(cons 'or
  113. (mapcar (lambda (es)
  114. `(or ,es (ignore (goto-char -cvs-parse-point))))
  115. alts))))
  116. (def-edebug-spec cvs-or t)
  117. ;; This is how parser tables should be executed
  118. (defun cvs-parse-run-table (parse-spec)
  119. "Run PARSE-SPEC and provide sensible default behavior."
  120. (unless (bolp) (forward-line 1)) ;this should never be needed
  121. (let ((cvs-start (point)))
  122. (cvs-or
  123. (funcall parse-spec)
  124. (dolist (re cvs-parse-ignored-messages)
  125. (when (cvs-match re) (return t)))
  126. ;; This is a parse error. Create a message-type fileinfo.
  127. (and
  128. (cvs-match ".*$")
  129. (cvs-create-fileinfo 'MESSAGE cvs-current-dir " "
  130. ;; (concat " Unknown msg: '"
  131. (cvs-parse-msg) ;; "'")
  132. :subtype 'ERROR)))))
  133. (defun cvs-parsed-fileinfo (type path &optional directory &rest keys)
  134. "Create a fileinfo.
  135. TYPE can either be a type symbol or a cons of the form (TYPE . SUBTYPE).
  136. PATH is the filename.
  137. DIRECTORY influences the way PATH is interpreted:
  138. - if it's a string, it denotes the directory in which PATH (which should then be
  139. a plain file name with no directory component) resides.
  140. - if it's nil, the PATH should not be trusted: if it has a directory
  141. component, use it, else, assume it is relative to the current directory.
  142. - else, the PATH should be trusted to be relative to the root
  143. directory (i.e. if there is no directory component, it means the file
  144. is inside the main directory).
  145. The remaining KEYS are passed directly to `cvs-create-fileinfo'."
  146. (let ((dir directory)
  147. (file path))
  148. ;; only trust the directory if it's a string
  149. (unless (stringp directory)
  150. ;; else, if the directory is true, the path should be trusted
  151. (setq dir (or (file-name-directory path) (if directory "")))
  152. (setq file (file-name-nondirectory path)))
  153. (let ((type (if (consp type) (car type) type))
  154. (subtype (if (consp type) (cdr type))))
  155. (when dir (setq cvs-current-dir dir))
  156. (apply 'cvs-create-fileinfo type
  157. (concat cvs-current-subdir (or dir cvs-current-dir))
  158. file (cvs-parse-msg) :subtype subtype keys))))
  159. ;;;; CVS Process Parser Tables:
  160. ;;;;
  161. ;;;; The table for status and update could actually be merged since they
  162. ;;;; don't conflict. But they don't overlap much either.
  163. (defun cvs-parse-table ()
  164. "Table of message objects for `cvs-parse-process'."
  165. (let (c file dir path base-rev subtype)
  166. (cvs-or
  167. (cvs-parse-status)
  168. (cvs-parse-merge)
  169. (cvs-parse-commit)
  170. ;; this is not necessary because the fileinfo merging will remove
  171. ;; such duplicate info and luckily the second info is the one we want.
  172. ;; (and (cvs-match "M \\(.*\\)$" (path 1))
  173. ;; (cvs-parse-merge path))
  174. ;; Normal file state indicator.
  175. (and
  176. (cvs-match "\\([MARCUPNJ?]\\) \\(.*\\)$" (c 1) (path 2))
  177. ;; M: The file is modified by the user, and untouched in the repository.
  178. ;; A: The file is "cvs add"ed, but not "cvs ci"ed.
  179. ;; R: The file is "cvs remove"ed, but not "cvs ci"ed.
  180. ;; C: Conflict
  181. ;; U: The file is copied from the repository.
  182. ;; P: The file was patched from the repository.
  183. ;; ?: Unknown file.
  184. (let ((code (aref c 0)))
  185. (cvs-parsed-fileinfo
  186. (case code
  187. (?M 'MODIFIED)
  188. (?A 'ADDED)
  189. (?R 'REMOVED)
  190. (?? 'UNKNOWN)
  191. (?C
  192. (if (not dont-change-disc) 'CONFLICT
  193. ;; This is ambiguous. We should look for conflict markers in the
  194. ;; file to decide between CONFLICT and NEED-MERGE. With CVS-1.10
  195. ;; servers, this should not be necessary, because they return
  196. ;; a complete merge output.
  197. (with-temp-buffer
  198. (ignore-errors (insert-file-contents path))
  199. (goto-char (point-min))
  200. (if (re-search-forward "^<<<<<<< " nil t)
  201. 'CONFLICT 'NEED-MERGE))))
  202. (?J 'NEED-MERGE) ;not supported by standard CVS
  203. ((?U ?P)
  204. (if dont-change-disc 'NEED-UPDATE
  205. (cons 'UP-TO-DATE (if (eq code ?U) 'UPDATED 'PATCHED)))))
  206. path 'trust)))
  207. (and
  208. (cvs-match "pcl-cvs: descending directory \\(.*\\)$" (dir 1))
  209. (setq cvs-current-subdir dir))
  210. ;; A special cvs message
  211. (and
  212. (let ((case-fold-search t))
  213. (cvs-match "cvs[.a-z]* [a-z]+: "))
  214. (cvs-or
  215. ;; CVS is descending a subdirectory
  216. ;; (status says `examining' while update says `updating')
  217. (and
  218. (cvs-match "\\(Examining\\|Updating\\) \\(.*\\)$" (dir 2))
  219. (let ((dir (if (string= "." dir) "" (file-name-as-directory dir))))
  220. (cvs-parsed-fileinfo 'DIRCHANGE "." dir)))
  221. ;; [-n update] A new (or pruned) directory appeared but isn't traversed
  222. (and
  223. (cvs-match "New directory `\\(.*\\)' -- ignored$" (dir 1))
  224. ;; (cvs-parsed-fileinfo 'MESSAGE " " (file-name-as-directory dir))
  225. ;; These messages either correspond to a true new directory
  226. ;; that an update will bring in, or to a directory that's empty
  227. ;; on the current branch (either because it only exists in other
  228. ;; branches, or because it's been removed).
  229. (if (ignore-errors
  230. (with-temp-buffer
  231. (ignore-errors
  232. (insert-file-contents
  233. (expand-file-name ".cvsignore" (file-name-directory dir))))
  234. (goto-char (point-min))
  235. (re-search-forward
  236. (concat "^" (regexp-quote (file-name-nondirectory dir)) "/$")
  237. nil t)))
  238. t ;The user requested to ignore those messages.
  239. (cvs-parsed-fileinfo '(NEED-UPDATE . NEW-DIR) dir t)))
  240. ;; File removed, since it is removed (by third party) in repository.
  241. (and
  242. (cvs-or
  243. ;; some cvs versions output quotes around these files
  244. (cvs-match "warning: `\\(.*\\)' is not (any longer) pertinent$" (file 1))
  245. (cvs-match "warning: \\(.*\\) is not (any longer) pertinent$" (file 1))
  246. (cvs-match "`\\(.*\\)' is no longer in the repository$" (file 1))
  247. (cvs-match "\\(.*\\) is no longer in the repository$" (file 1)))
  248. (cvs-parsed-fileinfo
  249. (if dont-change-disc '(NEED-UPDATE . REMOVED) 'DEAD) file))
  250. ;; [add]
  251. (and
  252. (cvs-or
  253. (cvs-match "scheduling file `\\(.*\\)' for addition.*$" (path 1))
  254. (cvs-match "re-adding file \\(.*\\) (in place of .*)$" (path 1)))
  255. (cvs-parsed-fileinfo 'ADDED path))
  256. ;; [add] this will also show up as a `U <file>'
  257. (and
  258. (cvs-match "`?\\(.*?\\)'?, version \\(.*\\), resurrected$"
  259. (path 1) (base-rev 2))
  260. ;; FIXME: resurrection only brings back the original version,
  261. ;; not the latest on the branch, so `up-to-date' is not always
  262. ;; what we want.
  263. (cvs-parsed-fileinfo '(UP-TO-DATE . RESURRECTED) path nil
  264. :base-rev base-rev))
  265. ;; [remove]
  266. (and
  267. (cvs-match "removed `\\(.*\\)'$" (path 1))
  268. (cvs-parsed-fileinfo 'DEAD path))
  269. ;; [remove,merge]
  270. (and
  271. (cvs-match "scheduling `\\(.*\\)' for removal$" (file 1))
  272. (cvs-parsed-fileinfo 'REMOVED file))
  273. ;; [update] File removed by you, but not cvs rm'd
  274. (and
  275. (cvs-match "warning: \\(.*\\) was lost$" (path 1))
  276. (cvs-match (concat "U " (regexp-quote path) "$"))
  277. (cvs-parsed-fileinfo (if dont-change-disc
  278. 'MISSING
  279. '(UP-TO-DATE . UPDATED))
  280. path))
  281. ;; Mode conflicts (rather than contents)
  282. (and
  283. (cvs-match "conflict: ")
  284. (cvs-or
  285. (cvs-match "removed \\(.*\\) was modified by second party$"
  286. (path 1) (subtype 'REMOVED))
  287. (cvs-match "\\(.*\\) created independently by second party$"
  288. (path 1) (subtype 'ADDED))
  289. (cvs-match "\\(.*\\) is modified but no longer in the repository$"
  290. (path 1) (subtype 'MODIFIED)))
  291. (cvs-match (concat "C " (regexp-quote path)))
  292. (cvs-parsed-fileinfo (cons 'CONFLICT subtype) path))
  293. ;; Messages that should be shown to the user
  294. (and
  295. (cvs-or
  296. (cvs-match "move away \\(.*\\); it is in the way$" (file 1))
  297. (cvs-match "warning: new-born \\(.*\\) has disappeared$" (file 1))
  298. (cvs-match "sticky tag .* for file `\\(.*\\)' is not a branch$"
  299. (file 1)))
  300. (cvs-parsed-fileinfo 'MESSAGE file))
  301. ;; File unknown.
  302. (and (cvs-match "use `.+ add' to create an entry for \\(.*\\)$" (path 1))
  303. (cvs-parsed-fileinfo 'UNKNOWN path))
  304. ;; [commit]
  305. (and (cvs-match "Up-to-date check failed for `\\(.+\\)'$" (file 1))
  306. (cvs-parsed-fileinfo 'NEED-MERGE file))
  307. ;; We use cvs-execute-multi-dir but cvs can't handle it
  308. ;; Probably because the cvs-client can but the cvs-server can't
  309. (and (cvs-match ".* files with '?/'? in their name.*$")
  310. (not cvs-execute-single-dir)
  311. (setq cvs-execute-single-dir t)
  312. (cvs-create-fileinfo
  313. 'MESSAGE "" " "
  314. "*** Add (setq cvs-execute-single-dir t) to your .emacs ***
  315. See the FAQ file or the variable's documentation for more info."))
  316. ;; Cvs waits for a lock. Ignored: already handled by the process filter
  317. (cvs-match "\\[..:..:..\\] \\(waiting for\\|obtained\\) .*lock in .*$")
  318. ;; File you removed still exists. Ignore (will be noted as removed).
  319. (cvs-match ".* should be removed and is still there$")
  320. ;; just a note
  321. (cvs-match "use ['`].+ commit' to \\sw+ th\\sw+ files? permanently$")
  322. ;; [add,status] followed by a more complete status description anyway
  323. (and (cvs-match "nothing known about \\(.*\\)$" (path 1))
  324. (cvs-parsed-fileinfo 'DEAD path 'trust))
  325. ;; [update] problem with patch
  326. (cvs-match "checksum failure after patch to .*; will refetch$")
  327. (cvs-match "refetching unpatchable files$")
  328. ;; [commit]
  329. (cvs-match "Rebuilding administrative file database$")
  330. ;; ???
  331. (cvs-match "--> Using per-directory sticky tag `.*'")
  332. ;; CVS is running a *info program.
  333. (and
  334. (cvs-match "Executing.*$")
  335. ;; Skip by any output the program may generate to stdout.
  336. ;; Note that pcl-cvs will get seriously confused if the
  337. ;; program prints anything to stderr.
  338. (re-search-forward cvs-update-prog-output-skip-regexp))))
  339. (and
  340. (cvs-match "cvs[.ex]* \\[[a-z]+ aborted\\]:.*$")
  341. (cvs-parsed-fileinfo 'MESSAGE ""))
  342. ;; sadly you can't do much with these since the path is in the repository
  343. (cvs-match "Directory .* added to the repository$")
  344. )))
  345. (defun cvs-parse-merge ()
  346. (let (path base-rev head-rev type)
  347. ;; A merge (maybe with a conflict).
  348. (and
  349. (cvs-match "RCS file: .*$")
  350. ;; Squirrel away info about the files that were retrieved for merging
  351. (cvs-match "retrieving revision \\([0-9.]+\\)$" (base-rev 1))
  352. (cvs-match "retrieving revision \\([0-9.]+\\)$" (head-rev 1))
  353. (cvs-match "Merging differences between [0-9.]+ and [0-9.]+ into \\(.*\\)$"
  354. (path 1))
  355. ;; eat up potential conflict warnings
  356. (cvs-or (cvs-match "\\(rcs\\)?merge:?\\( warning\\)?: \\(overlaps\\|conflicts\\) \\(or other problems \\)?during merge$" (type 'CONFLICT)) t)
  357. (cvs-or
  358. (and
  359. (cvs-match "cvs[.ex]* [a-z]+: ")
  360. (cvs-or
  361. (cvs-match "conflicts found in \\(.*\\)$" (path 1) (type 'CONFLICT))
  362. (cvs-match "could not merge .*$")
  363. (cvs-match "restoring \\(.*\\) from backup file .*$" (path 1))))
  364. t)
  365. ;; Is it a successful merge?
  366. ;; Figure out result of merging (ie, was there a conflict?)
  367. (let ((qfile (regexp-quote path)))
  368. (cvs-or
  369. ;; Conflict
  370. (and
  371. (cvs-match (concat "C \\(.*" qfile "\\)$") (path 1) (type 'CONFLICT))
  372. ;; C might be followed by a "spurious" U for non-mergable files
  373. (cvs-or (cvs-match (concat "U \\(.*" qfile "\\)$")) t))
  374. ;; Successful merge
  375. (cvs-match (concat "M \\(.*" qfile "\\)$") (path 1))
  376. ;; The file already contained the modifications
  377. (cvs-match (concat "^\\(.*" qfile
  378. "\\) already contains the differences between .*$")
  379. (path 1) (type '(UP-TO-DATE . MERGED)))
  380. t)
  381. ;; FIXME: PATH might not be set yet. Sometimes the only path
  382. ;; information is in `RCS file: ...' (yuck!!).
  383. (cvs-parsed-fileinfo (if dont-change-disc 'NEED-MERGE
  384. (or type '(MODIFIED . MERGED))) path nil
  385. :merge (cons base-rev head-rev))))))
  386. (defun cvs-parse-status ()
  387. (let (nofile path base-rev head-rev type)
  388. (and
  389. (cvs-match
  390. "===================================================================$")
  391. (cvs-match "File: \\(no file \\)?\\(.*[^ \t]\\)[ \t]+Status: "
  392. (nofile 1) (path 2))
  393. (cvs-or
  394. (cvs-match "Needs \\(Checkout\\|Patch\\)$"
  395. (type (if nofile 'MISSING 'NEED-UPDATE)))
  396. (cvs-match "Up-to-date$"
  397. (type (if nofile '(UP-TO-DATE . REMOVED) 'UP-TO-DATE)))
  398. (cvs-match "File had conflicts on merge$" (type 'MODIFIED))
  399. (cvs-match ".*[Cc]onflict.*$" (type 'CONFLICT))
  400. (cvs-match "Locally Added$" (type 'ADDED))
  401. (cvs-match "Locally Removed$" (type 'REMOVED))
  402. (cvs-match "Locally Modified$" (type 'MODIFIED))
  403. (cvs-match "Needs Merge$" (type 'NEED-MERGE))
  404. (cvs-match "Entry Invalid" (type '(NEED-MERGE . REMOVED)))
  405. (cvs-match ".*$" (type 'UNKNOWN)))
  406. (cvs-match "$")
  407. (cvs-or
  408. (cvs-match " *Version:[ \t]*\\([0-9.]+\\).*$" (base-rev 1))
  409. ;; NOTE: there's no date on the end of the following for server mode...
  410. (cvs-match " *Working revision:[ \t]*-?\\([0-9.]+\\).*$" (base-rev 1))
  411. ;; Let's not get all worked up if the format changes a bit
  412. (cvs-match " *Working revision:.*$"))
  413. (cvs-or
  414. (cvs-match " *RCS Version:[ \t]*\\([0-9.]+\\)[ \t]*.*$" (head-rev 1))
  415. (cvs-match " *Repository revision:[ \t]*\\([0-9.]+\\)[ \t]*\\(.*\\)$"
  416. (head-rev 1))
  417. (cvs-match " *Repository revision:.*"))
  418. (cvs-or (cvs-match " *Expansion option:.*") t) ;Optional CVSNT thingie.
  419. (cvs-or (cvs-match " *Commit Identifier:.*") t) ;Optional CVSNT thingie.
  420. (cvs-or
  421. (and ;; Sometimes those fields are missing.
  422. (cvs-match " *Sticky Tag:[ \t]*\\(.*\\)$") ; FIXME: use it.
  423. (cvs-match " *Sticky Date:[ \t]*\\(.*\\)$") ; FIXME: use it.
  424. (cvs-match " *Sticky Options:[ \t]*\\(.*\\)$")) ; FIXME: use it.
  425. t)
  426. (cvs-or (cvs-match " *Merge From:.*") t) ;Optional CVSNT thingie.
  427. (cvs-match "$")
  428. ;; ignore the tags-listing in the case of `status -v'
  429. (cvs-or (cvs-match " *Existing Tags:\n\\(\t.*\n\\)*$") t)
  430. (cvs-parsed-fileinfo type path nil
  431. :base-rev base-rev
  432. :head-rev head-rev))))
  433. (defun cvs-parse-commit ()
  434. (let (path file base-rev subtype)
  435. (cvs-or
  436. (and
  437. (cvs-or
  438. (cvs-match "\\(Checking in\\|Removing\\) \\(.*\\);$" (path 2))
  439. t)
  440. (cvs-match ".*,v <-- \\(.*\\)$" (file 1))
  441. (cvs-or
  442. ;; deletion
  443. (cvs-match "new revision: delete; previous revision: \\([0-9.]*\\)$"
  444. (subtype 'REMOVED) (base-rev 1))
  445. ;; addition
  446. (cvs-match "initial revision: \\([0-9.]*\\)$"
  447. (subtype 'ADDED) (base-rev 1))
  448. ;; update
  449. (cvs-match "new revision: \\([0-9.]*\\); previous revision: .*$"
  450. (subtype 'COMMITTED) (base-rev 1)))
  451. (cvs-or (cvs-match "done$") t)
  452. ;; In cvs-1.12.9 commit messages have been changed and became
  453. ;; ambiguous. More specifically, the `path' above is not given.
  454. ;; We assume here that in future releases the corresponding info will
  455. ;; be put into `file'.
  456. (progn
  457. ;; Try to remove the temp files used by VC.
  458. (vc-delete-automatic-version-backups (expand-file-name (or path file)))
  459. ;; it's important here not to rely on the default directory management
  460. ;; because `cvs commit' might begin by a series of Examining messages
  461. ;; so the processing of the actual checkin messages might begin with
  462. ;; a `current-dir' set to something different from ""
  463. (cvs-parsed-fileinfo (cons 'UP-TO-DATE subtype)
  464. (or path file) 'trust
  465. :base-rev base-rev)))
  466. ;; useless message added before the actual addition: ignored
  467. (cvs-match "RCS file: .*\ndone$"))))
  468. (provide 'pcvs-parse)
  469. ;;; pcvs-parse.el ends here