[Cvsshell-devel] CVS: cvsshell/src cvs_cmds.py,1.1,1.2 cvs_shell.py,1.13,1.14 utils.py,1.8,1.9
Status: Beta
Brought to you by:
stefanheimann
|
From: Stefan H. <ste...@us...> - 2002-03-11 12:02:17
|
Update of /cvsroot/cvsshell/cvsshell/src
In directory usw-pr-cvs1:/tmp/cvs-serv29583/src
Modified Files:
cvs_cmds.py cvs_shell.py utils.py
Log Message:
* added support for filtering the file-listing
* add now ask if the files should be added.
Index: cvs_cmds.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/cvs_cmds.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** cvs_cmds.py 11 Mar 2002 09:45:51 -0000 1.1
--- cvs_cmds.py 11 Mar 2002 12:02:13 -0000 1.2
***************
*** 74,78 ****
try:
(globOpts, opts,
! myOpts, rest) = app.parseArgs(args, app.getCmdToAllowedOpts().get(name, ''))
except getopt.GetoptError, msg:
app.printErr(msg)
--- 74,79 ----
try:
(globOpts, opts,
! myOpts, rest) = app.parseArgs(args,
! app.getCmdToAllowedOpts().get(name, ''))
except getopt.GetoptError, msg:
app.printErr(msg)
***************
*** 103,107 ****
try:
(globOpts, opts,
! myOpts, rest) = app.parseArgs(args, app.getCmdToAllowedOpts().get(name, ''))
except getopt.GetoptError, msg:
app.printErr(msg)
--- 104,109 ----
try:
(globOpts, opts,
! myOpts, rest) = app.parseArgs(args,
! app.getCmdToAllowedOpts().get(name, ''))
except getopt.GetoptError, msg:
app.printErr(msg)
***************
*** 137,141 ****
try:
(globOpts, opts,
! myOpts, rest) = app.parseArgs(args, app.getCmdToAllowedOpts().get(name, ''))
except getopt.GetoptError, msg:
app.printErr(msg)
--- 139,144 ----
try:
(globOpts, opts,
! myOpts, rest) = app.parseArgs(args,
! app.getCmdToAllowedOpts().get(name, ''))
except getopt.GetoptError, msg:
app.printErr(msg)
***************
*** 147,167 ****
def __doIt(e, filename):
e.status = Entry.S_ADDED
! return filename
try:
! filenames = app.applyOnEntryList(rest, __doIt)
try:
if filenames:
app.runCvsCmd('add', rootDir=app.getListing().getRootDir(),
! globOpts=globOpts, args=opts+' '+string.join(filenames))
! except CvsError: pass
except utils.ParseError: # args do not spefiy ids in the current listing
try:
app.runCvsCmd('add', globOpts=globOpts,
! args=opts+' '+rest)
app.setDirtyListing(1)
! except CvsError: pass
except AppError, msg:
app.printErr(msg)
!
def addBinary(app, name, args):
--- 150,191 ----
def __doIt(e, filename):
e.status = Entry.S_ADDED
! return (e, filename)
! filenames = ''
! toAddListing = Listing(app, '')
try:
! l = app.applyOnEntryList(rest, __doIt)
! entries = []
! for x in l:
! e,name = x
! filenames += name + ' '
! entries.append(e)
! toAddListing.setEntries(entries)
! toAddListing.setRootDir(app.getListing().getRootDir())
try:
if filenames:
app.runCvsCmd('add', rootDir=app.getListing().getRootDir(),
! globOpts=globOpts,
! args=opts+' '+filenames)
! toAddListing.printEntries()
! except CvsError: return
except utils.ParseError: # args do not spefiy ids in the current listing
+ filenames = rest
try:
app.runCvsCmd('add', globOpts=globOpts,
! args=opts+' '+filenames)
app.setDirtyListing(1)
! except CvsError: return
except AppError, msg:
app.printErr(msg)
! return
! #
! answ = app.prompt("\nThe files have been scheduled for addition.\n" \
! "Should I run `commit' to add the files " \
! "to the repository (yes|no)? ")
! if answ == 'yes':
! for e in toAddListing.entries:
! e.status = Entry.S_OK
! app.runCvsCmd('commit', rootDir=toAddListing.getRootDir(),
! fork=0, args=filenames)
def addBinary(app, name, args):
***************
*** 173,177 ****
try:
(globOpts, opts,
! myOpts, rest) = app.parseArgs(args, app.getCmdToAllowedOpts().get(name, ''))
except getopt.GetoptError, msg:
app.printErr(msg)
--- 197,202 ----
try:
(globOpts, opts,
! myOpts, rest) = app.parseArgs(args,
! app.getCmdToAllowedOpts().get(name, ''))
except getopt.GetoptError, msg:
app.printErr(msg)
***************
*** 199,203 ****
if filenames:
app.runCvsCmd('commit', rootDir=app.getListing().getRootDir(),
! globOpts=globOpts, args=opts+' '+string.join(filenames), fork=0)
except CvsError: pass
except utils.ParseError: # args do not spefiy ids in the current listing
--- 224,229 ----
if filenames:
app.runCvsCmd('commit', rootDir=app.getListing().getRootDir(),
! globOpts=globOpts,
! args=opts+' '+string.join(filenames), fork=0)
except CvsError: pass
except utils.ParseError: # args do not spefiy ids in the current listing
***************
*** 214,218 ****
try:
(globOpts, opts,
! myOpts, rest) = app.parseArgs(args, app.getCmdToAllowedOpts().get(name, ''))
except getopt.GetoptError, msg:
app.printErr(msg)
--- 240,245 ----
try:
(globOpts, opts,
! myOpts, rest) = app.parseArgs(args,
! app.getCmdToAllowedOpts().get(name, ''))
except getopt.GetoptError, msg:
app.printErr(msg)
Index: cvs_shell.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/cvs_shell.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** cvs_shell.py 11 Mar 2002 10:09:50 -0000 1.13
--- cvs_shell.py 11 Mar 2002 12:02:13 -0000 1.14
***************
*** 20,24 ****
###############################################################################
! import os, sys, re, string, types, getopt, utils
from oo_tools import GetSetProvider
from app import AppError
--- 20,24 ----
###############################################################################
! import os, sys, re, string, types, getopt, fnmatch, utils
from oo_tools import GetSetProvider
from app import AppError
***************
*** 80,85 ****
self.readCommandFile()
self.readConfigFile()
!
def readCvsRootFromFile(self):
s = None
--- 80,86 ----
self.readCommandFile()
self.readConfigFile()
! self.listingFilter = utils.splitquoted(self.configMap.get('filter',''))
+
def readCvsRootFromFile(self):
s = None
***************
*** 176,180 ****
except (IOError,OSError), msg:
self.printMsg(s, nonl=1)
! self.printErr("Error invoking pager `%s': %s" % (pager,str(msg)))
--- 177,182 ----
except (IOError,OSError), msg:
self.printMsg(s, nonl=1)
! self.printErr("Error invoking pager `%s': %s" %
! (pager,str(msg)))
***************
*** 325,330 ****
self.app = app
self.rootDir = rootDir
- self.entries = entries
self.sortOrder = ['dir', 'status', 'name']
def sortEntries(self):
--- 327,344 ----
self.app = app
self.rootDir = rootDir
self.sortOrder = ['dir', 'status', 'name']
+ filter = app.getListingFilter()
+ if not filter:
+ self.entries = entries
+ else:
+ self.entries = []
+ for e in entries:
+ dontInclude = 0
+ for f in filter:
+ if fnmatch.fnmatch(e.getName(), f):
+ dontInclude = 1
+ break
+ if not dontInclude:
+ self.entries.append(e)
def sortEntries(self):
Index: utils.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/utils.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** utils.py 10 Mar 2002 23:13:59 -0000 1.8
--- utils.py 11 Mar 2002 12:02:14 -0000 1.9
***************
*** 65,80 ****
! def splitquoted(str):
"""Splits str on whitespace except when a quoted string is
encountered.
# Example: splitquotes('foo "foo \"bar\""') => ['foo','"foo \"bar\""']
"""
- doubleQ = r'"(?:[^"\\]+|\\.)*"'
- singleQ = r"'(?:[^'\\]+|\\.)*'"
- splitRE = re.compile(r'(%s|%s|\S+)' % (doubleQ, singleQ))
res = []
for x in splitRE.split(str):
x = x.strip()
! if x: res.append(x) # not only whitespace
return res
--- 65,85 ----
! doubleQ = r'"(?:[^"\\]+|\\.)*"'
! singleQ = r"'(?:[^'\\]+|\\.)*'"
! splitRE = re.compile(r'(%s|%s|\S+)' % (doubleQ, singleQ))
! def splitquoted(str, stripQuotes=0):
"""Splits str on whitespace except when a quoted string is
encountered.
# Example: splitquotes('foo "foo \"bar\""') => ['foo','"foo \"bar\""']
+ If stripQuotes evaluates to true, the quotation marks are removed.
"""
res = []
+ quotes = ['"', "'"]
for x in splitRE.split(str):
x = x.strip()
! if x:
! if stripQuotes and x[0] in quotes and x[len(x)-1] in quotes:
! x = x[1:len(x)-1]
! res.append(x) # not only whitespace
return res
|