blob: f2f90dde0c9f7a0982838f128ceac459bec7e664 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
##
# systr_repo_create_commit [<path>]
#
# Create a new commit directory within the repository. This function
# is polymorphic for both local and remote repositories. The new
# commit ID is printed to stdout.
##
function systr_repo_create_commit
{
if [ $# -gt 0 ]; then
path="$1"
fi
if [[ "$remote" == "" ]]; then
(
cd "$path"
cd "revs/"
mktemp -d XXXXXXXX
)
else
ssh "$remote" "systrunk create-commit \"$path\""
fi
}
##
# systr_repo_finish_commit <commit> <parent> [<merge>]
#
# Finish writing a commit by adding meta-data to the commit directory.
# The commit mesasge is taken from the file <commit>.mesg at the root
# of the repository directory. If <merge> is given, it is written to
# .merge.systr in the commit. This function is polymorphic for both
# local and remote repositories.
##
function systr_repo_finish_commit
{
if [ $# -lt 2 ]; then
echo "Fatal: too few arguments to systr_repo_finish_commit"
exit 1
fi
commit="$1"
parent="$2"
if [ $# -gt 2 ]; then
merge="$3"
else
merge=""
fi
if [ -f ".systr/author" ]; then
read author <.systr/author
else
author="Anonymous"
fi
if [ -f ".systr/email" ]; then
read email <.systr/email
else
email="<anon>"
fi
if [[ "$remote" == "" ]]; then
(
cd "$path"
cd "revs/"
cd "$commit"
echo "$parent" >.commit.systr
echo "$author" >.author.systr
echo "$email" >.email.systr
date >.date.systr
mv "../$commit.mesg" ".mesg.systr"
if [[ "$merge" != "" ]]; then
echo "$merge" >.merge.systr
fi
)
else
ssh "$remote" "systrunk finish-commit \"$commit\" \"$parent\" \
\"$author\" \"$email\" \"$merge\""
fi
}
##
# systr_repo_set_reference <symref> <commit>
#
# Update <symref> to point to <commit>. If <symref> doesn't exist,
# it is created. This function is polymorphic for both local and
# remote repositories.
##
function systr_repo_set_reference
{
if [ $# -lt 2 ]; then
echo "Fatal: too few arguments to systr_repo_set_reference"
exit 1
fi
symref="$1"
commit="$2"
if [[ "$symref" == "BASE" ]]; then
echo "Fatal: will not define BASE in the repository"
exit 1
elif [[ "$symref" == "TRAC" ]]; then
echo "Fatal: will not define TRAC in the repository"
exit 1
elif [[ "$symref" == "NULL" ]]; then
echo "Fatal: will not define NULL in the repository"
exit 1
elif [[ "$symref" == "MERG" ]]; then
echo "Fatal: will not define MERG in the repository"
exit 1
fi
if [[ "$remote" == "" ]]; then
(
cd "$path"
cd "refs/"
echo "$commit" >"$symref"
)
else
ssh "$remote" "systrunk set-ref \"$symref\" \"$commit\""
fi
}
##
# systr_repo_tag <name>
#
# Tag the current commit. This creates a new branch which references
# BASE.
##
function systr_repo_tag
{
if [ $# -lt 1 ]; then
echo "Fatal: too few arguments to systr_repo_tag"
exit 1
fi
name="$1"
systr_repo_set_reference "$name" "$BASE"
}
|