Update of /cvsroot/cvsshell/cvsshell/src
In directory usw-pr-cvs1:/tmp/cvs-serv13101/src
Modified Files:
basic_cmds.py cvs_cmds.py utils.py
Log Message:
implemented scan-command
Index: basic_cmds.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/basic_cmds.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** basic_cmds.py 27 May 2002 07:32:29 -0000 1.19
--- basic_cmds.py 26 Jul 2002 16:35:37 -0000 1.20
***************
*** 21,24 ****
--- 21,25 ----
import os, string, re
+ from cvs_shell import Listing, Entry
######################################
***************
*** 104,105 ****
--- 105,127 ----
in the local listing."""
app.autoRefresh = app.toggle(app.autoRefresh, args)
+
+ def scan(app, name, args):
+ """Scans the local filesystem starting at the given directory and creates a listing.
+ The server is not contacted, so the status of all files will be `unknown'."""
+ def visit(entries, dirname, names):
+ if dirname.find('CVS') >= 0: return
+ for name in names:
+ if name.find('CVS') < 0:
+ entries.append(Entry(dirname, name, Entry.S_UNKNOWN))
+ dir = '.'
+ entries = []
+ if args != '': dir = args
+ try:
+ os.path.walk(dir, visit, entries)
+ except OSError, msg:
+ app.printErr(msg)
+ app.setListing(Listing(app, dir, entries))
+ app.setDirtyListing(0)
+ app.getListing().sortEntries()
+ app.printListing()
+
Index: cvs_cmds.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/cvs_cmds.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** cvs_cmds.py 26 Jul 2002 15:44:25 -0000 1.10
--- cvs_cmds.py 26 Jul 2002 16:35:37 -0000 1.11
***************
*** 46,49 ****
--- 46,52 ----
app.printErr(msg)
return
+ rootDir = utils.getAbsDir(rest)
+ if rootDir is None:
+ return
try:
lines = app.runCvsCmd('status', globOpts=globOpts, args=opts+' '+rest, getStderr=1)
***************
*** 71,75 ****
dir = dirRes.group('dir')
if dir == '.': dir = ''
! app.setListing(Listing(app, os.getcwd(), entries))
app.setDirtyListing(0)
app.getListing().sortEntries()
--- 74,78 ----
dir = dirRes.group('dir')
if dir == '.': dir = ''
! app.setListing(Listing(app, rootDir, entries))
app.setDirtyListing(0)
app.getListing().sortEntries()
***************
*** 93,96 ****
--- 96,102 ----
return
if simulate: globOpts += '-n'
+ rootDir = utils.getAbsDir(rest)
+ if rootDir is None:
+ return
try:
lines = app.runCvsCmd('update', globOpts=globOpts, args=opts+' '+rest)
***************
*** 104,108 ****
dir = os.path.dirname(x[1])
entries.append(Entry(dir, name, status))
! app.setListing(Listing(app, os.getcwd(), entries))
app.setDirtyListing(0)
app.getListing().sortEntries()
--- 110,114 ----
dir = os.path.dirname(x[1])
entries.append(Entry(dir, name, status))
! app.setListing(Listing(app, rootDir, entries))
app.setDirtyListing(0)
app.getListing().sortEntries()
Index: utils.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/utils.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** utils.py 27 May 2002 07:32:29 -0000 1.10
--- utils.py 26 Jul 2002 16:35:37 -0000 1.11
***************
*** 23,28 ****
from app import AppError
- ParseError = 'ParseError'
###########################
--- 23,46 ----
from app import AppError
+ def getAbsDir(str):
+ """Returns the absolute directory str denotes. If str does not denote a directory, None is returned.
+ """
+ import os
+ try:
+ if str == '': return os.getcwd()
+ str = os.path.expandvars(str)
+ str = os.path.expanduser(str)
+ if not os.path.exists(str):
+ return None
+ if not os.path.isabs(str):
+ str = os.path.join(os.getcwd(), str)
+ return os.path.dirname(str)
+ except OSError, msg:
+ print msg
+ return None
+
+
+ ParseError = 'ParseError'
###########################
|