如何获取hg history
的输出并将其转换为dot文件?
答案 0 :(得分:5)
您正在寻找this extension。
答案 1 :(得分:3)
我写了一个脚本来做这个(并称之为hghistory2dot.pl)。请参阅代码下方的用法:
#!/usr/bin/perl
print "digraph {\n";
$first = 1;
$cset = ();
sub printedge {
my $one = csetstr(shift(@_));
my $two = csetstr(shift(@_));
print $one, " -> ", $two, ";\n";
}
sub csetstr {
my $csetid = shift(@_);
$csetid =~ s/\s//;
$csetid =~ s/\\n//;
return "cset_" . $csetid;
}
while($line = <> ) {
if (!($line eq "\n") ) {
$line =~ s/\n/\\n/;
push(@cset, $line);
}
else {
print csetstr($current), " [shape=record label=\"", @cset, "\"];\n";
@cset = ();
}
if( $line =~ m/^changeset/ ) {
@arr = split(/:/, $line);
$arr[2] =~ s/\s//;
if( ! $parent_found && ! $first) {
#previous changeset had no defined parent; therefore this one is the implied parent.
printedge($current, $arr[2]);
}
$current = $arr[2];
$parent_found = 0;
$first = 0;
}
elsif($line =~ m/^parent/) {
$parent_found = 1;
@arr = split(/:/, $line);
$arr[2] =~ s/\s//;
printedge($current, $arr[2]);
}
}
print "}\n";
hg history | hghistory2dot.pl | dot -Tpng > tree.png