largely rewritten FileClass and RCVS

This commit is contained in:
Guido van Rossum 1995-05-01 20:06:44 +00:00
parent 1c653bd6be
commit ec8cfd4089

View File

@ -34,6 +34,10 @@ class MyFile(File):
'c' -- create entry 'c' -- create entry
'u' -- update entry 'u' -- update entry
""" """
if not self.lseen:
self.getlocal()
if not self.rseen:
self.getremote()
if not self.eseen: if not self.eseen:
if not self.lseen: if not self.lseen:
if not self.rseen: return '0' # Never heard of if not self.rseen: return '0' # Never heard of
@ -114,6 +118,7 @@ class MyFile(File):
self.file self.file
def diff(self, opts = []): def diff(self, opts = []):
self.action() # To update lseen, rseen
if self.lsum == self.rsum: if self.lsum == self.rsum:
return return
import tempfile import tempfile
@ -170,25 +175,63 @@ class RCVS(CVS):
def __init__(self): def __init__(self):
CVS.__init__(self) CVS.__init__(self)
def checkfiles(self, files): def update(self, files):
if not files: for e in self.whichentries(files, 1):
def ok(file, self=self): e.update()
e = self.entries[file]
return e.eseen or e.rseen def commit(self, files, message = ""):
files[:] = filter(ok, self.entries.keys()) list = self.whichentries(files)
files.sort() ok = 1
if not files: for e in list:
print "no files to be processed" if not e.commitcheck():
return 1 ok = 0
else: if not ok:
return None print "correct above errors first"
else: return
sts = None if not message:
message = raw_input("One-liner: ")
for e in list:
e.commit(message)
def report(self, files):
for e in self.whichentries(files):
e.report()
def diff(self, files, opts):
for e in self.whichentries(files):
e.diff(opts)
def whichentries(self, files, localfilestoo = 0):
if files:
list = []
for file in files: for file in files:
if not self.entries.has_key(file): if self.entries.has_key(file):
print "%s: nothing known" % file e = self.entries[file]
sts = 1 else:
return sts e = self.FileClass(file)
self.entries[file] = e
list.append(e)
else:
list = self.entries.values()
for file in self.proxy.listfiles():
if self.entries.has_key(file):
continue
e = self.FileClass(file)
self.entries[file] = e
list.append(e)
if localfilestoo:
for file in os.listdir(os.curdir):
if not self.entries.has_key(file) \
and not self.ignored(file):
e = self.FileClass(file)
self.entries[file] = e
list.append(e)
list.sort()
if self.proxy:
for e in list:
if e.proxy is None:
e.proxy = self.proxy
return list
class rcvs(CommandFrameWork): class rcvs(CommandFrameWork):
@ -213,50 +256,29 @@ class rcvs(CommandFrameWork):
self.proxy = rcsclient.openrcsclient(self.opts) self.proxy = rcsclient.openrcsclient(self.opts)
self.cvs.setproxy(self.proxy) self.cvs.setproxy(self.proxy)
self.cvs.getentries() self.cvs.getentries()
self.cvs.getlocalfiles()
self.cvs.getremotefiles(self.proxy)
def default(self): def default(self):
files = [] self.cvs.report([])
if self.cvs.checkfiles(files):
return 1
for file in files:
print self.cvs.entries[file].action(), file
def do_update(self, opts, files): def do_update(self, opts, files):
"""update [file] ...""" """update [file] ..."""
if self.cvs.checkfiles(files): self.cvs.update(files)
return 1
for file in files:
if not self.cvs.entries.has_key(file):
print "%s: not found" % file
else:
self.cvs.entries[file].update()
self.cvs.putentries() self.cvs.putentries()
do_up = do_update do_up = do_update
def do_commit(self, opts, files): def do_commit(self, opts, files):
"""commit [file] ...""" """commit [-m message] [file] ..."""
if self.cvs.checkfiles(files): message = ""
return 1 for o, a in opts:
sts = 0 if o == '-m': message = a
for file in files: self.cvs.commit(files, message)
if not self.cvs.entries[file].commitcheck():
sts = 1
if sts:
return sts
message = raw_input("One-liner: ")
for file in files:
self.cvs.entries[file].commit(message)
self.cvs.putentries() self.cvs.putentries()
do_com = do_commit do_com = do_commit
flags_commit = 'm:'
def do_diff(self, opts, files): def do_diff(self, opts, files):
"""diff [difflags] [file] ...""" """diff [difflags] [file] ..."""
if self.cvs.checkfiles(files): self.cvs.diff(files, opts)
return 1
for file in files:
self.cvs.entries[file].diff(opts)
do_dif = do_diff do_dif = do_diff
flags_diff = 'cbitwcefhnlrsD:S:' flags_diff = 'cbitwcefhnlrsD:S:'