[Cvsshell-devel] CVS: cvsshell/src basic_cmds.py,1.8,1.9 cvs_shell.py,1.7,1.8
Status: Beta
Brought to you by:
stefanheimann
|
From: Stefan H. <ste...@us...> - 2002-03-07 15:10:56
|
Update of /cvsroot/cvsshell/cvsshell/src
In directory usw-pr-cvs1:/tmp/cvs-serv1765
Modified Files:
basic_cmds.py cvs_shell.py
Log Message:
* support for adding binary files
* better apearance of prompt
Index: basic_cmds.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/basic_cmds.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** basic_cmds.py 7 Mar 2002 13:08:49 -0000 1.8
--- basic_cmds.py 7 Mar 2002 15:10:51 -0000 1.9
***************
*** 52,56 ****
except KeyError:
app.printErr("Unknown command: %s" % cmd)
-
first_sentence = re.compile(r'[^\n]*')
app.printMsg("The following commands are available:")
--- 52,55 ----
***************
*** 62,66 ****
items = app.cmdToDoc.items()
items.sort(lambda x,y: cmp(x[0], y[0]))
- print items
for x in items:
name = app.cmdToCmds[x[0]]
--- 61,64 ----
***************
*** 171,179 ****
_runCvsCmd(context, 'checkout', args=module)
except CvsError: pass
!
! def add(name, args, context):
app = context['APP']
if not args:
! args = app.prompt('enter filenumbers to add: ')
if args is None: return
def __doIt(e,filename):
--- 169,178 ----
_runCvsCmd(context, 'checkout', args=module)
except CvsError: pass
!
!
! def add(name, args, context, isBinary=0):
app = context['APP']
if not args:
! args = app.prompt('enter filenumber(s) to add: ')
if args is None: return
def __doIt(e,filename):
***************
*** 182,188 ****
(rootDir, filenames) = _applyOnEntryList(args, context, __doIt)
if filenames:
try:
! _runCvsCmd(context, 'add', rootDir=rootDir, args=utils.list2string(filenames))
except CvsError: pass
def commit(name, args, context):
--- 181,195 ----
(rootDir, filenames) = _applyOnEntryList(args, context, __doIt)
if filenames:
+ if isBinary: opts = '-kb'
+ else: opts = ''
try:
! _runCvsCmd(context, 'add', rootDir=rootDir, opts=opts, args=utils.list2string(filenames))
except CvsError: pass
+
+
+ def addBinary(name, args, context):
+ context['APP'].printMsg('The file will be added in binary mode.')
+ add(name, args, context, isBinary=1)
+
def commit(name, args, context):
***************
*** 214,218 ****
app = context['APP']
if args == '':
! args = app.prompt('enter filenumbers to remove: ')
if args is None: return
def __doIt(e,filename):
--- 221,225 ----
app = context['APP']
if args == '':
! args = app.prompt('enter filenumber(s) to remove: ')
if args is None: return
def __doIt(e,filename):
***************
*** 286,302 ****
option to a new value with `on' or `off' as argument."""
app = context['APP']
! if len(args) == 0:
! app.cvsRootAutoUpdate = not app.cvsRootAutoUpdate
! else:
! if args == 'on': app.cvsRootAutoUpdate = 1
! elif args == 'off': app.cvsRootAutoUpdate = 0
! else:
! app.printErr("argument must be `on' or `off'")
! return
if app.cvsRootAutoUpdate:
newRoot = app.readCvsRootFromFile()
if newRoot is not None: app.setCvsRoot(newRoot)
###################################
# Helper functions for CVS commands
--- 293,306 ----
option to a new value with `on' or `off' as argument."""
app = context['APP']
! app.cvsRootAutoUpdate = _toggle(app, app.cvsRootAutoUpdate, args)
if app.cvsRootAutoUpdate:
newRoot = app.readCvsRootFromFile()
if newRoot is not None: app.setCvsRoot(newRoot)
+ def toggleFullPrompt(name, args, context):
+ app = context['APP']
+ app.showFullPrompt = _toggle(app, app.showFullPrompt, args)
+
###################################
# Helper functions for CVS commands
***************
*** 489,492 ****
--- 493,505 ----
return defGlobOpts,defOpts
+ def _toggle(app, oldVal, args):
+ if len(args) == 0:
+ return not oldVal
+ else:
+ if args == 'on': return 1
+ elif args == 'off': return 0
+ else:
+ app.printErr("argument must be `on' or `off'")
+ return oldVal
Index: cvs_shell.py
===================================================================
RCS file: /cvsroot/cvsshell/cvsshell/src/cvs_shell.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** cvs_shell.py 7 Mar 2002 13:08:49 -0000 1.7
--- cvs_shell.py 7 Mar 2002 15:10:51 -0000 1.8
***************
*** 26,30 ****
VERSION = '0.1'
- _cvsChangeCmdRE = re.compile(r'\s+(ad(d)?|new|ci|com(mit)?|delete|remove)\s+')
class CvsShell(PlugableApp, InteractiveApp):
--- 26,29 ----
***************
*** 47,50 ****
--- 46,50 ----
self.cvsRoot = None
self.cvsRootAutoUpdate = 0
+ self.showFullPrompt = 0
self.cmdRegex = re.compile(r"""
^\s* # matches leading whitespace
***************
*** 75,80 ****
else: status += 'A'
root = self.getCvsRoot() or '--'
! return "{%s} %s [%s]$ " % (status,
! os.getcwd().replace(self.HOME, '~'),
root)
--- 75,99 ----
else: status += 'A'
root = self.getCvsRoot() or '--'
! dir = os.getcwd().replace(self.HOME, '~')
! if not self.showFullPrompt:
! # make to prompt match on one line
! extraChars = 6
! maxLineWidth = 79
! minLen = 15
! ls = len(status)
! ld = len(dir)
! lr = len(root)
! width = ls + extraChars + ld + lr
! if width > maxLineWidth:
! w = max(minLen, (lr - (width - maxLineWidth + 3)) / 2)
! if lr > 2*w: root = root[:w] + '...' + root[-w:]
! lr = len(root)
! width = ls + extraChars + ld + lr
! if width > maxLineWidth:
! w = max(minLen, ld - (width - maxLineWidth + 3))
! if ld > w: dir = '...' + dir[-w:]
! ld = len(dir)
! return "{%s} %s [%s]\n$ " % (status,
! dir,
root)
***************
*** 94,101 ****
InteractiveApp.run(self)
def execShellCmd(self, name, opts, context):
- global _cvsChangeCmdRE
app = context['APP']
! if name == 'cvs' and _cvsChangeCmdRE.search(opts): # command may change the status
context['basic_cmds.dirty_listing'] = 1
app.shell('%s %s' % (name, opts))
--- 113,120 ----
InteractiveApp.run(self)
+ _cvsChangeCmdRE = re.compile(r'\s+(ad(d)?|new|ci|com(mit)?|delete|remove)\s+')
def execShellCmd(self, name, opts, context):
app = context['APP']
! if name == 'cvs' and CvsShell._cvsChangeCmdRE.search(opts): # command may change the status
context['basic_cmds.dirty_listing'] = 1
app.shell('%s %s' % (name, opts))
|