-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathaccurev.conf
185 lines (168 loc) · 4.13 KB
/
accurev.conf
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
export ACCUREV_IGNORE_ELEMS="tags .ant-targets-build.xml .DS_Store"
# Diffs pending files
acc-diff-basic() {
if [[ -z "$1" ]]; then
accurev diff `accurev stat -m -fl` -- -u
else
accurev diff "$@" -- -u
fi
}
# Color diffs pending changes
acc-diff-color() {
acc-diff-basic "$@" | colordiff
}
# Shows a diff of Pending changes
acc-diff() {
if which colordiff > /dev/null; then
acc-diff-color "$@"
else
acc-diff-basic "$@"
fi
}
# Plumbing for getting status for types of files
# but skipping output if there aren't any changes
acc-conditional-status() {
local status result switch
status=$1
case $status in
Pending)
switch=-p
;;
Missing)
switch=-M
;;
External)
switch=-x
;;
Overlap)
switch="-o -B"
;;
esac
echo -ne "Checking $status...\r"
results=`accurev stat $switch`
if [[ -n $results ]]; then
echo "$1: "
echo "$results"
else
echo -ne " \r"
fi
}
# Shows Pending and External changes
acc-st() {
local status
for status in Pending Missing External Overlap; do
acc-conditional-status $status
done
}
# Reverts the given files to their backed (in stream) versions
acc-co() {
accurev purge "$@"
}
# Promotes all pending changes
acc-promotepending() {
accurev promote -K `accurev stat -p -fl` "$@"
}
# Commits the given files to the stream
# NOTE: If one file is modified/kept, this won't work. To fix, we may need to
# manually capture the commit message and keep each file.
acc-commit() {
accurev promote -K "$@"
}
# Interactively shows diffs and prompts for inclusion in the commit set
# NOTE: This won't likely handle files with spaces. But when I tried quoting
# the commit_list entries it caused something to resolve the /./ to pwd.
acc-icommit() {
local file commit_list include_file
for file in `accurev stat -p -fl`; do
acc diff "$file"
echo "$file"
read -p "Include in commit ([y]/n)? " include_file
if echo "$include_file" | grep -i -q n; then
echo "Skipped."
else
commit_list="$commit_list $file"
echo "Included."
fi
echo
done
echo "Committing $commit_list..."
acc commit "$@" $commit_list
}
# Check out a local copy of the given stream.
# Uses the stream name as workspace/local path by default.
# Usage:
# acc clone StreamName [WorkSpaceName] [LocalPath]
acc-clone() {
local STREAM NAME DIR
STREAM="$1"
NAME="${2:-$STREAM}"
DIR="${3:-$NAME}"
accurev mkws -b "$STREAM" -w "$NAME" -l "$DIR"
}
acc-branch-create() {
local STREAM NAME
STREAM="$1"
NAME="$2"
accurev mkstream -s "$NAME" -b "$STREAM"
}
acc-branch-delete() {
accurev lock -c "Stream is deprecated, pending admin removal" "$@"
}
acc-branch-list() {
accurev show -s `accurev info | grep Basis: | awk '{ print $2 }'` -R streams
}
# Branch a stream, or delete a stream
# List branches (substreams):
# acc branch
# Make a branch:
# acc branch ParentStream NewStream
# Delete a branch:
# acc branch -d StreamName
acc-branch() {
if [[ "$1" == "-d" ]]; then
shift
acc-branch-delete "$@"
elif [[ -z "$1" ]]; then
acc-branch-list
else
acc-branch-create "$@"
fi
}
# Merge two streams
# Usage:
# acc stream-merge SourceStream DestinationStream Message
acc-stream-merge() {
local SRC DEST MESSAGE
SRC="$1"
DEST="$2"
MESSAGE="$3"
accurev promote -c "$MESSAGE" -s "$SRC" -S "$DEST" `accurev mergelist -s "$SRC" -S "$DEST" -fl`
}
# Plumbing, autologin before running command once an hour
acc-ensure-login() {
local NOW
NOW=`date +%s`
if [[ -z $ACCUREV_LOGGED_IN ]] || [[ $(($NOW - $ACCUREV_LOGGED_IN)) -gt 3600 ]]; then
accurev secinfo > /dev/null # need two runs for accuracy
if accurev secinfo | grep -q notauth; then
accurev login && ACCUREV_LOGGED_IN=$NOW
else
ACCUREV_LOGGED_IN=$NOW
fi
fi
}
# Entry point for all accurev commands.
# Calls acc-subcommand function if defined, or
# falls back to the 'accurev' command.
acc() {
local SUBCOMMAND CMD
acc-ensure-login
SUBCOMMAND=$1
CMD=acc-$SUBCOMMAND
shift
if type -t $CMD | grep -q function; then
$CMD "$@"
else
accurev $SUBCOMMAND "$@"
fi
}