Re: [TopGit PATCH] tg-graph: print dependency graph like git log --graph

Previous thread: committing to a checked out branch by Jeff Brown on Monday, May 18, 2009 - 5:33 pm. (5 messages)

Next thread: gitweb: Comments on perlcritic suggestions with severity 3 (harsh) by Jakub Narebski on Tuesday, May 19, 2009 - 1:40 am. (1 message)
From: Bert Wesarg
Date: Monday, May 18, 2009 - 10:44 pm

Finally, I have managed to work on an old idea: to display the dependency graph
line-by-line on the console.  The insiration comes from the git log --graph
command, the implementation too.  I have ported the graph.c file from the
GIT project into the GVPR graph processing language from the graphviz package.
Thats why I have Cc'ed Adam, the original author of the GIT graph API and I
would like to thank him for it.  But I must also apologize to him that I
haven't gave him credit in this first patch (only here in the message).  Which
should be done, before accepting into the topgit.git.

Actually, this is still a proof-of-concept, because I'm uncertain wheather we
need a new command for this or not.

As you can see from the tg graph options, there is many you can tweak.  I think
the dfs options gives compacter graphs for depending topics.  Dfs gives
compacter graphs for the reversed dependencies (i.e. master as first line) for
me too.  So dfs should probably the default.

Please try.

Thanks,
Bert

Signed-off-by: Bert Wesarg <bert.wesarg@googlemail.com>

---
 .gitignore                 |    2 +
 Makefile                   |    1 +
 README                     |    6 +
 contrib/tg-completion.bash |   25 +
 share/graph.gvpr           | 1043 ++++++++++++++++++++++++++++++++++++++++++++
 tg-graph.sh                |   74 ++++
 tg-summary.sh              |   47 ++-
 7 files changed, 1189 insertions(+), 9 deletions(-)

diff --git a/.gitignore b/.gitignore
index eb56446..fcc7f95 100644
--- a/.gitignore
+++ b/.gitignore
@@ -21,6 +21,8 @@
 /tg-import.txt
 /tg-remote
 /tg-remote.txt
+/tg-graph
+/tg-graph.txt
 /tg
 .*.swp
 
diff --git a/Makefile b/Makefile
index 3ce39a5..0de1277 100644
--- a/Makefile
+++ b/Makefile
@@ -38,6 +38,7 @@ install:: all
 	install $(hooks_out) "$(DESTDIR)$(hooksdir)"
 	install -d -m 755 "$(DESTDIR)$(sharedir)"
 	install -m 644 $(help_out) "$(DESTDIR)$(sharedir)"
+	install -m 644 share/graph.gvpr "$(DESTDIR)$(sharedir)"
 
 clean::
 	rm -f tg ...
From: Michael Radziej
Date: Tuesday, May 19, 2009 - 3:27 am

Hi,

I'm really looking forward for a tool like this and tried your patch
instantly, but I keep getting:

gvpr: "/usr/local/share/topgit/graph.gvpr", line 936: gg_nl_ret +=
graph_output_commit_line();<<< 
 -- cannot convert node_t to string
Error: <stdin>:16: syntax error near line 16
context:  >>> \ <<< t"t/conflicts" -> "master";

I have no idea what graph.gvpr is trying. My repo is available at:

git://github.com/mradziej/topgit.git

Your patch is on t/tg-graph. I tried "tg graph" on this repo.

Any idea?

Cheers

Michael

-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100
http://www.noris.de - The IT-Outsourcing Company
 
Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - 
Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689
--

From: Bert Wesarg
Date: Tuesday, May 19, 2009 - 3:37 am

No, it works here. Which version of graphviz do you have?

Thanks,
--

From: Michael Radziej
Date: Tuesday, May 19, 2009 - 4:08 am

I tried two versions on debian:

2.8-3+etch1 (debian etch)
2.20.2-3~bpo40+1 (debian etch-backports)

I also tried it on a different host running Ubuntu with
2.16-3ubuntu2

Which one did you use?

Michael

-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100
http://www.noris.de - The IT-Outsourcing Company
 
Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - 
Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689
--

From: Bert Wesarg
Date: Tuesday, May 19, 2009 - 4:48 am

The 2.20.2 one.

And you see the error with all 3?

Can you send the output from 'tg summary --graphviz' too?

--

From: Michael Radziej
Date: Tuesday, May 19, 2009 - 6:10 am

# GraphViz output; pipe to:
#   | dot -Tpng -o <ouput>
# or
#   | dot -Txlib

digraph G {

        graph [
                rankdir = "TB"
                label="TopGit Layout\n\n\n"
                fontsize = 14
                labelloc=top
                pad = "0.5,0.5"
        ];

\t"t/conflicts" -> "master";
\t"t/python" -> "master";
\t"t/tg-graph" -> "master";
}

Michael


-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100
http://www.noris.de - The IT-Outsourcing Company
 
Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - 
Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689
--

From: Bert Wesarg
Date: Tuesday, May 19, 2009 - 6:32 am

can you remove the '\t' and pipe the resulting file into this command
inside your topgit work dir:

cat "$file" | gvpr -f share/graph.gvpr

--

From: Michael Radziej
Date: Tuesday, May 19, 2009 - 6:39 am

Works:

* t/conflicts
| * t/python
|/  
| * t/tg-graph
|/  
* master

(Wow, I had no idea graphviz can produce ASCII art!)

Where's the '\t' from? Is it a result of the "t/" prefix I used for the
topic branches?

Michael

-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100
http://www.noris.de - The IT-Outsourcing Company
 
Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - 
Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689
--

From: Bert Wesarg
Date: Tuesday, May 19, 2009 - 6:51 am

No its just a formating tab to make the output of summary --graphviz nicer ;-)

As martin suggests, you can remove any "\t" from the 'echo' lines in
tg-summary or add a '-e' option to it.

I will probably post tomorrow an updated patch.

--

From: Michael Radziej
Date: Tuesday, May 19, 2009 - 7:09 am

Cool. If I had any knowledge of graphviz I'd really like to help out :-(

I see another issue. On a quite complicated repository, I did the "tg
summary --graphviz ... edit ...  graphviz ..." dance, and there I get the
following output:

mir@mir:otrs-git$ cat /tmp/graph | gvpr -f ~/src/topgit/share/graph.gvpr
gvpr: "/home/mir/src/topgit/share/graph.gvpr", line 936: gg_nl_ret +=
graph_output_commit_line();<<<
 -- cannot convert node_t to string

I have attached /tmp/graph (the output of tg summary --graphviz), I can't
find anything that would stick out. I have to prepare this particular
project a bit before I could push it out to git hub (removing configuration
part with not-so-public content), do you need it at all?

I'm going to be away from mail for a few hours.


Thanks for your efforts!

Michael


-- 
noris network AG - Deutschherrnstraße 15-19 - D-90429 Nürnberg -
Tel +49-911-9352-0 - Fax +49-911-9352-100
http://www.noris.de - The IT-Outsourcing Company
 
Vorstand: Ingo Kraupa (Vorsitzender), Joachim Astel, Hansjochen Klenk - 
Vorsitzender des Aufsichtsrats: Stefan Schnabel - AG Nürnberg HRB 17689
From: Bert Wesarg
Date: Tuesday, May 19, 2009 - 7:14 am

From: Bert Wesarg
Date: Tuesday, May 19, 2009 - 7:32 am

And still I can't reproduce it here :(

Bert
--

From: Bert Wesarg
Date: Tuesday, May 19, 2009 - 9:45 am

I found a missing rename which causes random segfaults.

Here the diff:

--- a/share/graph.gvpr
+++ b/share/graph.gvpr
@@ -523,7 +523,7 @@ BEGIN {
                  * print the branch lines as "|".
                  */
                 if (gg_prev_state == GRAPH_POST_MERGE &&
-                    gg_prev_commit_index < gg_opcl_i)
+                    gg_prev_n_index < gg_opcl_i)
                     gg_opcl_sb += gg_write_column(gg_columns[gg_opcl_i], "\\");
                 else
                     gg_opcl_sb += gg_write_column(gg_columns[gg_opcl_i], "|");

patch tomorrow

Bert
--

From: Bert Wesarg
Date: Tuesday, May 19, 2009 - 4:47 am

The 2.20.2 one.

And you see the error with all 3?

Can you send the output from 'tg summary --graphviz' too?

--

From: martin f krafft
Date: Tuesday, May 19, 2009 - 6:28 am

You need to pass -e to echo for it to honour escape sequences. That
should solve Michael's problem. Alternatively, just use ^I directly.

-- 
`. `'`   http://people.debian.org/~madduck    http://vcs-pkg.org
  `-  Debian - when you have better things to do than fixing systems
 
"in just seven days, i can make you a man!"
                                      -- the rocky horror picture show
From: Bert Wesarg
Date: Tuesday, May 19, 2009 - 6:33 am

Correct, thanks. Looks like a feature from bash or dash to honor
escape sequences without -e'

Bert
From: Uwe =?iso-8859-1?Q?Kleine-K=F6nig?=
Date: Tuesday, May 19, 2009 - 11:44 am

Hi Bert,

quoting
http://www.gnu.org/software/hello/manual/autoconf/Limitations-of-Builtins.html#Limitat...

	It is not possible to use `echo' portably unless both options
	and escape sequences are omitted.

... use printf instead.

Best regards
Uwe

-- 
Pengutronix e.K.                              | Uwe Kleine-König            |
Industrial Linux Solutions                    | http://www.pengutronix.de/  |
--

From: Bert Wesarg
Date: Tuesday, May 19, 2009 - 11:07 pm

Thank you for this valuable link, Will switch to printf.

--

Previous thread: committing to a checked out branch by Jeff Brown on Monday, May 18, 2009 - 5:33 pm. (5 messages)

Next thread: gitweb: Comments on perlcritic suggestions with severity 3 (harsh) by Jakub Narebski on Tuesday, May 19, 2009 - 1:40 am. (1 message)