cpython/Demo/pdist/rcvs.py

87 lines
1.6 KiB
Python
Raw Normal View History

#! /usr/local/bin/python
"""Remote CVS -- command line interface"""
from cvslib import CVS, File
1995-04-26 22:57:11 +00:00
import md5
import os
import string
import sys
from cmdfw import CommandFrameWork
1995-04-26 22:57:11 +00:00
class MyFile(File):
1995-04-26 22:57:11 +00:00
def update(self):
print self.file, '...'
if self.lsum == self.esum == self.rsum:
print '=', self.file
return
if self.lsum and not self.erev and not self.rrev:
print '?', self.file
return
print 'X', self.file
1995-04-26 22:57:11 +00:00
class RCVS(CVS):
FileClass = MyFile
def __init__(self):
CVS.__init__(self)
def checkfiles(self, files):
if not files:
def ok(file, self=self):
e = self.entries[file]
return e.eseen or e.rseen
files[:] = filter(ok, self.entries.keys())
files.sort()
class rcvs(CommandFrameWork):
GlobalFlags = 'd:h:p:qv'
UsageMessage = \
"usage: rcvs [-d directory] [-h host] [-p port] [-q] [-v] subcommand arg ..."
def __init__(self):
"""Constructor."""
CommandFrameWork.__init__(self)
self.proxy = None
self.cvs = RCVS()
def options(self, opts):
self.opts = opts
def ready(self):
import rcsclient
self.proxy = rcsclient.openrcsclient(self.opts)
self.cvs.setproxy(self.proxy)
self.cvs.getentries()
self.cvs.getlocalfiles()
self.cvs.getremotefiles(self.proxy)
def default(self):
self.cvs.report()
def do_update(self, opts, files):
self.cvs.checkfiles(files)
if not files:
print "no files"
1995-04-26 22:57:11 +00:00
return
for file in files:
if not self.cvs.entries.has_key(file):
print "%s: not found" % file
else:
self.cvs.entries[file].update()
1995-04-26 22:57:11 +00:00
1995-04-27 21:28:53 +00:00
def main():
rcvs().run()
1995-04-26 22:57:11 +00:00
if __name__ == "__main__":
1995-04-27 21:28:53 +00:00
main()