Artifact 5736267763b2b886670f3a3ddacc2be5b4b210fb:
File
tools/cvs2fossil/filerevtree
part of check-in
[64d0019e0f]
- Added two more debugging helper applications. One to extract and show a file revision tree, the other to display a dot file generated by the importer during cycle breaking passes.
by
aku on
2007-11-23 05:38:12.
0000: 23 21 2f 62 69 6e 2f 73 68 0a 23 23 20 2d 2a 2d #!/bin/sh.## -*-
0010: 20 74 63 6c 20 2d 2a 2d 20 5c 0a 65 78 65 63 20 tcl -*- \.exec
0020: 74 63 6c 73 68 20 22 24 30 22 20 24 7b 31 2b 22 tclsh "$0" ${1+"
0030: 24 40 22 7d 0a 0a 23 20 23 20 23 23 20 23 23 23 $@"}..# # ## ###
0040: 20 23 23 23 23 23 20 23 23 23 23 23 23 23 23 20 ##### ########
0050: 23 23 23 23 23 23 23 23 23 23 23 23 23 20 23 23 ############# ##
0060: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
0070: 23 23 23 0a 23 23 20 43 6f 70 79 72 69 67 68 74 ###.## Copyright
0080: 20 28 63 29 20 32 30 30 37 20 41 6e 64 72 65 61 (c) 2007 Andrea
0090: 73 20 4b 75 70 72 69 65 73 2e 0a 23 0a 23 20 54 s Kupries..#.# T
00a0: 68 69 73 20 73 6f 66 74 77 61 72 65 20 69 73 20 his software is
00b0: 6c 69 63 65 6e 73 65 64 20 61 73 20 64 65 73 63 licensed as desc
00c0: 72 69 62 65 64 20 69 6e 20 74 68 65 20 66 69 6c ribed in the fil
00d0: 65 20 4c 49 43 45 4e 53 45 2c 20 77 68 69 63 68 e LICENSE, which
00e0: 0a 23 20 79 6f 75 20 73 68 6f 75 6c 64 20 68 61 .# you should ha
00f0: 76 65 20 72 65 63 65 69 76 65 64 20 61 73 20 70 ve received as p
0100: 61 72 74 20 6f 66 20 74 68 69 73 20 64 69 73 74 art of this dist
0110: 72 69 62 75 74 69 6f 6e 2e 0a 23 0a 23 20 54 68 ribution..#.# Th
0120: 69 73 20 73 6f 66 74 77 61 72 65 20 63 6f 6e 73 is software cons
0130: 69 73 74 73 20 6f 66 20 76 6f 6c 75 6e 74 61 72 ists of voluntar
0140: 79 20 63 6f 6e 74 72 69 62 75 74 69 6f 6e 73 20 y contributions
0150: 6d 61 64 65 20 62 79 20 6d 61 6e 79 0a 23 20 69 made by many.# i
0160: 6e 64 69 76 69 64 75 61 6c 73 2e 20 20 46 6f 72 ndividuals. For
0170: 20 65 78 61 63 74 20 63 6f 6e 74 72 69 62 75 74 exact contribut
0180: 69 6f 6e 20 68 69 73 74 6f 72 79 2c 20 73 65 65 ion history, see
0190: 20 74 68 65 20 72 65 76 69 73 69 6f 6e 0a 23 20 the revision.#
01a0: 68 69 73 74 6f 72 79 20 61 6e 64 20 6c 6f 67 73 history and logs
01b0: 2c 20 61 76 61 69 6c 61 62 6c 65 20 61 74 20 68 , available at h
01c0: 74 74 70 3a 2f 2f 66 6f 73 73 69 6c 2d 73 63 6d ttp://fossil-scm
01d0: 2e 68 77 61 63 69 2e 63 6f 6d 2f 66 6f 73 73 69 .hwaci.com/fossi
01e0: 6c 0a 23 20 23 20 23 23 20 23 23 23 20 23 23 23 l.# # ## ### ###
01f0: 23 23 20 23 23 23 23 23 23 23 23 20 23 23 23 23 ## ######## ####
0200: 23 23 23 23 23 23 23 23 23 20 23 23 23 23 23 23 ######### ######
0210: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 0a ###############.
0220: 0a 23 23 20 48 65 6c 70 65 72 20 61 70 70 6c 69 .## Helper appli
0230: 63 61 74 69 6f 6e 2c 20 64 65 62 75 67 67 69 6e cation, debuggin
0240: 67 20 6f 66 20 63 76 73 32 66 6f 73 73 69 6c 2e g of cvs2fossil.
0250: 20 54 68 69 73 20 61 70 70 6c 69 63 61 74 69 6f This applicatio
0260: 6e 0a 23 23 20 65 78 74 72 61 63 74 73 20 74 68 n.## extracts th
0270: 65 20 74 72 65 65 20 6f 66 20 72 65 76 69 73 69 e tree of revisi
0280: 6f 6e 73 20 66 6f 72 20 61 20 66 69 6c 65 20 6f ons for a file o
0290: 66 20 69 6e 74 65 72 65 73 74 2c 20 73 70 65 63 f interest, spec
02a0: 69 66 69 65 64 0a 23 23 20 65 69 74 68 65 72 20 ified.## either
02b0: 64 69 72 65 63 74 6c 79 20 74 68 72 6f 75 67 68 directly through
02c0: 20 69 74 73 20 69 64 2c 20 6f 72 20 69 6e 64 69 its id, or indi
02d0: 72 65 63 74 6c 79 20 74 68 72 6f 75 67 68 20 74 rectly through t
02e0: 68 65 20 69 64 20 6f 66 20 61 0a 23 23 20 72 65 he id of a.## re
02f0: 76 69 73 69 6f 6e 20 69 74 20 63 6f 6e 74 61 69 vision it contai
0300: 6e 73 2c 20 61 6e 64 20 67 65 6e 65 72 61 74 65 ns, and generate
0310: 73 20 61 20 6e 69 63 65 20 67 72 61 70 68 69 63 s a nice graphic
0320: 61 6c 20 72 65 70 72 65 73 65 6e 74 61 74 69 6f al representatio
0330: 6e 0a 23 23 20 6f 66 20 69 74 20 28 70 6e 67 20 n.## of it (png
0340: 69 6d 61 67 65 29 2e 20 49 74 20 75 73 65 73 20 image). It uses
0350: 47 72 61 70 68 69 56 69 7a 27 73 20 27 64 6f 74 GraphiViz's 'dot
0360: 27 20 74 6f 6f 6c 20 74 6f 20 64 6f 20 61 6c 6c ' tool to do all
0370: 20 74 68 65 0a 23 23 20 6c 61 79 6f 75 74 69 6e the.## layoutin
0380: 67 2e 0a 0a 23 20 23 20 23 23 20 23 23 23 20 23 g...# # ## ### #
0390: 23 23 23 23 20 23 23 23 23 23 23 23 23 20 23 23 #### ######## ##
03a0: 23 23 23 23 23 23 23 23 23 23 23 20 23 23 23 23 ########### ####
03b0: 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 23 ################
03c0: 23 0a 23 23 20 52 65 71 75 69 72 65 6d 65 6e 74 #.## Requirement
03d0: 73 2c 20 65 78 74 65 6e 64 65 64 20 70 61 63 6b s, extended pack
03e0: 61 67 65 20 6d 61 6e 61 67 65 6d 65 6e 74 20 66 age management f
03f0: 6f 72 20 6c 6f 63 61 6c 20 70 61 63 6b 61 67 65 or local package
0400: 73 2e 0a 0a 6c 61 70 70 65 6e 64 20 61 75 74 6f s...lappend auto
0410: 5f 70 61 74 68 20 5b 66 69 6c 65 20 6a 6f 69 6e _path [file join
0420: 20 5b 66 69 6c 65 20 64 69 72 6e 61 6d 65 20 5b [file dirname [
0430: 69 6e 66 6f 20 73 63 72 69 70 74 5d 5d 20 6c 69 info script]] li
0440: 62 5d 0a 0a 70 61 63 6b 61 67 65 20 72 65 71 75 b]..package requ
0450: 69 72 65 20 54 63 6c 20 38 2e 34 20 20 20 20 20 ire Tcl 8.4
0460: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0470: 20 20 20 20 20 20 20 20 20 20 3b 20 23 20 52 65 ; # Re
0480: 71 75 69 72 65 64 20 72 75 6e 74 69 6d 65 2e 0a quired runtime..
0490: 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 package require
04a0: 73 74 72 75 63 74 3a 3a 67 72 61 70 68 20 20 20 struct::graph
04b0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
04c0: 20 20 20 20 20 20 3b 20 23 20 47 72 61 70 68 20 ; # Graph
04d0: 68 61 6e 64 6c 69 6e 67 2e 0a 70 61 63 6b 61 67 handling..packag
04e0: 65 20 72 65 71 75 69 72 65 20 73 74 72 75 63 74 e require struct
04f0: 3a 3a 6c 69 73 74 20 20 20 20 20 20 20 20 20 20 ::list
0500: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0510: 3b 20 23 20 48 69 67 68 65 72 20 6f 72 64 65 72 ; # Higher order
0520: 20 6c 69 73 74 20 6f 70 73 2e 0a 70 61 63 6b 61 list ops..packa
0530: 67 65 20 72 65 71 75 69 72 65 20 76 63 3a 3a 66 ge require vc::f
0540: 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a 63 ossil::import::c
0550: 76 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a 72 65 76 vs::project::rev
0560: 20 3b 20 23 20 43 68 61 6e 67 65 73 65 74 73 0a ; # Changesets.
0570: 70 61 63 6b 61 67 65 20 72 65 71 75 69 72 65 20 package require
0580: 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f vc::fossil::impo
0590: 72 74 3a 3a 63 76 73 3a 3a 73 74 61 74 65 20 20 rt::cvs::state
05a0: 20 20 20 20 20 20 3b 20 23 20 53 74 61 74 65 20 ; # State
05b0: 73 74 6f 72 61 67 65 2e 0a 70 61 63 6b 61 67 65 storage..package
05c0: 20 72 65 71 75 69 72 65 20 76 63 3a 3a 74 6f 6f require vc::too
05d0: 6c 73 3a 3a 6d 69 73 63 20 20 20 20 20 20 20 20 ls::misc
05e0: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 3b ;
05f0: 20 23 20 4d 69 6e 2f 6d 61 78 2e 0a 70 61 63 6b # Min/max..pack
0600: 61 67 65 20 72 65 71 75 69 72 65 20 76 63 3a 3a age require vc::
0610: 74 6f 6f 6c 73 3a 3a 64 6f 74 20 20 20 20 20 20 tools::dot
0620: 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20
0630: 20 20 3b 20 23 20 47 72 61 70 68 20 65 78 70 6f ; # Graph expo
0640: 72 74 20 74 6f 20 44 4f 54 2e 0a 0a 6e 61 6d 65 rt to DOT...name
0650: 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 space import ::v
0660: 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 c::fossil::impor
0670: 74 3a 3a 63 76 73 3a 3a 73 74 61 74 65 0a 6e 61 t::cvs::state.na
0680: 6d 65 73 70 61 63 65 20 69 6d 70 6f 72 74 20 3a mespace import :
0690: 3a 76 63 3a 3a 66 6f 73 73 69 6c 3a 3a 69 6d 70 :vc::fossil::imp
06a0: 6f 72 74 3a 3a 63 76 73 3a 3a 70 72 6f 6a 65 63 ort::cvs::projec
06b0: 74 3a 3a 72 65 76 0a 6e 61 6d 65 73 70 61 63 65 t::rev.namespace
06c0: 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a 74 6f import ::vc::to
06d0: 6f 6c 73 3a 3a 64 6f 74 0a 6e 61 6d 65 73 70 61 ols::dot.namespa
06e0: 63 65 20 69 6d 70 6f 72 74 20 3a 3a 76 63 3a 3a ce import ::vc::
06f0: 74 6f 6f 6c 73 3a 3a 6d 69 73 63 3a 3a 2a 0a 0a tools::misc::*..
0700: 23 20 50 72 6f 63 65 73 73 20 74 68 65 20 63 6f # Process the co
0710: 6d 6d 61 6e 64 20 6c 69 6e 65 2c 20 69 2e 65 2e mmand line, i.e.
0720: 20 67 65 74 20 74 68 65 20 64 61 74 61 62 61 73 get the databas
0730: 65 20 74 6f 20 61 63 63 65 73 73 2c 20 61 6e 64 e to access, and
0740: 20 66 69 6c 65 0a 23 20 6f 66 20 69 6e 74 65 72 file.# of inter
0750: 65 73 74 2e 20 54 68 65 20 6c 61 74 74 65 72 20 est. The latter
0760: 63 61 6e 20 62 65 20 73 70 65 63 69 66 69 65 64 can be specified
0770: 20 62 79 20 6e 61 6d 65 2c 20 69 64 2c 20 6f 72 by name, id, or
0780: 20 69 6e 64 69 72 65 63 74 6c 79 0a 23 20 74 68 indirectly.# th
0790: 72 6f 75 67 68 20 74 68 65 20 69 64 20 6f 66 20 rough the id of
07a0: 6f 6e 65 20 6f 66 20 74 68 65 20 72 65 76 69 73 one of the revis
07b0: 69 6f 6e 73 20 69 74 20 63 6f 6e 74 61 69 6e 73 ions it contains
07c0: 2e 0a 0a 73 74 61 74 65 20 75 73 65 20 5b 6c 69 ...state use [li
07d0: 6e 64 65 78 20 24 61 72 67 76 20 30 5d 0a 73 74 ndex $argv 0].st
07e0: 61 74 65 20 72 65 61 64 69 6e 67 20 70 72 6f 6a ate reading proj
07f0: 65 63 74 0a 73 74 61 74 65 20 72 65 61 64 69 6e ect.state readin
0800: 67 20 66 69 6c 65 0a 73 74 61 74 65 20 72 65 61 g file.state rea
0810: 64 69 6e 67 20 72 65 76 69 73 69 6f 6e 0a 73 74 ding revision.st
0820: 61 74 65 20 72 65 61 64 69 6e 67 20 72 65 76 69 ate reading revi
0830: 73 69 6f 6e 62 72 61 6e 63 68 63 68 69 6c 64 72 sionbranchchildr
0840: 65 6e 0a 73 74 61 74 65 20 72 65 61 64 69 6e 67 en.state reading
0850: 20 63 68 61 6e 67 65 73 65 74 0a 73 74 61 74 65 changeset.state
0860: 20 72 65 61 64 69 6e 67 20 63 73 72 65 76 69 73 reading csrevis
0870: 69 6f 6e 0a 73 74 61 74 65 20 72 65 61 64 69 6e ion.state readin
0880: 67 20 63 73 6f 72 64 65 72 0a 0a 73 65 74 20 77 g csorder..set w
0890: 68 61 74 20 5b 6c 69 6e 64 65 78 20 24 61 72 67 hat [lindex $arg
08a0: 76 20 31 5d 0a 73 65 74 20 63 65 6e 74 72 61 6c v 1].set central
08b0: 72 69 64 20 2d 31 0a 0a 73 77 69 74 63 68 20 2d rid -1..switch -
08c0: 65 78 61 63 74 20 2d 2d 20 24 77 68 61 74 20 7b exact -- $what {
08d0: 0a 20 20 20 20 72 69 64 20 7b 0a 09 23 20 47 65 . rid {..# Ge
08e0: 74 20 74 68 65 20 72 65 76 69 73 69 6f 6e 20 6f t the revision o
08f0: 66 20 69 6e 74 65 72 65 73 74 2c 20 69 64 65 6e f interest, iden
0900: 74 69 66 69 65 64 20 62 79 20 74 68 65 20 69 6e tified by the in
0910: 74 65 72 6e 61 6c 0a 09 23 20 6e 75 6d 65 72 69 ternal..# numeri
0920: 63 20 69 64 20 75 73 65 64 20 62 79 20 63 76 73 c id used by cvs
0930: 32 66 6f 73 73 69 6c 2e 0a 09 73 65 74 20 63 65 2fossil...set ce
0940: 6e 74 72 61 6c 72 69 64 20 5b 6c 69 6e 64 65 78 ntralrid [lindex
0950: 20 24 61 72 67 76 20 32 5d 0a 0a 09 70 75 74 73 $argv 2]...puts
0960: 20 22 52 65 76 69 73 69 6f 6e 20 3a 20 5b 73 74 "Revision : [st
0970: 61 74 65 20 6f 6e 65 20 7b 20 53 45 4c 45 43 54 ate one { SELECT
0980: 20 72 65 76 20 46 52 4f 4d 20 72 65 76 69 73 69 rev FROM revisi
0990: 6f 6e 20 57 48 45 52 45 20 72 69 64 20 3d 20 24 on WHERE rid = $
09a0: 63 65 6e 74 72 61 6c 72 69 64 20 7d 5d 20 28 24 centralrid }] ($
09b0: 63 65 6e 74 72 61 6c 72 69 64 29 22 0a 0a 09 23 centralrid)"...#
09c0: 20 4d 61 70 20 69 74 20 74 6f 20 74 68 65 20 66 Map it to the f
09d0: 69 6c 65 20 63 6f 6e 74 61 69 6e 69 6e 67 20 74 ile containing t
09e0: 68 65 20 72 65 76 69 73 69 6f 6e 20 6f 66 20 69 he revision of i
09f0: 6e 74 65 72 65 73 74 2e 0a 09 73 65 74 20 66 69 nterest...set fi
0a00: 64 20 5b 73 74 61 74 65 20 6f 6e 65 20 7b 20 53 d [state one { S
0a10: 45 4c 45 43 54 20 66 69 64 20 46 52 4f 4d 20 72 ELECT fid FROM r
0a20: 65 76 69 73 69 6f 6e 20 57 48 45 52 45 20 72 69 evision WHERE ri
0a30: 64 20 3d 20 24 63 65 6e 74 72 61 6c 72 69 64 20 d = $centralrid
0a40: 7d 5d 0a 20 20 20 20 7d 0a 20 20 20 20 66 69 64 }]. }. fid
0a50: 20 7b 0a 09 23 20 47 65 74 20 74 68 65 20 66 69 {..# Get the fi
0a60: 6c 65 20 6f 66 20 69 6e 74 65 72 65 73 74 2c 20 le of interest,
0a70: 69 64 65 6e 74 69 66 69 65 64 20 62 79 20 69 6e identified by in
0a80: 74 65 72 6e 61 6c 20 6e 75 6d 65 72 69 63 20 69 ternal numeric i
0a90: 64 0a 09 23 20 75 73 65 64 20 62 79 20 63 76 73 d..# used by cvs
0aa0: 32 66 6f 73 73 69 6c 2e 0a 09 73 65 74 20 66 69 2fossil...set fi
0ab0: 64 20 5b 6c 69 6e 64 65 78 20 24 61 72 67 76 20 d [lindex $argv
0ac0: 32 5d 0a 20 20 20 20 7d 0a 20 20 20 20 66 6e 61 2]. }. fna
0ad0: 6d 65 20 7b 0a 09 23 20 47 65 74 20 74 68 65 20 me {..# Get the
0ae0: 66 69 6c 65 20 6f 66 20 69 6e 74 65 72 65 73 74 file of interest
0af0: 2c 20 69 64 65 6e 74 69 66 69 65 64 20 62 79 20 , identified by
0b00: 69 74 73 20 6e 61 6d 65 2e 0a 0a 09 73 65 74 20 its name....set
0b10: 66 6e 61 6d 65 20 5b 6c 69 6e 64 65 78 20 24 61 fname [lindex $a
0b20: 72 67 76 20 32 5d 0a 09 73 65 74 20 66 69 64 20 rgv 2]..set fid
0b30: 5b 73 74 61 74 65 20 6f 6e 65 20 7b 20 53 45 4c [state one { SEL
0b40: 45 43 54 20 66 69 64 20 46 52 4f 4d 20 66 69 6c ECT fid FROM fil
0b50: 65 20 57 48 45 52 45 20 6e 61 6d 65 20 3d 3d 20 e WHERE name ==
0b60: 24 66 6e 61 6d 65 20 7d 5d 0a 20 20 20 20 7d 0a $fname }]. }.
0b70: 20 20 20 20 64 65 66 61 75 6c 74 20 7b 0a 09 74 default {..t
0b80: 72 6f 75 62 6c 65 20 66 61 74 61 6c 20 5c 0a 09 rouble fatal \..
0b90: 20 20 20 20 22 55 6e 6b 6e 6f 77 6e 20 73 70 65 "Unknown spe
0ba0: 63 20 5c 22 24 77 68 61 74 5c 22 2c 20 65 78 70 c \"$what\", exp
0bb0: 65 63 74 65 64 20 6f 6e 65 20 6f 66 20 5c 22 66 ected one of \"f
0bc0: 69 64 5c 22 2c 20 5c 22 66 6e 61 6d 65 5c 22 2c id\", \"fname\",
0bd0: 20 6f 72 20 5c 22 72 69 64 5c 22 22 0a 20 20 20 or \"rid\"".
0be0: 20 7d 0a 7d 0a 0a 73 65 74 20 70 69 64 20 5b 73 }.}..set pid [s
0bf0: 74 61 74 65 20 6f 6e 65 20 7b 20 53 45 4c 45 43 tate one { SELEC
0c00: 54 20 70 69 64 20 46 52 4f 4d 20 66 69 6c 65 20 T pid FROM file
0c10: 57 48 45 52 45 20 66 69 64 20 3d 3d 20 24 66 69 WHERE fid == $fi
0c20: 64 20 7d 5d 0a 0a 70 75 74 73 20 22 46 69 6c 65 d }]..puts "File
0c30: 20 20 20 20 20 3a 20 5b 73 74 61 74 65 20 6f 6e : [state on
0c40: 65 20 7b 20 53 45 4c 45 43 54 20 6e 61 6d 65 20 e { SELECT name
0c50: 46 52 4f 4d 20 66 69 6c 65 20 20 20 20 57 48 45 FROM file WHE
0c60: 52 45 20 66 69 64 20 3d 20 24 66 69 64 20 7d 5d RE fid = $fid }]
0c70: 20 28 24 66 69 64 29 22 0a 70 75 74 73 20 22 50 ($fid)".puts "P
0c80: 72 6f 6a 65 63 74 20 20 3a 20 5b 73 74 61 74 65 roject : [state
0c90: 20 6f 6e 65 20 7b 20 53 45 4c 45 43 54 20 6e 61 one { SELECT na
0ca0: 6d 65 20 46 52 4f 4d 20 70 72 6f 6a 65 63 74 20 me FROM project
0cb0: 57 48 45 52 45 20 70 69 64 20 3d 20 24 70 69 64 WHERE pid = $pid
0cc0: 20 7d 5d 20 28 24 70 69 64 29 22 0a 0a 23 20 47 }] ($pid)"..# G
0cd0: 65 74 20 74 68 65 20 64 61 74 61 20 6f 66 20 61 et the data of a
0ce0: 6c 6c 20 72 65 76 69 73 69 6f 6e 73 20 69 6e 20 ll revisions in
0cf0: 74 68 65 20 66 69 6c 65 20 6f 66 20 69 6e 74 65 the file of inte
0d00: 72 65 73 74 2c 20 61 73 20 61 20 6c 69 73 74 20 rest, as a list
0d10: 66 6f 72 0a 23 20 69 74 65 72 61 74 69 6f 6e 2c for.# iteration,
0d20: 20 61 6e 64 20 61 73 20 61 72 72 61 79 20 66 6f and as array fo
0d30: 72 20 72 61 6e 64 6f 6d 20 61 63 63 65 73 73 20 r random access
0d40: 6f 66 20 6e 65 69 67 68 62 6f 75 72 69 6e 67 20 of neighbouring
0d50: 72 65 76 69 73 69 6f 6e 73 2e 0a 0a 61 72 72 61 revisions...arra
0d60: 79 20 73 65 74 20 72 65 76 20 7b 7d 0a 66 6f 72 y set rev {}.for
0d70: 65 61 63 68 20 7b 72 69 64 20 72 65 76 6e 72 20 each {rid revnr
0d80: 6c 6f 64 20 64 61 74 65 20 69 73 64 65 66 61 75 lod date isdefau
0d90: 6c 74 7d 20 5b 73 65 74 20 72 65 76 69 73 69 6f lt} [set revisio
0da0: 6e 73 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a ns [state run {.
0db0: 20 20 20 20 53 45 4c 45 43 54 20 52 2e 72 69 64 SELECT R.rid
0dc0: 2c 20 52 2e 72 65 76 2c 20 53 2e 6e 61 6d 65 2c , R.rev, S.name,
0dd0: 20 52 2e 64 61 74 65 2c 20 52 2e 69 73 64 65 66 R.date, R.isdef
0de0: 61 75 6c 74 0a 20 20 20 20 46 52 4f 4d 20 72 65 ault. FROM re
0df0: 76 69 73 69 6f 6e 20 52 2c 20 73 79 6d 62 6f 6c vision R, symbol
0e00: 20 53 0a 20 20 20 20 57 48 45 52 45 20 52 2e 66 S. WHERE R.f
0e10: 69 64 20 3d 20 24 66 69 64 0a 20 20 20 20 41 4e id = $fid. AN
0e20: 44 20 20 20 52 2e 6c 6f 64 20 3d 20 53 2e 73 69 D R.lod = S.si
0e30: 64 0a 7d 5d 5d 20 7b 0a 20 20 20 20 73 65 74 20 d.}]] {. set
0e40: 63 73 20 5b 73 74 61 74 65 20 72 75 6e 20 7b 0a cs [state run {.
0e50: 09 53 45 4c 45 43 54 20 43 52 2e 63 69 64 2c 20 .SELECT CR.cid,
0e60: 43 4f 2e 70 6f 73 2c 20 43 54 2e 6e 61 6d 65 0a CO.pos, CT.name.
0e70: 09 46 52 4f 4d 20 63 73 72 65 76 69 73 69 6f 6e .FROM csrevision
0e80: 20 43 52 2c 20 63 73 6f 72 64 65 72 20 43 4f 2c CR, csorder CO,
0e90: 20 63 73 74 79 70 65 20 43 54 2c 20 63 68 61 6e cstype CT, chan
0ea0: 67 65 73 65 74 20 43 0a 09 57 48 45 52 45 20 43 geset C..WHERE C
0eb0: 52 2e 72 69 64 20 3d 20 24 72 69 64 0a 09 41 4e R.rid = $rid..AN
0ec0: 44 20 20 20 43 52 2e 63 69 64 20 3d 20 43 4f 2e D CR.cid = CO.
0ed0: 63 69 64 0a 09 41 4e 44 20 20 20 43 52 2e 63 69 cid..AND CR.ci
0ee0: 64 20 3d 20 43 2e 63 69 64 0a 09 41 4e 44 20 20 d = C.cid..AND
0ef0: 20 43 54 2e 74 69 64 20 3d 20 43 2e 74 79 70 65 CT.tid = C.type
0f00: 0a 20 20 20 20 7d 5d 0a 0a 20 20 20 20 73 65 74 . }].. set
0f10: 20 72 65 76 28 24 72 69 64 29 20 5b 6c 69 73 74 rev($rid) [list
0f20: 20 24 72 65 76 6e 72 20 24 6c 6f 64 20 24 64 61 $revnr $lod $da
0f30: 74 65 20 24 69 73 64 65 66 61 75 6c 74 20 24 63 te $isdefault $c
0f40: 73 5d 0a 7d 0a 0a 70 75 74 73 20 22 23 52 65 76 s].}..puts "#Rev
0f50: 73 20 20 20 20 3a 20 5b 61 72 72 61 79 20 73 69 s : [array si
0f60: 7a 65 20 72 65 76 5d 22 0a 0a 23 20 53 74 61 72 ze rev]"..# Star
0f70: 74 20 74 68 65 20 67 72 61 70 68 0a 0a 73 74 72 t the graph..str
0f80: 75 63 74 3a 3a 67 72 61 70 68 20 64 67 0a 0a 23 uct::graph dg..#
0f90: 20 43 6f 6e 76 65 72 74 20 74 68 65 20 72 65 76 Convert the rev
0fa0: 69 73 69 6f 6e 73 20 69 6e 74 6f 20 6e 6f 64 65 isions into node
0fb0: 73 20 6f 66 20 74 68 65 20 67 72 61 70 68 2c 20 s of the graph,
0fc0: 61 6e 64 20 75 73 65 20 6e 6f 64 65 0a 23 20 61 and use node.# a
0fd0: 74 74 72 69 62 75 74 65 73 20 74 6f 20 68 69 67 ttributes to hig
0fe0: 68 6c 69 67 68 74 20 76 61 72 69 6f 75 73 20 70 hlight various p
0ff0: 69 65 63 65 73 20 6f 66 20 69 6e 74 65 72 65 73 ieces of interes
1000: 74 20 66 6f 72 20 74 68 65 20 64 6f 74 0a 23 20 t for the dot.#
1010: 63 6f 6e 76 65 72 73 69 6f 6e 2e 20 4c 61 62 65 conversion. Labe
1020: 6c 20 3d 3e 20 52 65 76 6e 72 2c 20 53 79 6d 62 l => Revnr, Symb
1030: 6f 6c 20 28 4c 4f 44 29 2c 20 43 68 61 6e 67 65 ol (LOD), Change
1040: 73 65 74 20 69 64 20 28 69 66 0a 23 20 61 76 61 set id (if.# ava
1050: 69 6c 61 62 6c 65 29 2c 20 66 6f 72 6d 61 74 74 ilable), formatt
1060: 65 64 20 64 61 74 65 2e 20 42 61 63 6b 67 72 6f ed date. Backgro
1070: 75 6e 64 20 66 69 6c 6c 20 63 6f 6c 6f 72 73 20 und fill colors
1080: 74 6f 20 73 68 6f 77 20 74 68 65 0a 23 20 64 69 to show the.# di
1090: 66 66 65 72 65 6e 74 20 62 72 61 6e 63 68 65 73 fferent branches
10a0: 20 3f 2e 0a 0a 66 6f 72 65 61 63 68 20 7b 72 69 ?...foreach {ri
10b0: 64 20 72 65 76 6e 72 20 6c 6f 64 20 64 61 74 65 d revnr lod date
10c0: 20 69 73 64 65 66 61 75 6c 74 7d 20 24 72 65 76 isdefault} $rev
10d0: 69 73 69 6f 6e 73 20 7b 0a 20 20 20 20 73 65 74 isions {. set
10e0: 20 6c 61 62 65 6c 20 20 22 24 72 69 64 20 3d 20 label "$rid =
10f0: 3c 24 72 65 76 6e 72 3e 20 40 20 24 6c 6f 64 20 <$revnr> @ $lod
1100: 2f 20 5b 63 6c 6f 63 6b 20 66 6f 72 6d 61 74 20 / [clock format
1110: 24 64 61 74 65 5d 22 0a 20 20 20 20 73 65 74 20 $date]". set
1120: 63 73 20 5b 6c 69 6e 64 65 78 20 24 72 65 76 28 cs [lindex $rev(
1130: 24 72 69 64 29 20 34 5d 0a 20 20 20 20 69 66 20 $rid) 4]. if
1140: 7b 5b 6c 6c 65 6e 67 74 68 20 24 63 73 5d 7d 20 {[llength $cs]}
1150: 7b 0a 09 66 6f 72 65 61 63 68 20 7b 63 73 20 6f {..foreach {cs o
1160: 72 64 20 63 73 74 79 70 65 7d 20 24 63 73 20 7b rd cstype} $cs {
1170: 0a 09 20 20 20 20 61 70 70 65 6e 64 20 6c 61 62 .. append lab
1180: 65 6c 20 22 5c 5c 6e 43 53 2f 24 7b 63 73 74 79 el "\\nCS/${csty
1190: 70 65 7d 28 24 63 73 29 20 40 24 6f 72 64 22 0a pe}($cs) @$ord".
11a0: 09 7d 0a 20 20 20 20 7d 0a 20 20 20 20 64 67 20 .}. }. dg
11b0: 6e 6f 64 65 20 69 6e 73 65 72 74 20 24 72 69 64 node insert $rid
11c0: 0a 20 20 20 20 64 67 20 6e 6f 64 65 20 73 65 74 . dg node set
11d0: 20 20 20 20 24 72 69 64 20 6c 61 62 65 6c 20 24 $rid label $
11e0: 6c 61 62 65 6c 0a 20 20 20 20 64 67 20 6e 6f 64 label. dg nod
11f0: 65 20 73 65 74 20 20 20 20 24 72 69 64 20 73 68 e set $rid sh
1200: 61 70 65 20 5b 65 78 70 72 20 7b 24 69 73 64 65 ape [expr {$isde
1210: 66 61 75 6c 74 20 3f 20 22 64 69 61 6d 6f 6e 64 fault ? "diamond
1220: 22 20 3a 20 22 62 6f 78 22 7d 5d 0a 7d 0a 0a 23 " : "box"}].}..#
1230: 20 47 6f 20 74 68 72 6f 75 67 68 20 74 68 65 20 Go through the
1240: 72 65 76 69 73 69 6f 6e 73 20 61 20 73 65 63 6f revisions a seco
1250: 6e 64 20 74 69 6d 65 20 61 6e 64 20 73 65 74 20 nd time and set
1260: 75 70 20 74 68 65 20 61 72 63 73 20 62 61 73 65 up the arcs base
1270: 64 20 6f 6e 0a 23 20 74 68 65 20 73 74 6f 72 65 d on.# the store
1280: 64 20 73 75 63 63 65 73 73 6f 72 20 69 6e 66 6f d successor info
1290: 72 6d 61 74 69 6f 6e 2e 0a 0a 3a 3a 76 63 3a 3a rmation...::vc::
12a0: 66 6f 73 73 69 6c 3a 3a 69 6d 70 6f 72 74 3a 3a fossil::import::
12b0: 63 76 73 3a 3a 70 72 6f 6a 65 63 74 3a 3a 72 65 cvs::project::re
12c0: 76 3a 3a 50 75 6c 6c 53 75 63 63 65 73 73 6f 72 v::PullSuccessor
12d0: 52 65 76 69 73 69 6f 6e 73 20 64 65 70 20 5b 61 Revisions dep [a
12e0: 72 72 61 79 20 6e 61 6d 65 73 20 72 65 76 5d 0a rray names rev].
12f0: 0a 70 72 6f 63 20 4f 72 64 20 7b 63 6d 64 20 72 .proc Ord {cmd r
1300: 69 64 7d 20 7b 0a 20 20 20 20 67 6c 6f 62 61 6c id} {. global
1310: 20 72 65 76 0a 20 20 20 20 73 65 74 20 6f 72 64 rev. set ord
1320: 73 20 7b 7d 0a 20 20 20 20 66 6f 72 65 61 63 68 s {}. foreach
1330: 20 7b 63 73 20 6f 72 64 20 63 73 74 79 70 65 7d {cs ord cstype}
1340: 20 5b 6c 69 6e 64 65 78 20 24 72 65 76 28 24 72 [lindex $rev($r
1350: 69 64 29 20 34 5d 20 7b 20 6c 61 70 70 65 6e 64 id) 4] { lappend
1360: 20 6f 72 64 73 20 24 6f 72 64 20 7d 0a 20 20 20 ords $ord }.
1370: 20 72 65 74 75 72 6e 20 5b 24 63 6d 64 20 24 6f return [$cmd $o
1380: 72 64 73 5d 0a 7d 0a 0a 66 6f 72 65 61 63 68 20 rds].}..foreach
1390: 7b 72 69 64 20 63 68 69 6c 64 72 65 6e 7d 20 5b {rid children} [
13a0: 61 72 72 61 79 20 67 65 74 20 64 65 70 5d 20 7b array get dep] {
13b0: 0a 20 20 20 20 73 65 74 20 6d 61 78 20 5b 4f 72 . set max [Or
13c0: 64 20 6d 61 78 20 24 72 69 64 5d 0a 0a 20 20 20 d max $rid]..
13d0: 20 66 6f 72 65 61 63 68 20 63 68 69 6c 64 20 24 foreach child $
13e0: 63 68 69 6c 64 72 65 6e 20 7b 0a 09 73 65 74 20 children {..set
13f0: 61 20 5b 64 67 20 61 72 63 20 69 6e 73 65 72 74 a [dg arc insert
1400: 20 24 72 69 64 20 24 63 68 69 6c 64 5d 0a 0a 09 $rid $child]...
1410: 69 66 20 7b 24 6d 61 78 20 3e 20 5b 4f 72 64 20 if {$max > [Ord
1420: 6d 69 6e 20 24 63 68 69 6c 64 5d 7d 20 7b 0a 09 min $child]} {..
1430: 20 20 20 20 70 75 74 73 20 22 42 61 63 6b 77 61 puts "Backwa
1440: 72 64 20 3a 20 24 72 69 64 20 2d 3e 20 24 63 68 rd : $rid -> $ch
1450: 69 6c 64 22 0a 09 20 20 20 20 64 67 20 61 72 63 ild".. dg arc
1460: 20 73 65 74 20 24 61 20 63 6f 6c 6f 72 20 72 65 set $a color re
1470: 64 0a 09 7d 0a 20 20 20 20 7d 0a 7d 0a 0a 23 20 d..}. }.}..#
1480: 43 6f 6e 76 65 72 74 20 74 68 65 20 67 72 61 70 Convert the grap
1490: 68 20 74 6f 20 64 6f 74 2c 20 74 68 65 6e 20 72 h to dot, then r
14a0: 75 6e 20 74 68 65 20 6c 61 79 6f 75 74 65 72 20 un the layouter
14b0: 61 6e 64 20 63 6f 6e 76 65 72 74 20 74 6f 20 70 and convert to p
14c0: 6e 67 2c 0a 23 20 61 74 20 6c 61 73 74 20 73 68 ng,.# at last sh
14d0: 6f 77 20 74 68 65 20 69 6d 61 67 65 2e 0a 0a 76 ow the image...v
14e0: 63 3a 3a 74 6f 6f 6c 73 3a 3a 64 6f 74 20 6c 61 c::tools::dot la
14f0: 79 6f 75 74 20 70 6e 67 20 64 67 20 53 79 6d 62 yout png dg Symb
1500: 6f 6c 54 72 65 65 20 73 74 2e 70 6e 67 0a 65 78 olTree st.png.ex
1510: 65 63 20 64 69 73 70 6c 61 79 20 73 74 2e 70 6e ec display st.pn
1520: 67 0a 66 69 6c 65 20 64 65 6c 65 74 65 20 73 74 g.file delete st
1530: 2e 70 6e 67 0a 65 78 69 74 0a .png.exit.