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
221
222
223
224
225
226
227
228
229
230
231
232
233
|
@
echo
off
@REM Create tag script
@REM 2013-03-20 DD
@setlocal
@
pushd
%WORK_SPACE%
@goto StartScript
:Usage
@
echo
Usage: %SCRIPT_CMD% -R repository -M cvsHome -S sourceTagType -C createTagType -U userid [-P password] [-F ctlFile] [-L logDir] [-H help]
@
echo
repository - required. The CVS Repository Name.
@
echo
cvsHome - required. The CVS root directory. option
@
echo
SourceTagType - required. option (trunk,
head
,branch,tag).
@
echo
createTagType - required. option (branch,tag).
@
echo
userid - required. The CVS user
id
who
can connect CVS server.
@
echo
password - optional. The CVS user password.
@
echo
ctlFile - optional. The script control
file
, default is (.ctl)
in
current directory.
@
echo
logDir - optional. The log
file
directory default is current directory.
@
echo
help - optional. help.
@goto :eof
:errRepository
@call :Usage
@
echo
ERROR: CVS repository name is empty.
@goto :eof
:errCheckReposit
@call :Usage
@
echo
ERROR: CVS repository (%Repository%) does not exist.
@goto :eof
:errHome
@call :Usage
@
echo
ERROR: CVS home is empty.
@goto :eof
:errCheckHome
@call :Usage
@
echo
ERROR: CVS home (%cvsHome%) does not exist.
@goto :eof
:errCheckType
@call :Usage
@
echo
ERROR: The tag
type
with trunk,branch,tag.
@goto :eof
:errCheckType
@call :Usage
@
echo
ERROR: The tag
type
with trunk,branch,tag.
@goto :eof
:errSourceType
@call :Usage
@
echo
ERROR: Source tag Type is empty
@goto :eof
:errCreateType
@call :Usage
@
echo
ERROR:Create tag Type is empty.
@goto :eof
:errUser
@call :Usage
@
echo
ERROR:CVS user
id
is empty.
@goto :eof
:errCtlFileMissing
@call :Usage
@
echo
ERROR: There is no control
file
(.ctl)
in
current directory.
@goto :eof
:errCtlFileTooMany
@call :Usage
@
echo
ERROR: There are
more
than one control files (.ctl)
in
current directory.
@goto :eof
:errCtlFileNotFound
@call :Usage
@
echo
ERROR: Control
file
(%ctlFile%) not found.
@goto :eof
:errLogDir
@call :Usage
@
echo
ERROR: Log directory (%logDir%) does not exist.
@goto :eof
:errLogin
@
echo
ERROR:connect to CVS (%Repository%\%cvsHome%) failed.
@
echo
Please check your usrname and password.
@goto :eof
:errCreateTag
@
echo
ERROR: created tag (%err_tag%) failed.
@goto :eof
:StartScript
@
set
SCRIPT_CMD=%0
@
set
Repository=
@
set
cvsHome=
@
set
SourceType=
@
set
CreateType=
@
set
cvsUser=
@
set
cvsPwd=
@
set
ctlFile=
@
set
logDir=
:NextParam
@
if
/I
"A%1"
==
"A"
goto CheckParam
@
if
/I
"%1"
==
"-R"
goto setRepositoy
@
if
/I
"%1"
==
"-M"
goto setCvsHome
@
if
/I
"%1"
==
"-S"
goto setSourceType
@
if
/I
"%1"
==
"-C"
goto setCreateType
@
if
/I
"%1"
==
"-U"
goto setUser
@
if
/I
"%1"
==
"-P"
goto setPwd
@
if
/I
"%1"
==
"-F"
goto setCtlfile
@
if
/I
"%1"
==
"-L"
goto setLogDir
@
if
/I
"%1"
==
"-H"
goto Usage
@
if
/I
"%1"
==
"?"
goto Usage
@
shift
@goto NextParam
:setRepositoy
@
set
Repository=%2
@
shift
@
shift
@goto NextParam
:setCvsHome
@
set
cvsHome=%2
@
shift
@
shift
@goto NextParam
:setSourceType
@
set
SourceType=%2
@
shift
@
shift
@goto NextParam
:setCreateType
@
set
CreateType=%2
@
shift
@
shift
@goto NextParam
:setUser
@
set
cvsUser=%2
@
shift
@
shift
@goto NextParam
:setPwd
@
set
cvsPwd=%2
@
shift
@
shift
@goto NextParam
:setCtlfile
@
set
ctlFile=%2
@
shift
@
shift
@goto NextParam
:setLogDir
@
set
logDir=%2
@
shift
@
shift
@goto NextParam
:CheckParam
@
if
/I
"A%Repository%"
==
"A"
goto errRepository
@
if
/I
"%Repository%"
NEQ
"REP1"
if
/I
"%Repository%"
NEQ
"REP2"
if
/I
"%Repository%"
NEQ
"REP3"
if
/I
"%Repository%"
NEQ
"REP4"
if
/I
"%Repository%"
NEQ
"REP5"
goto errCheckReposit
@
if
/I
"A%cvsHome%"
==
"A"
goto errHome
@
if
/I
"%cvsHome%"
NEQ
"FSCS3.0"
if
/I
"%cvsHome%"
NEQ
"REP1.0"
if
/I
"%cvsHome%"
NEQ
"REP2.0"
if
/I
"%cvsHome%"
NEQ
"REP3.0"
if
/I
"%cvsHome%"
NEQ
"REP4.0"
goto errCheckHome
@
if
/I
"A%SourceType%"
==
"A"
goto errSourceType
@
if
/I
"%SourceType%"
NEQ
"TRUNK"
if
/I
"%SourceType%"
NEQ
"HEAD"
if
/I
"%SourceType%"
NEQ
"TAG"
if
/I
"%SourceType%"
NEQ
"BRANCH"
goto errCheckType
@
if
/I
"A%CreateType%"
==
"A"
goto errCreateType
@
if
/I
"%CreateType%"
NEQ
"TAG"
if
/I
"%CreateType%"
NEQ
"BRANCH"
goto errCheckType
@
if
/I
"A%cvsUser%"
==
"A"
goto errUser
@
if
/I
"A%ctlFile%"
==
"A"
goto cont1
:cont1
@REM
find
.ctl
file
in
current directory
@
if
not
"A%ctlFile%"
==
"A"
goto cont_1
@
set
/A
ASN=0
@
for
%%i
in
(*.ctl)
do
set
/A
ASN+=1
@
if
%ASN% == 0 goto errCtlFileMissing
@
if
not %ASN% == 1 goto errCtlFileTooMany
@
for
%%i
in
(*.ctl)
do
set
ctlFile=%%i
:cont_1
@REM script root directory is the control
file
directory full path ending with \
@
for
/F
"tokens=*"
%%i
in
(
"%ctlFile%"
)
do
set
scriptRootDir=%%~dpi
@
for
/F
"tokens=*"
%%i
in
(
"%ctlFile%"
)
do
set
controlFileName=%%~nxi
@
set
ctlFile=%scriptRootDir%%controlFileName%
@
if
not exist
"%ctlFile%"
goto errCtlFileNotFound
:cont2
@
if
not
"A%logDir%"
==
"A"
goto cont2_1
@
if
"A%logDir%"
==
"A"
set
logDir=.
@
if
not exist %logDir%\logs
mkdir
%logDir%\logs
@
set
logDir=%logDir%\logs
:cont2_1
@
if
not exist %logDir% goto errLogDir
@
for
/F
"usebackq tokens=1,2,3 delims=- "
%%i
in
(`
date
/T
`)
do
set
TodayDate=%%i%%j%%k
@
for
/F
"usebackq tokens=1,2,3 delims=: "
%%i
in
(`
time
/T
`)
do
set
TodayDate=%TodayDate%-%%i%%j
@
set
logfile=%logDir%\%TodayDate%.log
@
echo
logfile=%logfile% >> %logfile%
:cont3
@
echo
Start script at: %DATE% %TIME% >
"%logfile%"
@
echo
Premium Technology Inc. >>
"%logFile%"
@
echo
CVS Repostory: %Repository% >>
"%logfile%"
@
echo
CVS HOME: %cvsHome% >>
"%logfile%"
@
echo
Create tag user
id
: %cvsUser% >>
"%logfile%"
@
echo
Script control
file
: %ctlFile% >>
"%logfile%"
@
echo
. >>
"%logfile%"
:finshLogin
@rem login CVS server.
@
if
"A%cvsPwd%"
==
"A"
set
/p
cvsPwd=%cvsUser%'s password:
@
set
CVSROOT=:pserver:%cvsUser%:%cvsPwd%@192.168.3.50:/%Repository%
@
echo
connect to cvs(%Repository%) ...
@cvs login >> %logfile%
@
if
not
"%ERRORLEVEL%"
==
"0"
goto errLogin
@
echo
Login cvs %Repository% successfully.
@
echo
New tag name as following: >> %logfile%
@
for
/F
"eol=# tokens=1,2,3* delims= "
%%i
in
(%ctlFile%)
do
echo
%%i %%j >> %logfile%
@
echo
. >>
"%logfile%"
@call :finshTag %SourceType% %CreateType%
@
echo
Created successful >>
"%logfile%"
@
echo
end
time
>>
"%logfile%"
@
echo
at %DATE% %TIME% >>
"%logfile%"
@goto :eof
:finshTag_1
@rem create tags.
@
for
/f
"eol=# tokens=1,2,3 delims= "
%%i
in
(%ctlFile%)
do
(
echo
creating tag [%%j] please wait ...
cvs rtag -r %%i %%j %cvsHome%/%%k
if
"%ERRORLEVEL%"
==
"1"
set
err_tag=%%j
if
"%ERRORLEVEL%"
==
"1"
goto errCreateTag
echo
### New tag [%%j] created. >> "%logfile%"
echo
### New tag [%%j] created.
)
@goto logMessage
:finshBranch_1
@rem create branches.
@
for
/f
"eol=# tokens=1,2,3 delims= "
%%i
in
(%ctlFile%)
do
(
echo
creating branch [%%j] please wait ...
cvs rtag -r %%i -b %%j %cvsHome%/%%k
if
"%ERRORLEVEL%"
==
"1"
set
err_tag=%%j
if
"%ERRORLEVEL%"
==
"1"
goto errCreateTag
echo
### New branch [%%j] created. >> "%logfile%"
echo
### New branch [%%j] created.
)
@goto logMessage
:finshTag
@
if
/I
"%1"
==
"head"
if
/I
"%2"
==
"tag"
goto finshTag_1
@
if
/I
"%1"
==
"branch"
if
/I
"%2"
==
"tag"
goto finshTag_1
@
if
/I
"%1"
==
"tag"
if
/I
"%2"
==
"tag"
goto finshTag_1
@
if
/I
"%1"
==
"head"
if
/I
"%2"
==
"branch"
goto finshBranch_1
@
if
/I
"%1"
==
"branch"
if
/I
"%2"
==
"branch"
goto finshBranch_1
@
if
/I
"%1"
==
"tag"
if
/I
"%2"
==
"branch"
goto finshBranch_1
:logMessage
@
echo
please check log
file
"%logfile%"
@goto :eof
|
用bash 写的CVS版本控制脚本
最新推荐文章于 2024-09-05 22:02:14 发布