Update of /cvsroot/cvsshell/cvsshell/src
In directory sc8-pr-cvs1:/tmp/cvs-serv10619/src
Modified Files:
cvs_cmds.py utils.py
Log Message:
implemented log command
Index: cvs_cmds.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/cvs_cmds.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -C2 -d -r1.23 -r1.24
*** cvs_cmds.py 21 Apr 2003 08:02:26 -0000 1.23
--- cvs_cmds.py 21 Apr 2003 20:08:51 -0000 1.24
***************
*** 788,792 ****
app.printErr(msg)
return
- print opts, rest
try:
filenames = ' '.join(app.applyOnEntryList(rest, lambda e, fname: fname))
--- 788,791 ----
***************
*** 799,802 ****
--- 798,823 ----
try:
app.more(app.runCvsCmd('diff', globOpts=globOpts, args=args))
+ except CvsError:
+ return
+
+ def log(app, name, args):
+ try:
+ (globOpts, opts,
+ myOpts, rest) = app.parseArgs(args,
+ app.getCmdToAllowedOpts().get(name, ''))
+ except getopt.GetoptError, msg:
+ app.printErr(msg)
+ return
+ opts = utils.mergeOptionAndArg(opts, 'rw')
+ try:
+ filenames = ' '.join(app.applyOnEntryList(rest, lambda e, fname: fname))
+ except utils.ParseError: # args do not spefiy ids in the current listing
+ filenames = rest
+ except AppError, msg:
+ app.printErr(msg)
+ return
+ args = opts + ' ' + filenames
+ try:
+ app.more(app.runCvsCmd('log', globOpts=globOpts, args=args))
except CvsError:
return
Index: utils.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/utils.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -d -r1.16 -r1.17
*** utils.py 15 Apr 2003 13:40:10 -0000 1.16
--- utils.py 21 Apr 2003 20:08:52 -0000 1.17
***************
*** 184,188 ****
notEnclosed.append(current)
return (notEnclosed, enclosed)
!
##############################
--- 184,227 ----
notEnclosed.append(current)
return (notEnclosed, enclosed)
!
!
! def mergeOptionAndArg(opts, optsToMerge):
! """
!
! Some CVS options require the name of the option and the argument
! not to be separated by whitespace. This function takes an option
! string ('opts') and a string containing the names of the options
! ('optsToMerge') which should not be separated from their
! arguments. It returns the option string with whitespaces deleted
! between the options specified and their arguments.
!
! Example:
!
! mergeOptionAndArg('-r 1.2 -f xxx.py -D 2003-04-02', 'rD')
! =>
! '-r1.2 -f xxx.py -D2003-04-02'
!
! """
! res = ''
! i = 0
! l = opts.split()
! n = len(l)
! while 1:
! if i == n: break
! o = l[i]
! if len(o) == 2 and o[0] == '-' and optsToMerge.find(o[1]) >= 0:
! res += o
! i += 1
! if i < n and not l[i].startswith('-'):
! res += l[i]
! else:
! i -= 1
! else:
! res += o
! res += ' '
! i += 1
! return res.strip()
!
!
##############################
***************
*** 261,263 ****
--- 300,322 ----
self.assertEqual(split('\`foo\` `bar \`foo\`` steven', '`'),
(['`foo` ', None, ' steven'], ['bar `foo`']))
+
+
+ class MergeOptionAndArgTestCase(unittest.TestCase):
+ def setUp(self):
+ self.opts = '-r 1.2 -f xxx.py -D 2003-04-02'
+ def tearDown(self):
+ pass
+ def testEmpty(self):
+ self.assertEqual(mergeOptionAndArg('', ''), '')
+ self.assertEqual(mergeOptionAndArg('', string.lowercase), '')
+ self.assertEqual(mergeOptionAndArg(self.opts, ''), self.opts)
+ def testNoMatch(self):
+ self.assertEqual(mergeOptionAndArg(self.opts, 'abcXZk'), self.opts)
+ def testMatch(self):
+ self.assertEqual(mergeOptionAndArg(self.opts, 'rD'), '-r1.2 -f xxx.py -D2003-04-02')
+ def testNoArg(self):
+ s = '-r -D 2003-04-02'
+ self.assertEqual(mergeOptionAndArg(s, 'rD'), '-r -D2003-04-02')
+
+
unittest.main()
|