monotone

monotone Commit Details

Date:2005-05-21 15:44:41 (14 years 27 days ago)
Author:jcrisp@s-r-s.co.uk
Branch:net.venge.monotone.contrib.monotree
Commit:35cff8e8ba14155f5f7ddf7965073f514fd60f61
Parents: 5d288b39b49613b0d9dca8ece6b9a42c3773f35b
Message:Fixed some issues with header ordering, added DTD to jar for operation behind a firewall

Changes:
Acontrib/monotree/gxl-1.0.dtd (full)
Mcontrib/monotree/GXLViewer.java (2 diffs)
Mcontrib/monotree/Log2Gxl.java (9 diffs)
Mcontrib/monotree/Makefile (1 diff)
Mcontrib/monotree/Monotone.java (5 diffs)

File differences

contrib/monotree/GXLViewer.java
401401
402402
403403
404
404
405405
406406
407407
......
588588
589589
590590
591
591
592
592593
593594
594595
public void run() {
try {
logger.fine("Getting log for "+id);
final InputStream svgStream=database.getSVGLog(id);
final InputStream svgStream=database.getSVGLog(id,Monotone.HighlightTypes.AUTHORS);
SAXSVGDocumentFactory factory=new SAXSVGDocumentFactory(XMLResourceDescriptor.getXMLParserClassName());
final SVGDocument doc=factory.createSVGDocument("http://internal/graph",svgStream);
SwingUtilities.invokeLater(new Runnable() { public void run() {
JTextField property=new JTextField(id);
property.setEditable(false);
info.add(property,c);
GXLNode gxlNode=(GXLNode)database.log2gxl.gxlDocument.getElement(id);
GXLDocument doc=database.log2gxl.gxlDocument;
GXLNode gxlNode=(GXLNode)doc.getElement(id);
addInfo(info,gxlNode,"Authors");
addInfo(info,gxlNode,"Branches");
addInfo(info,gxlNode,"Tags");
contrib/monotree/Log2Gxl.java
2323
2424
2525
26
2627
2728
2829
......
5455
5556
5657
57
58
5859
59
60
6061
6162
63
6264
6365
6466
......
267269
268270
269271
270
272
271273
272
273
274
275
274276
275277
276278
......
287289
288290
289291
292
293
294
295
296
297
298
299
300
290301
291302
292303
......
413424
414425
415426
427
428
416429
417430
418431
419432
420
421
422433
423434
424435
425436
426437
427438
428
439
429440
430441
431442
432443
444
445
446
447
448
433449
434450
435
451
436452
437453
438454
......
11551171
11561172
11571173
1158
1174
11591175
11601176
1161
1162
1163
1177
1178
1179
11641180
1165
1166
1181
1182
11671183
1168
1169
1184
1185
11701186
1171
1187
11721188
1173
1189
11741190
11751191
11761192
11771193
11781194
11791195
1180
1196
11811197
11821198
11831199
11841200
11851201
11861202
1187
1203
11881204
11891205
11901206
......
11951211
11961212
11971213
1198
1214
11991215
12001216
12011217
......
12031219
12041220
12051221
1206
1207
1222
1223
12081224
1209
1225
12101226
12111227
12121228
......
12261242
12271243
12281244
1245
12291246
12301247
12311248
import java.util.ArrayList;
import java.util.Arrays;
import java.util.logging.Logger;
import java.util.logging.Level;
import net.sourceforge.gxl.GXLDocument;
import net.sourceforge.gxl.GXLGraph;
import net.sourceforge.gxl.GXLNode;
* Main method
* Invoke via: monotone --db=database.db log id | java -classpath gxl.jar:. uk.co.srs.monotree.Log2Gxl | xslt gxl2dot.xsl >log.dot
* or monotone --db=database.db log id | java -classpath gxl.jar:. uk.co.srs.monotree.Log2Gxl | xslt gxl2dot.xsl | dot -Tsvg >log.svg
* or monotone --db=database.db log id | java -classpath gxl.jar:. uk.co.srs.monotree.Log2Gxl --authorfile <file> | xslt gxl2dot.xsl | dot -Tsvg >log.svg
* or monotone --db=database.db log id | java -classpath gxl.jar:. uk.co.srs.monotree.Log2Gxl --colorfile <file> | xslt gxl2dot.xsl | dot -Tsvg >log.svg
*
* @param argv command line arguments, --authorfile <file> to specify a file mapping authors to colors
* @param argv command line arguments, --colorfile <file> to specify a file mapping authors to colors
*/
public static void main(String argv[]) throws IOException,IllegalStateException,InterruptedException {
logger.setLevel(Level.FINEST);
Log2Gxl processor=new Log2Gxl();
processor.start(argv);
processor.join();
addToAttributeSet("Authors",author);
if(colorAuthors) {
String color=authorColorMap.get(author);
String color=highlightColorMap.get(author);
if(color==null) {
color=colors[authorColorMap.size()];
authorColorMap.put(author,color);
color=colors[highlightColorMap.size()];
highlightColorMap.put(author,color);
}
currentNode.setAttr("AuthorColor",new GXLString(color));
}
String branch=line.substring("Branch:".length()+1);
if(branch.length()!=0) {
addToAttributeSet("Branches",branch);
if(colorBranches) {
String color=highlightColorMap.get(branch);
if(color==null) {
color=colors[highlightColorMap.size()];
highlightColorMap.put(branch,color);
}
currentNode.setAttr("BranchColor",new GXLString(color));
}
}
}
String line=source.readLine();
if(line.length()>0) throw new IOException(source.getLineNumber()+": Unexpected data ["+line+"]");
line=lookahead();
if(line.startsWith("Deleted files:")) parseDeletedFiles();
line=lookahead();
if(line.startsWith("Renamed files:")) parseRenamedFiles();
line=lookahead();
if(line.startsWith("Renamed directories:")) parseRenamedDirectories();
line=lookahead();
if(line.startsWith("Deleted files:")) parseDeletedFiles();
line=lookahead();
if(line.startsWith("Added files:")) parseAddedFiles();
line=lookahead();
if(line.startsWith("Modified files:")) parseModifiedFiles();
}
/**
* If true, set the background color of the node to indicate the author
* If true, output a color of the node to indicate the author of the node
*/
private boolean colorAuthors=true;
/**
* If true, output a color attribute to indicate the branch of the node
*/
private boolean colorBranches=true;
/**
* Map of author identifiers to allocated colors
*/
private Map<String,String> authorColorMap=new HashMap<String,String>();
private Map<String,String> highlightColorMap=new HashMap<String,String>();
/**
* Array of color names used to allocate colors
* This file should consist of lines like
* jcrisp@s-r-s.co.uk=black
*
* @param authorFileName the name of the author file (may be qualified)
* @param colorfileName the name of the author file (may be qualified)
* @throws IOException if there is a problem with the author to color mapping file
*/
private void loadAuthorFile(String authorFileName) throws IOException {
Properties authorMap=new Properties();
InputStream authorMapStream=null;
private void loadColorfile(String colorfileName) throws IOException {
Properties colorMap=new Properties();
InputStream colorMapStream=null;
try {
authorMapStream=new FileInputStream(authorFileName);
authorMap.load(authorMapStream);
colorMapStream=new FileInputStream(colorfileName);
colorMap.load(colorMapStream);
List<String> colorList=new ArrayList<String>(Arrays.asList(colors));
for(Object key: authorMap.keySet()) {
String color=(String)authorMap.get(key);
for(Object key: colorMap.keySet()) {
String color=(String)colorMap.get(key);
if(!colorList.contains(color)) {
throw new IOException("Illegal color "+color+" in author color map file");
throw new IOException("Illegal color "+color+" in color map file");
}
authorColorMap.put((String)key,color);
highlightColorMap.put((String)key,color);
logger.config(key+"="+color);
colorList.remove(color);
}
colors=colorList.toArray(new String[colorList.size()]);
}
finally {
if(authorMapStream!=null) authorMapStream.close();
if(colorMapStream!=null) colorMapStream.close();
}
}
/**
* Start parsing the output of a monotone log command and output the corresponding GXL graph
*
* @param argv the command line arguments, --authorfile <file> to specify a file mapping authors to colors
* @param argv the command line arguments, --colorfile <file> to specify a file mapping authors to colors
* @throws IOException if there is a read error on the input stream or the input stream runs dry
* @throws IllegalStateException if the header lines aren't as expected
*/
/**
* Start parsing the output of a monotone log command and output the corresponding GXL graph
*
* @param argv the command line arguments, --authorfile <file> to specify a file mapping authors to colors
* @param argv the command line arguments, --colorfile <file> to specify a file mapping authors to colors
* @throws IOException if there is a read error on the input stream or the input stream runs dry
* @throws IllegalStateException if the header lines aren't as expected
*/
nodes=new HashMap<String,GXLNode>();
if(argv.length>0) {
for(int I=0;I<argv.length;I++) {
if(argv[I]!=null && argv[I].equals("--authorfile")) {
if(I<argv.length-1) loadAuthorFile(argv[I+1]);
if(argv[I]!=null && argv[I].equals("--colorfile")) {
if(I<argv.length-1) loadColorfile(argv[I+1]);
else {
System.err.println("Usage: Log2Gxl --authorfile <authorfile>");
System.err.println("Usage: Log2Gxl --colorfile <colorfile>");
System.exit(-1);
}
}
doRun();
}
catch(Exception e) {
e.printStackTrace();
logger.throwing(this.getClass().getName(),"run",e);
}
}
contrib/monotree/Makefile
22
33
44
5
6
5
6
77
88
99
1010
11
11
1212
1313
1414
all: monotree.jar
monotree.jar: Log2Gxl.class Monotone.class GXLViewer.class META-INF/MANIFEST.MF gxl2dot.xsl
jar cvmf META-INF/MANIFEST.MF monotree.jar Log2Gxl.class Monotone.class GXLViewer.class GXLViewer\$$1.class GXLViewer\$$2.class GXLViewer\$$3.class GXLViewer\$$4.class GXLViewer\$$5.class GXLViewer\$$6.class Monotone\$$ErrorReader.class Monotone\$$StreamCopier.class GXLViewer\$$ReadBranches.class GXLViewer\$$MonotoneFileFilter.class GXLViewer\$$ReadBranches\$$1.class GXLViewer\$$DisplayLog.class GXLViewer\$$DisplayLog\$$1.class GXLViewer\$$GXLUserAgent.class GXLViewer\$$7.class GXLViewer\$$OnClickAction.class gxl2dot.xsl Monotone\$$1.class GXLViewer\$$OnClickAction\$$1.class
monotree.jar: Log2Gxl.class Monotone.class GXLViewer.class META-INF/MANIFEST.MF gxl2dot.xsl gxl-1.0.dtd
jar cvmf META-INF/MANIFEST.MF monotree.jar Log2Gxl.class Monotone.class GXLViewer.class GXLViewer\$$1.class GXLViewer\$$2.class GXLViewer\$$3.class GXLViewer\$$4.class GXLViewer\$$5.class GXLViewer\$$6.class Monotone\$$ErrorReader.class Monotone\$$StreamCopier.class GXLViewer\$$ReadBranches.class GXLViewer\$$MonotoneFileFilter.class GXLViewer\$$ReadBranches\$$1.class GXLViewer\$$DisplayLog.class GXLViewer\$$DisplayLog\$$1.class GXLViewer\$$GXLUserAgent.class GXLViewer\$$7.class GXLViewer\$$OnClickAction.class gxl2dot.xsl Monotone\$$1.class GXLViewer\$$OnClickAction\$$1.class gxl-1.0.dtd Monotone\$$HighlightTypes.class InternalURIResolver.class
Log2Gxl.class: Log2Gxl.java
javac -g -classpath "gxl/gxl-0.92/gxl.jar;." Log2Gxl.java
Monotone.class Monotone$$ErrorReader.class Monotone$$StreamCopier.class Monotone$$1.class : Monotone.java Log2Gxl.class
Monotone.class Monotone$$ErrorReader.class Monotone$$StreamCopier.class Monotone$$1.class Monotone$$HighlightTypes.class InternalURIResolver.class: Monotone.java Log2Gxl.class
javac -g Monotone.java
GXLViewer$$OnClickAction.class GXLViewer$$ReadBranches.class GXLViewer$$2$$1.class GXLViewer$$DisplayLog.class GXLViewer$$1.class GXLViewer$$2.class GXLViewer$$3.class GXLViewer$$4.class GXLViewer$$5 GXLViewer$$6 GXLViewer.class GXLViewer$$MonotoneFileFilter.class GXLViewer$$ReadBranches$$1.class GXLViewer$$DisplayLog$$1.class GXLViewer$$GXLUserAgent.class GXLViewer$$7.class GXLViewer$$OnClickAction$$1.class: GXLViewer.java Monotone.class
contrib/monotree/Monotone.java
2020
2121
2222
23
2324
2425
26
27
2528
2629
2730
......
4952
5053
5154
55
5256
5357
5458
......
103107
104108
105109
110
111
112
113
114
115
106116
107117
108118
109
119
120
110121
111122
112
113
123
124
114125
115126
116
127
117128
118
129
119130
120131
121132
122133
123134
124135
125
126
136
137
138
139
127140
128141
129142
......
131144
132145
133146
134
147
135148
136149
150
137151
152
138153
139154
140155
......
296311
297312
298313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
299330
import java.io.BufferedOutputStream;
import java.io.BufferedInputStream;
import java.util.logging.Logger;
import java.util.logging.Level;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.Source;
import javax.xml.transform.URIResolver;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
*/
public Monotone(File database) {
this.database=database;
logger.setLevel(Level.FINEST);
}
/**
*/
public Log2Gxl log2gxl;
public enum HighlightTypes {
NONE,
AUTHORS,
BRANCHES
};
/**
* Run monotone and get an SVG stream from a log
*
* @param id the identifier for which the log should be generated
* @param id the identifier (revision or file) for which the log should be generated (not null)
* @param highlight an enum specifing the node background highlight type requested
* @return a stream from which an SVG format graph may be read
*/
public InputStream getSVGLog(String id) throws IOException {
String command="log "+id;
public InputStream getSVGLog(final String id,final HighlightTypes highlight) throws IOException {
final String command="log --revision "+id;
// Start the inferior processes
Process monotone=Runtime.getRuntime().exec(getBaseCommand()+command);
final Process monotone=Runtime.getRuntime().exec(getBaseCommand()+command);
new ErrorReader("monotone",monotone.getErrorStream());
Process dot2svg=Runtime.getRuntime().exec("dot -Tsvg");
final Process dot2svg=Runtime.getRuntime().exec("dot -Tsvg");
new ErrorReader("dot2svg",dot2svg.getErrorStream());
final PipedOutputStream gxl2dotSourceOutputStream=new PipedOutputStream();
final PipedInputStream gxl2dotSourceInputStream=new PipedInputStream(gxl2dotSourceOutputStream);
// Chain the log output to the GXL generator and into the dot converter
String[] args=new String[] { "--authorfile","authors.map" };
if(!(new File("authors.map")).exists()) args=new String[0];
final String[] args;
if(!(new File("colors.map")).exists()) args=new String[0];
else args=new String[] { "--colorfile","colors.map" };
log2gxl=new Log2Gxl();
log2gxl.start(args,monotone.getInputStream(),gxl2dotSourceOutputStream);
final PipedInputStream gxl2dotSinkInputStream=new PipedInputStream(gxl2dotSinkOutputStream);
// Create a thread to transform the GXL semantic graph into an DOT visual graph
Thread transformerThread=new Thread(new Runnable() { public void run() {
final Thread transformerThread=new Thread(new Runnable() { public void run() {
try {
TransformerFactory factory=TransformerFactory.newInstance();
factory.setURIResolver(new InternalURIResolver());
Transformer transformer=factory.newTransformer(new StreamSource(ClassLoader.getSystemResourceAsStream("gxl2dot.xsl")));
transformer.setParameter("HIGHLIGHT",highlight.toString());
transformer.transform(new StreamSource(gxl2dotSourceInputStream),new StreamResult(gxl2dotSinkOutputStream));
}
catch(Exception e) {
}
}
}
}
class InternalURIResolver implements URIResolver {
/**
* Log sink
*/
private static Logger logger=Logger.getLogger("Monotone");
public Source resolve(String href,String base) {
logger.info("URI is "+href);
if(href.equals("http://www.gupro.de/GXL/gxl-1.0.dtd")) {
return new StreamSource(ClassLoader.getSystemResourceAsStream("gxl-1.0.dtd"));
}
return null;
}
}
contrib/monotree/gxl-1.0.dtd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<!-- GXL (1.0)
Document Type Definition
(April 25, 2002)
copyright by
Andy Schuerr
Real-Time Systems Lab
Darmstadt University of Technology
Merckstr. 25, D-64283 Darmstadt, Germany
andy.schuerr@es.tu-darmstadt.de
Susan Elliott Sim
School of Information and Computer Science
444 Computer Science Bldg.
University of California, Irvine
ses@ics.uci.edu
Ric Holt
Department of Computer Science
University of Waterloo
Waterloo N2L 3G1, Canada
holt@plg.uwaterloo.ca
Andreas Winter
Institute for Software Technology
University of Koblenz-Landau
Universitaetsstrasse 1, D-56070 Koblenz, Germany
winter@uni-koblenz.de
-->
<!-- Extensions -->
<!ENTITY % gxl-extension "">
<!ENTITY % graph-extension "">
<!ENTITY % node-extension "">
<!ENTITY % edge-extension "">
<!ENTITY % rel-extension "">
<!ENTITY % value-extension "">
<!ENTITY % relend-extension "">
<!ENTITY % gxl-attr-extension "">
<!ENTITY % graph-attr-extension "">
<!ENTITY % node-attr-extension "">
<!ENTITY % edge-attr-extension "">
<!ENTITY % rel-attr-extension "">
<!ENTITY % relend-attr-extension "">
<!-- Attribute values -->
<!ENTITY % val "
locator |
bool |
int |
float |
string |
enum |
seq |
set |
bag |
tup
%value-extension;">
<!-- gxl -->
<!ELEMENT gxl (graph* %gxl-extension;) >
<!ATTLIST gxl
xmlns:xlink CDATA #FIXED "http://www.w3.org/1999/xlink"
%gxl-attr-extension;
>
<!-- type -->
<!ELEMENT type EMPTY>
<!ATTLIST type
xlink:type (simple) #FIXED "simple"
xlink:href CDATA #REQUIRED
>
<!-- graph -->
<!ELEMENT graph (type? , attr* , ( node | edge | rel )* %graph-extension;) >
<!ATTLIST graph
id ID #REQUIRED
role NMTOKEN #IMPLIED
edgeids (true | false) "false"
hypergraph (true | false) "false"
edgemode (directed | undirected | defaultdirected | defaultundirected) "directed"
%graph-attr-extension;
>
<!-- node -->
<!ELEMENT node (type? , attr*, graph* %node-extension;) >
<!ATTLIST node
id ID #REQUIRED
%node-attr-extension;
>
<!-- edge -->
<!ELEMENT edge (type?, attr*, graph* %edge-extension;) >
<!ATTLIST edge
id ID #IMPLIED
from IDREF #REQUIRED
to IDREF #REQUIRED
fromorder CDATA #IMPLIED
toorder CDATA #IMPLIED
isdirected (true | false) #IMPLIED
%edge-attr-extension;
>
<!-- rel -->
<!ELEMENT rel (type? , attr*, graph*, relend* %rel-extension;) >
<!ATTLIST rel
id ID #IMPLIED
isdirected (true | false) #IMPLIED
%rel-attr-extension;
>
<!-- relend -->
<!ELEMENT relend (attr* %relend-extension;) >
<!ATTLIST relend
target IDREF #REQUIRED
role NMTOKEN #IMPLIED
direction (in | out | none) #IMPLIED
startorder CDATA #IMPLIED
endorder CDATA #IMPLIED
%relend-attr-extension;
>
<!-- attr -->
<!ELEMENT attr (attr*, (%val;))>
<!ATTLIST attr
id ID #IMPLIED
name NMTOKEN #REQUIRED
kind NMTOKEN #IMPLIED
>
<!-- locator -->
<!ELEMENT locator EMPTY>
<!ATTLIST locator
xlink:type (simple) #FIXED "simple"
xlink:href CDATA #REQUIRED
>
<!-- atomic values -->
<!ELEMENT bool (#PCDATA)>
<!ELEMENT int (#PCDATA)>
<!ELEMENT float (#PCDATA)>
<!ELEMENT string (#PCDATA)>
<!-- enumeration value -->
<!ELEMENT enum (#PCDATA)>
<!-- composite values -->
<!ELEMENT seq (%val;)*>
<!ELEMENT set (%val;)*>
<!ELEMENT bag (%val;)*>
<!ELEMENT tup (%val;)*>

Archive Download the corresponding diff file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status