home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / progs / unclog.icn < prev    next >
Text File  |  2001-05-01  |  2KB  |  90 lines

  1. ############################################################################
  2. #
  3. #    File:     unclog.icn
  4. #
  5. #    Subject:  Program to reformat CVS log output
  6. #
  7. #    Author:   Gregg M. Townsend
  8. #
  9. #    Date:     May 1, 2001
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  Usage:  unclog [-n nnn] [file]
  18. #
  19. #    -n nnn    maximum number of files to be listed individually
  20. #        (default is 50)
  21. #
  22. #  Unclog reads the output of "cvs log", as run without arguments in
  23. #  a directory maintained by CVS, and reformats it to correlate CVS
  24. #  changes that affected multiple files.  The log entries are produced
  25. #  in chronological order.  Portions crossing a one-minute clock boundary
  26. #  are not combined.
  27. #
  28. ############################################################################
  29.  
  30. link options
  31.  
  32. $define MAXFILES 50
  33.  
  34. procedure main(args)
  35.    local opts, maxfiles, f, line, mods, fname, files, text, s
  36.  
  37.    opts := options(args, "n+")
  38.    maxfiles := \opts["n"] | MAXFILES
  39.  
  40.    if *args = 0 then
  41.       f := &input
  42.    else
  43.       f := open(args[1]) | stop("cannot open ", args[1])
  44.  
  45.    mods := table()
  46.  
  47.    while line := read(f) do line ? {
  48.  
  49.       # look for "date:" line
  50.       if ="Working file: " then        # save working file name
  51.          fname := tab(0)
  52.       ="date: "            | next
  53.       tab(find("author: ") + 8)    | next
  54.       tab(upto(';') + 1)    | next
  55.  
  56.       # this is the "date:" line
  57.       # save as first part of description
  58.       s := tab(1)
  59.       s[23+:3] := ""            # remove seconds from clock reading
  60.  
  61.       # read description of modification
  62.       while line := read(f) do {
  63.          if line ? =("-----------" | "===========") then break
  64.          s ||:= "\n" || line
  65.          }
  66.  
  67.       # have reached end of this entry
  68.       # add to table, indexed by text
  69.       files := mods[s]
  70.       if /files then
  71.          files := mods[s] := []
  72.       put(files, fname)
  73.       }
  74.  
  75.    # sort mods by timestamp, which is first part of text
  76.    mods := sort(mods, 3)
  77.  
  78.    # output the mods in order, giving affected files first
  79.    while text := get(mods) do {
  80.       write()
  81.       files := get(mods)
  82.       if *files >= maxfiles then
  83.          write("file: [", *files, " files]")
  84.       else
  85.          every write("file: ", !sort(files))
  86.       write(text)
  87.       write()
  88.       }
  89. end
  90.