[Cvsshell-devel] CVS: cvsshell/src cvs_cmds.py,1.17,1.18 cvs_shell.py,1.35,1.36 entry_parser.py,1.1,
Status: Beta
Brought to you by:
stefanheimann
|
From: Stefan H. <ste...@us...> - 2002-11-29 18:35:29
|
Update of /cvsroot/cvsshell/cvsshell/src
In directory sc8-pr-cvs1:/tmp/cvs-serv18087
Modified Files:
cvs_cmds.py cvs_shell.py entry_parser.py utils.py
Log Message:
added support for filtering files listed in .cvsignore, $CVSIGNORE and
~/.cvsignore
Index: cvs_cmds.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/cvs_cmds.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** cvs_cmds.py 16 Sep 2002 06:49:32 -0000 1.17
--- cvs_cmds.py 29 Nov 2002 18:35:26 -0000 1.18
***************
*** 104,111 ****
This command donwloads new files and changes to already
checked out files from the server. It also brings the
! listing in sync with the repository.
!
! The listing can be filtered by setting the variable
! filter' in the CONFIG section of ~/.cvsshellrc."""
try:
(globOpts, opts,
--- 104,108 ----
This command donwloads new files and changes to already
checked out files from the server. It also brings the
! listing in sync with the repository."""
try:
(globOpts, opts,
***************
*** 492,496 ****
The listing can be filtered by setting the variable
! `filter' in the CONFIG section of ~/.cvsshellrc."""
app.printListing()
--- 489,497 ----
The listing can be filtered by setting the variable
! `filter' in the CONFIG section of ~/.cvsshellrc. If the listing
! was produced by a cvs command like ``update'', the CVS filtering rules
! apply. If the listing was produced by a non-CVS command (for example
! with the builtin ``refresh'' command), only the filters in $CVSIGNORE,
! ~/.cvsignore and ./.cvsignore are considered."""
app.printListing()
Index: cvs_shell.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/cvs_shell.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** cvs_shell.py 18 Sep 2002 19:07:56 -0000 1.35
--- cvs_shell.py 29 Nov 2002 18:35:26 -0000 1.36
***************
*** 28,32 ****
from plugable_app import PlugableApp
! VERSION = '0.3.1'
NAME ='CvsShell'
COPYRIGHT = 'Copyright 2002 Stefan Heimann (ma...@st...).\n' \
--- 28,32 ----
from plugable_app import PlugableApp
! VERSION = '0.4'
NAME ='CvsShell'
COPYRIGHT = 'Copyright 2002 Stefan Heimann (ma...@st...).\n' \
***************
*** 86,90 ****
self.readCommandFile()
self.readConfigFile()
! self.listingFilter = utils.splitquoted(self.configMap.get('filter',''))
self.enableColor = self.configMap.get('colors', 'off') == 'on' and not self.onWindows
self.batchMode = 0
--- 86,95 ----
self.readCommandFile()
self.readConfigFile()
! filter = utils.getCvsIgnoreFilter(self.getenv('HOME'))
! filter.addPatterns(utils.splitquoted(self.configMap.get('filter','')))
! cvsignore = self.getenv("CVSIGNORE")
! if cvsignore:
! filter.addPatterns(utils.splitquoted(cvsignore))
! self.listingFilter = filter
self.enableColor = self.configMap.get('colors', 'off') == 'on' and not self.onWindows
self.batchMode = 0
***************
*** 187,191 ****
# command may change the status
self.setDirtyListing(1)
! # pare args as the could specify ids in the listing
doIt = lambda e, filename: filename
try:
--- 192,196 ----
# command may change the status
self.setDirtyListing(1)
! # parse args as they could specify ids in the listing
doIt = lambda e, filename: filename
try:
***************
*** 241,245 ****
open(tmp,'w').write(s)
self.shell(pager + ' ' + tmp)
! except (ShellException,IOError,OSError), msg:
self.printMsg(s, nonl=1)
self.printErr("Error invoking pager `%s': %s" %
--- 246,252 ----
open(tmp,'w').write(s)
self.shell(pager + ' ' + tmp)
! except ShellException:
! pass # don't care about a non-zero exit code of the pager
! except (IOError,OSError), msg:
self.printMsg(s, nonl=1)
self.printErr("Error invoking pager `%s': %s" %
***************
*** 285,289 ****
lines = f.readlines()
except KeyboardInterrupt:
! return []
if f.close() is not None: # cvs command caused an error
raise CvsError
--- 292,296 ----
lines = f.readlines()
except KeyboardInterrupt:
! raise CvsError
if f.close() is not None: # cvs command caused an error
raise CvsError
***************
*** 341,345 ****
"Run `update', `refresh' or `status'.")
!
def parseArgs(self, args, cvsCmdOpts='', cmdOpts=''):
"""Parse args and separates it like that:
--- 348,352 ----
"Run `update', `refresh' or `status'.")
!
def parseArgs(self, args, cvsCmdOpts='', cmdOpts=''):
"""Parse args and separates it like that:
***************
*** 401,417 ****
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):
--- 408,432 ----
self.rootDir = rootDir
self.sortOrder = ['dir', 'status', 'name']
+ # global filter
filter = app.getListingFilter()
if not filter:
! tmpEntries = entries
else:
! tmpEntries = []
for e in entries:
! if not filter.filter(e.name):
! tmpEntries.append(e)
! # .cvsignore filter
! filters = {}
! self.entries = []
! for e in tmpEntries:
! if filters.has_key(e.dir):
! filter = filters[e.dir]
! else:
! filter = utils.getCvsIgnoreFilter(e.dir)
! filters[e.dir] = filter
! if not filter.filter(e.name):
! self.entries.append(e)
!
def sortEntries(self):
Index: entry_parser.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/entry_parser.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** entry_parser.py 27 Jul 2002 15:34:12 -0000 1.1
--- entry_parser.py 29 Nov 2002 18:35:26 -0000 1.2
***************
*** 8,11 ****
--- 8,12 ----
def parse(filename):
+ """Parses and CVS/Entries file."""
dir = dirname(dirname(filename))
f = open(filename)
Index: utils.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/utils.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** utils.py 15 Sep 2002 21:33:39 -0000 1.14
--- utils.py 29 Nov 2002 18:35:26 -0000 1.15
***************
*** 20,24 ****
###############################################################################
! import sys, re, os, stat
from app import AppError
--- 20,24 ----
###############################################################################
! import sys, re, os, stat, fnmatch, string
from app import AppError
***************
*** 180,185 ****
!
##############################
# Tests
--- 180,215 ----
+ class Filter:
+ """This class represents a filter based on filename patterns.
+ The list with patterns is given in the constructor"""
! def __init__(self, patterns):
! self.patterns = patterns
!
! def filter(self, name):
! for p in self.patterns:
! if fnmatch.fnmatch(name, p):
! return 1
! return 0
!
! def addPattern(self, p):
! self.patterns.append(p)
!
! def addPatterns(self, ps):
! self.patterns += ps
!
! def getCvsIgnoreFilter(dirname):
! """Returns a filter that contains the patterns in the .cvsignore file of
! the given directory."""
! cvsignore = os.path.join(dirname, '.cvsignore')
! if os.path.exists(cvsignore):
! f = open(cvsignore)
! filter = Filter(map(string.strip, f.readlines()))
! f.close()
! else:
! filter = Filter([])
! return filter
!
!
##############################
# Tests
|