[TopGit PATCH] tg-tred: Print the transitive reduction of the dependecies

Subsystems: the rest

DORMANTno replies

4 messages, 2 authors, 2016-06-15 · open the first message on its own page

[TopGit PATCH] tg-tred: Print the transitive reduction of the dependecies

From: Bert Wesarg <hidden>
Date: 2016-06-15 22:46:28

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 <redacted>

---
 .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)

Re: [TopGit PATCH] tg-tred: Print the transitive reduction of the dependecies

From: Uwe Kleine-König <hidden>
Date: 2016-06-15 22:46:28

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/  |

Re: [TopGit PATCH] tg-tred: Print the transitive reduction of the dependecies

From: Bert Wesarg <hidden>
Date: 2016-06-15 22:46:28

2009/3/25 Uwe Kleine-König [off-list ref]:
Hello,

On Wed, Mar 25, 2009 at 11:35:41AM +0100, Bert Wesarg wrote:
quoted
+$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

Re: [TopGit PATCH] tg-tred: Print the transitive reduction of the dependecies

From: Bert Wesarg <hidden>
Date: 2016-06-15 22:46:28

quoted
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.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help