2
# Copyright (C) 2004 Aaron Bentley
4
# See the file "COPYING" for further information about
5
# the copyright and warranty status of this work.
7
# Runs a standard aba command
10
if [ -z "$abaname" ]; then
11
aba "$(basename $0)" "$@"
18
if [ "$1" = "-h" ] ; then
20
elif [ "$1" = "--help" ] ; then
22
elif [ "$1" = "-H" ] ; then
26
if [ -n "$ABAFILTER" ]; then
27
cmd_exec "$@" | $ABAFILTER
39
# Runs a command that functions as a tla wrapper
40
# The difference from aba_run is the handling of extended help
43
if [ -z "$abaname" ]; then
44
aba "$(basename $0)" "$@"
51
if [ "$1" = "-h" ] ; then
53
elif [ "$1" = "--help" ] ; then
55
elif [ "$1" = "-H" ] ; then
58
if [ -n "$ABAFILTER" ]; then
59
cmd_exec "$@" | $ABAFILTER
71
# Outputs the tag source of the current tree, according to patch-logs
72
# May be wrong under certain contrived circumstances
75
logs=$(tla logs 2>/dev/null)
80
tagsource=$(for r in $logs; do tla cat-log $r;done|grep "Continuation-of: "|head -n 1|sed s/"Continuation-of: "//)
81
if [ -z "$tagsource" ]; then
87
#Converts a fully-qualified revision to a fully-qualified version
90
echo $(tla parse-package-name -a $1)/$(tla parse-package-name --package-version $1)
93
# Outputs a full revision name; input may be either
94
# a full revision name
95
# a patchlevel refering to the current tree version
96
aba_revision_or_version()
98
name=$(aba_full_revision $@)
99
if [ -z "$name" ]; then
100
if tla valid-package-name -p -v $1; then
107
# Outputs a full revision name; input may be either
108
# a full revision name
109
# a patchlevel refering to the current tree version
116
if tla valid-package-name -p -v --lvl $1; then
119
newname=`tla tree-version 2> /dev/null`--$1
120
if tla valid-package-name -p -v --lvl $newname; then
126
# Executes the given command, omitting the last $1 lines
127
# $1 is the number of lines
133
my_local_lines="$(expr $("$@" | wc -l) - $n)"
134
"$@" | head -n $my_local_lines
138
# Outputs a tla-style command description
143
printf "%28s : %s\n" $cmd "$*"
146
# Creates a temporary directory and outputs its filename
149
if [ -z "$TMPDIR" ]; then
152
mktemp -d "$TMPDIR/aba.XXXXXX"
153
if [ $? -ne 0 ] ; then
154
echo "panic: Could not create temporary directory!"
159
# Outputs a temporary filename
162
if [ -z "$TMPDIR" ]; then
165
mktemp "$TMPDIR/aba.XXXXXX"
166
if [ $? -ne 0 ] ; then
167
echo "panic: Could not create temporary file!"
172
# Attempts to execute a command, panics if returns non-zero
176
if [ $? -ne 0 ] ; then
177
echo PANIC: failed to execute $@ >&2
182
# Undoes a star-merge
183
# Takes the same parameters as star-merge (except --changes)
184
aba_star_merge_undo()
187
treeroot=$(tla tree-root)
188
echo "* undoing current changes"
189
aba_try tla undo > /dev/null
190
echo "* generating star-merge changeset"
191
aba_try tla star-merge --changes $tmp/merge-undo "$@" > /dev/null
192
echo "* redoing changes"
193
aba_try tla redo > /dev/null
194
echo "* reverse-applying star-merge changeset"
195
tla dopatch --reverse $tmp/merge-undo $treeroot
197
if [ $status -gt 1 ]; then
198
echo Failed to execute tla dopatch --reverse $tmp/merge-undo . >&2
205
# Outputs the project tree revision
208
tla logs -d "${1:-.}" -r -f | head -n 1
211
# Break any links that the given file may have
214
cp -p $1 '++brokelink' && mv '++brokelink' $1
215
if [ $? -ne 0 ]; then
216
echo "Can't break link for $1"
221
# Ensure that the project tree has no uncommitted changes
224
tla changes > /dev/null
226
if [ $status -eq 1 ]; then
227
echo Project tree has uncommitted changes. Aborting. 2>&2
230
if [ $status -gt 1 ]; then
235
# Determine whether a command supports a given option (long form required)
236
aba_supports_option()
238
tla $1 -h | grep -- "--$2" >/dev/null
242
# Echoes message to stderr, exits with status 2
251
tree_root=`tla tree-root 2> /dev/null`
252
if [ $? -ne 0 ]; then
253
echo "not in project tree ($(pwd))" >&2
257
if [ -f $tree_root/{arch}/+partner-versions ]; then
258
partnerfile=$tree_root/{arch}/+partner-versions
260
partnerfile=$tree_root/{arch}/=partner-versions
262
mergefile=$tree_root/++merge-source
265
sourcetype="[supplied]"
266
elif [ -f $partnerfile ] ; then
267
sourcever=$(cat $partnerfile)
268
sourcetype="[from partner-versions]"
269
elif [ -f $mergefile ] ; then
270
sourcever=$(cat $mergefile)
271
sourcetype="[from ++merge-source]"
273
treesource=$(aba_tree_source)
276
if [ $status -eq 2 ]; then
277
echo "merge: not in project tree ($(pwd))" >&2
280
if [ $status -ne 0 ]; then
281
echo "aba merge: Unable to find $sourcefile" or tag source >&2
284
sourcever="$(tla parse-package-name -a $treesource)/$(tla parse-package-name --package-version $treesource)"
285
sourcetype="[from tag-source]"
290
tla tag -S `aba_tree_revision` $1
294
root=$(tla tree-root)
295
if [ $? -ne 0 ]; then
296
aba_panic "Unable to determine tree root"
298
from=$(aba_tree_revision)
299
if [ $? -ne 0 ]; then
300
aba_panic "Unable to determine tree revision"
302
to=$(tla revisions -f $1|tail -n 1)
303
if [ $? -ne 0 ]; then
304
aba_panic "Unable to determine target revision"
306
if [ -z "$to" ]; then
307
aba_panic "Unable to determine target revision"
309
aba_try tla apply-delta --dir $root $from $to
310
aba_try tla set-tree-version $1
312
# arch-tag: runner by Aaron Bentley (07:50 Jan 19, 2004)