File: cvslb

package info (click to toggle)
ldapjdk 5.3.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 9,756 kB
  • sloc: ansic: 44,727; java: 39,706; xml: 7,623; sh: 4,497; perl: 3,774; makefile: 1,680; cpp: 979
file content (220 lines) | stat: -rwxr-xr-x 6,322 bytes parent folder | download
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/bin/sh
# uncomment the following line on NT (change the path as needed) and move
# it to the first line of this file.
#!c:/appls/mksnt/mksnt/sh

#
# ***** BEGIN LICENSE BLOCK *****
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
# 
# The contents of this file are subject to the Mozilla Public License Version 
# 1.1 (the "License"); you may not use this file except in compliance with 
# the License. You may obtain a copy of the License at 
# http://www.mozilla.org/MPL/
# 
# Software distributed under the License is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
# for the specific language governing rights and limitations under the
# License.
# 
# The Original Code is mozilla.org code.
# 
# The Initial Developer of the Original Code is
# Netscape Communications Corporation.
# Portions created by the Initial Developer are Copyright (C) 1996-2003
# the Initial Developer. All Rights Reserved.
# 
# Contributor(s):
#   Mark Smith <MarkCSmithWork@aol.com>
# 
# Alternatively, the contents of this file may be used under the terms of
# either of the GNU General Public License Version 2 or later (the "GPL"),
# or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
# in which case the provisions of the GPL or the LGPL are applicable instead
# of those above. If you wish to allow use of your version of this file only
# under the terms of either the GPL or the LGPL, and not to allow others to
# use your version of this file under the terms of the MPL, indicate your
# decision by deleting the provisions above and replace them with the notice
# and other provisions required by the GPL or the LGPL. If you do not delete
# the provisions above, a recipient may use your version of this file under
# the terms of any one of the MPL, the GPL or the LGPL.
# 
# ***** END LICENSE BLOCK ***** 

#
# cvslb:  'cvs log' filtered to only show revisions on the current branch
#
# usage: cvslb [-l count] [-b branch] [files...]
#   where count is the maximum number of revisions to display.
#   and branch specifies a branch to focus on (instead of the current one).
#      (use -b TRUNK to see changes made on the trunk).
# options can also be passed in the CVSLBOPTIONS environment variable.
#

PROG=$(basename "$0")
USAGE="$0 [-v] [ -l count ] [ -b branch ] [ file... ]"
SEP="=============================================================================="
REVLIMIT=0
BRANCH=""
VERBOSE=0


# process arguments
set -- "$(getopt vb:l: "$CVSLBOPTIONS" "$*")"
if [ $? != 0 ]; then
   echo "$USAGE"
   exit 2
fi

for i in "$@"; do
    case $i in
       -l) REVLIMIT=$2; shift 2;;
       -b) BRANCH=$2; shift 2;;
       -v) VERBOSE=$(expr "$VERBOSE" + 1); shift;;
       --) shift; break;;
   esac
done

if [ $# -eq 0 ]; then
    # Requires array support to fix this issue, not provided by this shell
    # shellcheck disable=SC2125
    FILES=*
else
    FILES=$*
fi

for FN in $FILES; do
    if [ -d "$FN" ]; then
    echo "$PROG: Skipping directory $FN..."
    else
    if [ -z "$BRANCH" ]; then
        LINE=$(cvs -n stat "$FN" | grep 'Sticky Tag:')
        RC=$?
        if [ $RC != 0 ]; then
        echo "$PROG: skipping $FN (cvs stat failed or no sticky tag)..."
        continue
        fi

        CURTAG=$(echo "$LINE" | awk '{print $3}')
        if [ "$CURTAG" = "(none)" ]; then
            CURTAG="";
        fi
    else
        if [ "$BRANCH" = "TRUNK" ]; then
        CURTAG=""
        else
        CURTAG=$BRANCH
        fi
    fi

    if [ -z "$CURTAG" ]; then
        DISPLAY_CURTAG="the trunk";
    else
        DISPLAY_CURTAG="$CURTAG";
    fi

    if [ "$VERBOSE" -gt 0 ]; then
        echo "$FN": current revision: "$DISPLAY_CURTAG"
    fi

    cvs -n log "$FN" | awk '
    BEGIN           {
        echoing = 1;
        no_more = 0;
    }
    /^symbolic names:/  {
        looking_for_branch = 1;
        echoing = 0;
        next;
    }
    /^description:/ {
        print;
        echoing = 1;
        if ( revlimit > 0 ) {
        printf( "Displaying at most %d revisions from %s:\n", \
            revlimit, display_curtag );
        } else {
        printf( "Displaying all revisions from %s:\n", display_curtag );
        }
        next;
    }
    /^========================================================/ {
        next;
    }
    /^total revisions:/ {
        if ( looking_for_branch ) {
        if ( curtag == "" ) {
            looking_for_branch = 0;
        } else {
            printf( "This file not on branch %s (?)\n", display_curtag );
            exit;
        }
        }
    }
    /^revision [0-9]*\.[0-9]*$/ {
        found_rev = 0;
        if ( !no_more && !looking_for_branch && curtag == "" ) {
        if ( revlimit > 0 && --revlimit <= 0 ) {
            no_more = 1;
        }
        print;
        echoing = 1;
        } else {
        echoing = 0;
        }
        next;
    }
    /^revision [0-9]/   {
        found_rev = 0;
        if ( !no_more && !looking_for_branch ) {
         if ( length( $2 ) > numerictaglen &&       \
            substr( $2, 1, numerictaglen ) == numerictag && \
            index( substr( $2, numerictaglen + 1 ), "." ) == 0 ) {
            found_rev = 1;
        }
        }
        if ( found_rev ) {
        if ( revlimit > 0 && --revlimit <= 0 ) {
            no_more = 1;
        }
        print;
        echoing = 1;
        } else {
        echoing = 0;
        }
        next;
    }
    /   .*: [0-9]/  {
        tag = substr( $1, 1, length( $1 ) - 1 );
        if ( looking_for_branch && tag == curtag ) {
        print;
        count = split($2,digits,".");
        numerictag="";
        zero_suppressed = 0;
        for ( i = 1; i <= count; ++i ) {
            if ( !zero_suppressed && digits[i] == "0" ) {
            zero_suppressed = 1;
            } else {
            numerictag = numerictag digits[i] ".";
            }
        }
        numerictaglen = length( numerictag );
        looking_for_branch = 0;
#       printf( "got branch: %s ($2 was %s)\n", numerictag, $2 );
        } else if ( echoing ) {
        print;
        }
        next;
     }
    /.*/            {
        if ( echoing ) {
        print;
        }
        next;
    }
    ' curtag="$CURTAG" display_curtag="$DISPLAY_CURTAG" revlimit="$REVLIMIT"
    echo $SEP
    fi
done

exit 0