diff options
Diffstat (limited to 'modules/tree')
l--------- | modules/tree/Makefile | 1 | ||||
-rw-r--r-- | modules/tree/Makefile.inc.mk | 2 | ||||
-rw-r--r-- | modules/tree/Module.mk | 3 | ||||
-rw-r--r-- | modules/tree/addparent.d.sh | 44 | ||||
-rw-r--r-- | modules/tree/addparent.f.sh | 27 | ||||
-rw-r--r-- | modules/tree/addparent.sh | 35 | ||||
-rw-r--r-- | modules/tree/commit.sh | 27 | ||||
-rw-r--r-- | modules/tree/delparent.f.sh | 34 | ||||
-rw-r--r-- | modules/tree/getchildren.sh | 28 | ||||
-rw-r--r-- | modules/tree/getparents.sh | 27 | ||||
-rw-r--r-- | modules/tree/print.sh | 27 |
11 files changed, 255 insertions, 0 deletions
diff --git a/modules/tree/Makefile b/modules/tree/Makefile new file mode 120000 index 0000000..fa7273c --- /dev/null +++ b/modules/tree/Makefile @@ -0,0 +1 @@ +../module.mk
\ No newline at end of file diff --git a/modules/tree/Makefile.inc.mk b/modules/tree/Makefile.inc.mk new file mode 100644 index 0000000..82c0b58 --- /dev/null +++ b/modules/tree/Makefile.inc.mk @@ -0,0 +1,2 @@ +src_files += addparent.d.sh addparent.f.sh addparent.sh commit.sh delparent.f.sh getchildren.sh getparents.sh print.sh +out_files += addparent.d addparent.f addparent commit delparent.f getchildren getparents print diff --git a/modules/tree/Module.mk b/modules/tree/Module.mk new file mode 100644 index 0000000..2485770 --- /dev/null +++ b/modules/tree/Module.mk @@ -0,0 +1,3 @@ +commit/tags :: commit/tree +commit/tree :: commit/files + diff --git a/modules/tree/addparent.d.sh b/modules/tree/addparent.d.sh new file mode 100644 index 0000000..db43dd2 --- /dev/null +++ b/modules/tree/addparent.d.sh @@ -0,0 +1,44 @@ +#!/usr/bin/env bash +name='addparent.d' +ver=0.1 +# Copyright (C) 2010 Luke Shumaker +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see <http://www.gnu.org/licenses>. + +usage="usage: $RVS $name CHILD PARENT" + child=${1?"$usage"} +parent=${2?"$usage"} + +tc="`mktemp`" +tp="`mktemp`" + +"$RVS" ls "$child" '%i\t%n' > "$tc" +"$RVS" ls "$parent" '%i\t%n' > "$tp" + +while read line; do + name="`echo "$line" | cut -f2-`" + nID="`echo "$line" | cut -f1`" + oID="`sed -n "s:^\([a-z]\:[0-9a-f]*\)\t${name/:/\\:}$:\1:p" "$tp"`" + + if [ -n "$oID" ]; then + nT="`"$RVS" blob-gettype "$nID"`" + oT="`"$RVS" blob-gettype "$oID"`" + if [ "$nT" = "$oT" ]; then + "$RVS" addparent "$nID" "$oID" + fi + fi +done < "$tc" + +"$RVS" addparent.f "$child" "$parent" diff --git a/modules/tree/addparent.f.sh b/modules/tree/addparent.f.sh new file mode 100644 index 0000000..61b4f92 --- /dev/null +++ b/modules/tree/addparent.f.sh @@ -0,0 +1,27 @@ +#!/bin/sh +name='addparent.f' +ver=0.1 +# Copyright (C) 2010 Luke Shumaker +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see <http://www.gnu.org/licenses>. + +usage="usage: $RVS $name CHILD PARENT" + child=${1?"$usage"} +parent=${2?"$usage"} + +file="$REPO/tree/$child/$parent" +mkdir -p "`dirname "$file"`" +echo "$parent" > "$file" + diff --git a/modules/tree/addparent.sh b/modules/tree/addparent.sh new file mode 100644 index 0000000..6759bcb --- /dev/null +++ b/modules/tree/addparent.sh @@ -0,0 +1,35 @@ +#!/bin/sh +name='addparent' +ver=0.1 +# Copyright (C) 2010 Luke Shumaker +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see <http://www.gnu.org/licenses>. + +usage="usage: $RVS $name CHILD PARENT" + child=${1?"$usage"} +parent=${2?"$usage"} + +if [ ! "$child" = "$parent" ]; then + ct="`"$RVS" blob-gettype "$child"`" + pt="`"$RVS" blob-gettype "$parent"`" + + if [ "$ct" = "$pt" ]; then + "$RVS" "addparent.$ct" "$child" "$parent" + else + echo "$0: CHILD and PARENT must be the same type">>/dev/stderr + exit 1 + fi +fi + diff --git a/modules/tree/commit.sh b/modules/tree/commit.sh new file mode 100644 index 0000000..89b1bf6 --- /dev/null +++ b/modules/tree/commit.sh @@ -0,0 +1,27 @@ +#!/bin/sh +name='rvs @ID@ commit' +ver=0.1 +# Copyright (C) 2010 Luke Shumaker +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see <http://www.gnu.org/licenses>. + +if [ "$RVS_LEVEL" = '0' ]; then + id=`cat "$TMPDIR/commit/files"` + wch="`"$RVS" tag-id wch 2>/dev/null`" + if [ -n "$wch" ]; then + "$RVS" addparent "$id" "$wch" + fi +fi + diff --git a/modules/tree/delparent.f.sh b/modules/tree/delparent.f.sh new file mode 100644 index 0000000..e53df9b --- /dev/null +++ b/modules/tree/delparent.f.sh @@ -0,0 +1,34 @@ +#!/bin/sh +name='delparent.f' +ver=0.1 +# Copyright (C) 2010 Luke Shumaker +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see <http://www.gnu.org/licenses>. + +usage="usage: $RVS $name CHILD PARENT" + child=${1?"$usage"} +parent=${2?"$usage"} + +file="$REPO/tree/$child/$parent" +rm "$file" +if [ -z "$(ls "`dirname "$file"`")" ]; then + rmdir "`dirname "$file"`" +fi + + dir="$REPO/tree/$child" +if [ -z "$(ls "`dirname "$dir"`")" ]; then + rmdir "`dirname "$dir"`" +fi + diff --git a/modules/tree/getchildren.sh b/modules/tree/getchildren.sh new file mode 100644 index 0000000..952522c --- /dev/null +++ b/modules/tree/getchildren.sh @@ -0,0 +1,28 @@ +#!/bin/sh +name='getchildren' +ver=0.1 +# Copyright (C) 2010 Luke Shumaker +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see <http://www.gnu.org/licenses>. + +usage="Usage: $RVS $name ID" +id="${1?"$usage"}" + +dir="$REPO/@ID@/" +if [ -d "$dir" ]; then + grep -rFxh "$id" "$dir" +fi + + diff --git a/modules/tree/getparents.sh b/modules/tree/getparents.sh new file mode 100644 index 0000000..6e3edbd --- /dev/null +++ b/modules/tree/getparents.sh @@ -0,0 +1,27 @@ +#!/bin/sh +name='getparents' +ver=0.1 +# Copyright (C) 2010 Luke Shumaker +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see <http://www.gnu.org/licenses>. + +usage="Usage: $RVS $name ID" +id="${1?"$usage"}" + +dir="$REPO/@ID@/$id" +if [ -d "$dir" ]; then + cat "$dir"/* +fi + diff --git a/modules/tree/print.sh b/modules/tree/print.sh new file mode 100644 index 0000000..0ebf8fd --- /dev/null +++ b/modules/tree/print.sh @@ -0,0 +1,27 @@ +#!/bin/sh +name='print' +ver=0.1 +# Copyright (C) 2010 Luke Shumaker +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; see the file COPYING. +# If not, see <http://www.gnu.org/licenses>. + +usage="Usage: $RVS $name ID" +id="${1?"$usage"}" + +echo "Parents:" +"$RVS" getparents "$id" | sed 's/\(.*\)/ \1/' +echo "Children:" +"$RVS" getchildren "$id" | sed 's/\(.*\)/ \1/' + |