git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [TopGit PATCH] tg-tred: Print the transitive reduction of the dependecies
@ 2009-03-25 10:35 Bert Wesarg
  2009-03-25 10:58 ` Uwe Kleine-König
  0 siblings, 1 reply; 4+ messages in thread
From: Bert Wesarg @ 2009-03-25 10:35 UTC (permalink / raw)
  To: Petr Baudis; +Cc: Bert Wesarg, git, martin f krafft, u.kleine-koenig

This uses the tred(1) and gvpr(1) program from the graphviz package to reduce
the dependencies of the given TopGit branch.

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

---
 .gitignore |    2 ++
 README     |   22 ++++++++++++++++++++++
 tg-tred.sh |   47 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore
index eb56446..1061d93 100644
--- a/.gitignore
+++ b/.gitignore
@@ -13,6 +13,8 @@
 /tg-patch.txt
 /tg-summary
 /tg-summary.txt
+/tg-tred
+/tg-tred.txt
 /tg-update
 /tg-update.txt
 /tg-export
diff --git a/README b/README
index d2f095d..a941cb6 100644
--- a/README
+++ b/README
@@ -480,6 +480,28 @@ tg update
 
 	TODO: tg update -a for updating all topic branches
 
+tg tred
+~~~~~~~
+	Prints the transitive reduction of the dependecies for the current
+	or named TopGit branch.
+
+	To actually use this reduced dependencies list, feed the output into
+	the .topdeps file, commit and run tg update, like:
+
+	$ tg tred > .topdeps
+	$ tg add -f .topdeps
+	$ git commit -m "transitive reduce TopGit dependencies"
+	$ tg update
+
+	If you want to see the differences to the current dependencies, run
+	this:
+
+	$ diff -u -L current -L tred <(git show :.topdeps) <(tg tred)
+
+	TODO: tg tred -a for reducing all branches
+	TODO: tg tred -r for reducing recursive all from the current/named
+	      branch
+
 TODO: tg rename
 
 
diff --git a/tg-tred.sh b/tg-tred.sh
new file mode 100644
index 0000000..f41e051
--- /dev/null
+++ b/tg-tred.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+# TopGit - A different patch queue manager
+# (c) Petr Baudis <pasky@suse.cz>              2008
+# (c) Bert Wesarg <bert.wesarg@googlemail.com> 2009
+# GPLv2
+
+name=
+
+
+## Parse options
+
+while [ -n "$1" ]; do
+	arg="$1"; shift
+	case "$arg" in
+	-*)
+		echo "Usage: tg [...] tred [NAME]" >&2
+		exit 1;;
+	*)
+		[ -z "$name" ] || die "name already specified ($name)"
+		name="$arg";;
+	esac
+done
+
+[ -n "$name" ] || name="$(git symbolic-ref HEAD | sed 's#^refs/\(heads\|top-bases\)/##')"
+base_rev="$(git rev-parse --short --verify "refs/top-bases/$name" 2>/dev/null)" ||
+	die "not a TopGit-controlled branch"
+
+type tred >/dev/null 2>&1 ||
+	die "need the tred(1) tool from the graphviz package"
+type gvpr >/dev/null 2>&1 ||
+	die "need the gvpr(1) tool from the graphviz package"
+
+$tg summary --graphviz |
+	tred |
+	gvpr -a "\"${name}\"" '
+BEG_G {
+    node_t  ctr;
+    edge_t  e;
+
+    ctr = isNode($, ARGV[0]);
+    for (e = fstedge(ctr); e; e = nxtedge(e,ctr)) {
+        if (e.head.name != ARGV[0])
+            printf("%s\n", e.head.name);
+    }
+    exit(0);
+}
+'
-- 
tg: (fcb488d..) bw/tred (depends on: master)

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [TopGit PATCH] tg-tred: Print the transitive reduction of the dependecies
  2009-03-25 10:35 [TopGit PATCH] tg-tred: Print the transitive reduction of the dependecies Bert Wesarg
@ 2009-03-25 10:58 ` Uwe Kleine-König
  2009-03-25 11:20   ` Bert Wesarg
  0 siblings, 1 reply; 4+ messages in thread
From: Uwe Kleine-König @ 2009-03-25 10:58 UTC (permalink / raw)
  To: Bert Wesarg; +Cc: Petr Baudis, git, martin f krafft

Hello,

On Wed, Mar 25, 2009 at 11:35:41AM +0100, Bert Wesarg wrote:
> +$tg summary --graphviz |
> +	tred |
> +	gvpr -a "\"${name}\"" '
> +BEG_G {
> +    node_t  ctr;
> +    edge_t  e;
> +
> +    ctr = isNode($, ARGV[0]);
> +    for (e = fstedge(ctr); e; e = nxtedge(e,ctr)) {
> +        if (e.head.name != ARGV[0])
> +            printf("%s\n", e.head.name);
> +    }
> +    exit(0);
> +}
I don't know tred and gvpr, just looked shortly over the manpages.
Anyhow what I consider important is that the order of .topdeps is
stable.  That is

	t/topic1
	master
	t/topic2

must not be rewritten to

	t/topic2
	t/topic1

if master is redundant.  Is this asserted?

Moreover I wonder if the gvpr program could be optimized when E is used
instead of BEG_G, but as I said above, I don't know how gvpr works.

And note that I intend to change the semantic of tg summary s.t. it only
recurses on the current branch instead of all branches.  I think this
doesn't hurt here, though.

Best regards and thanks for your contribution,
Uwe

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [TopGit PATCH] tg-tred: Print the transitive reduction of the  dependecies
  2009-03-25 10:58 ` Uwe Kleine-König
@ 2009-03-25 11:20   ` Bert Wesarg
  2009-03-25 11:24     ` Bert Wesarg
  0 siblings, 1 reply; 4+ messages in thread
From: Bert Wesarg @ 2009-03-25 11:20 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: Petr Baudis, git, martin f krafft

2009/3/25 Uwe Kleine-König <u.kleine-koenig@pengutronix.de>:
> Hello,
>
> On Wed, Mar 25, 2009 at 11:35:41AM +0100, Bert Wesarg wrote:
>> +$tg summary --graphviz |
>> +     tred |
>> +     gvpr -a "\"${name}\"" '
>> +BEG_G {
>> +    node_t  ctr;
>> +    edge_t  e;
>> +
>> +    ctr = isNode($, ARGV[0]);
>> +    for (e = fstedge(ctr); e; e = nxtedge(e,ctr)) {
>> +        if (e.head.name != ARGV[0])
>> +            printf("%s\n", e.head.name);
>> +    }
>> +    exit(0);
>> +}
> I don't know tred and gvpr, just looked shortly over the manpages.
> Anyhow what I consider important is that the order of .topdeps is
> stable.  That is
>
>        t/topic1
>        master
>        t/topic2
>
> must not be rewritten to
>
>        t/topic2
>        t/topic1
>
> if master is redundant.  Is this asserted?
I asked this myself, I haven't looked very deeply but I think it is
stable. And some tests showed this.

>
> And note that I intend to change the semantic of tg summary s.t. it only
> recurses on the current branch instead of all branches.  I think this
> doesn't hurt here, though.
I don't understand and can't confirm this. tg summary calls 'git
for-each-ref refs/top-bases' so all TopGit controlled branches should
be reached.

While I was adding a 'reduce' subcommand to tg-depend (which calls
tg-tred and updates .topdeps) I saw that it is immposible to add a
none TopGit controlled branch to the dependency list, which looks
wrong. Dependencies don't need to be TopGit controlled, like master.

Bert

>
> Best regards and thanks for your contribution,
> Uwe

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [TopGit PATCH] tg-tred: Print the transitive reduction of the  dependecies
  2009-03-25 11:20   ` Bert Wesarg
@ 2009-03-25 11:24     ` Bert Wesarg
  0 siblings, 0 replies; 4+ messages in thread
From: Bert Wesarg @ 2009-03-25 11:24 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: Petr Baudis, git, martin f krafft

>> if master is redundant.  Is this asserted?
> I asked this myself, I haven't looked very deeply but I think it is
> stable. And some tests showed this.
BTW: Because of this uncertainty I implemented it so, that it just
shows the reduced dep list not alter the current one. Anyway, you can
always check what changed with my diff example.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-03-25 11:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-03-25 10:35 [TopGit PATCH] tg-tred: Print the transitive reduction of the dependecies Bert Wesarg
2009-03-25 10:58 ` Uwe Kleine-König
2009-03-25 11:20   ` Bert Wesarg
2009-03-25 11:24     ` Bert Wesarg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).