summaryrefslogtreecommitdiff
path: root/Demo/pdist
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>1998-09-14 16:44:15 +0000
committerGuido van Rossum <guido@python.org>1998-09-14 16:44:15 +0000
commit5efb5de5d6b9fa13827e67d9db6b67005b497b57 (patch)
tree26f0e1cf78e6283f18e0799d6cafafc905808277 /Demo/pdist
parent81185b11764f0835ecea0f2c913f79493f3d6958 (diff)
downloadcpython-5efb5de5d6b9fa13827e67d9db6b67005b497b57.tar.gz
nannified
Diffstat (limited to 'Demo/pdist')
-rwxr-xr-xDemo/pdist/RCSProxy.py178
-rwxr-xr-xDemo/pdist/makechangelog.py110
-rwxr-xr-xDemo/pdist/rcsclient.py4
-rwxr-xr-xDemo/pdist/rcslib.py458
4 files changed, 375 insertions, 375 deletions
diff --git a/Demo/pdist/RCSProxy.py b/Demo/pdist/RCSProxy.py
index e29090c12a..7212ca6224 100755
--- a/Demo/pdist/RCSProxy.py
+++ b/Demo/pdist/RCSProxy.py
@@ -31,147 +31,147 @@ import rcslib
class DirSupport:
def __init__(self):
- self._dirstack = []
+ self._dirstack = []
def __del__(self):
- self._close()
+ self._close()
def _close(self):
- while self._dirstack:
- self.back()
+ while self._dirstack:
+ self.back()
def pwd(self):
- return os.getcwd()
+ return os.getcwd()
def cd(self, name):
- save = os.getcwd()
- os.chdir(name)
- self._dirstack.append(save)
+ save = os.getcwd()
+ os.chdir(name)
+ self._dirstack.append(save)
def back(self):
- if not self._dirstack:
- raise os.error, "empty directory stack"
- dir = self._dirstack[-1]
- os.chdir(dir)
- del self._dirstack[-1]
+ if not self._dirstack:
+ raise os.error, "empty directory stack"
+ dir = self._dirstack[-1]
+ os.chdir(dir)
+ del self._dirstack[-1]
def listsubdirs(self, pat = None):
- files = os.listdir(os.curdir)
- files = filter(os.path.isdir, files)
- return self._filter(files, pat)
+ files = os.listdir(os.curdir)
+ files = filter(os.path.isdir, files)
+ return self._filter(files, pat)
def isdir(self, name):
- return os.path.isdir(name)
+ return os.path.isdir(name)
def mkdir(self, name):
- os.mkdir(name, 0777)
+ os.mkdir(name, 0777)
def rmdir(self, name):
- os.rmdir(name)
+ os.rmdir(name)
class RCSProxyLocal(rcslib.RCS, DirSupport):
def __init__(self):
- rcslib.RCS.__init__(self)
- DirSupport.__init__(self)
+ rcslib.RCS.__init__(self)
+ DirSupport.__init__(self)
def __del__(self):
- DirSupport.__del__(self)
- rcslib.RCS.__del__(self)
+ DirSupport.__del__(self)
+ rcslib.RCS.__del__(self)
def sumlist(self, list = None):
- return self._list(self.sum, list)
+ return self._list(self.sum, list)
def sumdict(self, list = None):
- return self._dict(self.sum, list)
+ return self._dict(self.sum, list)
def sum(self, name_rev):
- f = self._open(name_rev)
- BUFFERSIZE = 1024*8
- sum = md5.new()
- while 1:
- buffer = f.read(BUFFERSIZE)
- if not buffer:
- break
- sum.update(buffer)
- self._closepipe(f)
- return sum.digest()
+ f = self._open(name_rev)
+ BUFFERSIZE = 1024*8
+ sum = md5.new()
+ while 1:
+ buffer = f.read(BUFFERSIZE)
+ if not buffer:
+ break
+ sum.update(buffer)
+ self._closepipe(f)
+ return sum.digest()
def get(self, name_rev):
- f = self._open(name_rev)
- data = f.read()
- self._closepipe(f)
- return data
+ f = self._open(name_rev)
+ data = f.read()
+ self._closepipe(f)
+ return data
def put(self, name_rev, data, message=None):
- name, rev = self._unmangle(name_rev)
- f = open(name, 'w')
- f.write(data)
- f.close()
- self.checkin(name_rev, message)
- self._remove(name)
+ name, rev = self._unmangle(name_rev)
+ f = open(name, 'w')
+ f.write(data)
+ f.close()
+ self.checkin(name_rev, message)
+ self._remove(name)
def _list(self, function, list = None):
- """INTERNAL: apply FUNCTION to all files in LIST.
+ """INTERNAL: apply FUNCTION to all files in LIST.
- Return a list of the results.
+ Return a list of the results.
- The list defaults to all files in the directory if None.
+ The list defaults to all files in the directory if None.
- """
- if list is None:
- list = self.listfiles()
- res = []
- for name in list:
- try:
- res.append((name, function(name)))
- except (os.error, IOError):
- res.append((name, None))
- return res
+ """
+ if list is None:
+ list = self.listfiles()
+ res = []
+ for name in list:
+ try:
+ res.append((name, function(name)))
+ except (os.error, IOError):
+ res.append((name, None))
+ return res
def _dict(self, function, list = None):
- """INTERNAL: apply FUNCTION to all files in LIST.
+ """INTERNAL: apply FUNCTION to all files in LIST.
- Return a dictionary mapping files to results.
+ Return a dictionary mapping files to results.
- The list defaults to all files in the directory if None.
+ The list defaults to all files in the directory if None.
- """
- if list is None:
- list = self.listfiles()
- dict = {}
- for name in list:
- try:
- dict[name] = function(name)
- except (os.error, IOError):
- pass
- return dict
+ """
+ if list is None:
+ list = self.listfiles()
+ dict = {}
+ for name in list:
+ try:
+ dict[name] = function(name)
+ except (os.error, IOError):
+ pass
+ return dict
class RCSProxyServer(RCSProxyLocal, server.SecureServer):
def __init__(self, address, verbose = server.VERBOSE):
- RCSProxyLocal.__init__(self)
- server.SecureServer.__init__(self, address, verbose)
+ RCSProxyLocal.__init__(self)
+ server.SecureServer.__init__(self, address, verbose)
def _close(self):
- server.SecureServer._close(self)
- RCSProxyLocal._close(self)
+ server.SecureServer._close(self)
+ RCSProxyLocal._close(self)
def _serve(self):
- server.SecureServer._serve(self)
- # Retreat into start directory
- while self._dirstack: self.back()
+ server.SecureServer._serve(self)
+ # Retreat into start directory
+ while self._dirstack: self.back()
def test_server():
import string
import sys
if sys.argv[1:]:
- port = string.atoi(sys.argv[1])
+ port = string.atoi(sys.argv[1])
else:
- port = 4127
+ port = 4127
proxy = RCSProxyServer(('', port))
proxy._serverloop()
@@ -179,19 +179,19 @@ def test_server():
def test():
import sys
if not sys.argv[1:] or sys.argv[1] and sys.argv[1][0] in '0123456789':
- test_server()
- sys.exit(0)
+ test_server()
+ sys.exit(0)
proxy = RCSProxyLocal()
what = sys.argv[1]
if hasattr(proxy, what):
- attr = getattr(proxy, what)
- if callable(attr):
- print apply(attr, tuple(sys.argv[2:]))
- else:
- print `attr`
+ attr = getattr(proxy, what)
+ if callable(attr):
+ print apply(attr, tuple(sys.argv[2:]))
+ else:
+ print `attr`
else:
- print "%s: no such attribute" % what
- sys.exit(2)
+ print "%s: no such attribute" % what
+ sys.exit(2)
if __name__ == '__main__':
diff --git a/Demo/pdist/makechangelog.py b/Demo/pdist/makechangelog.py
index 5a0cf7991c..b26f30b3a0 100755
--- a/Demo/pdist/makechangelog.py
+++ b/Demo/pdist/makechangelog.py
@@ -15,25 +15,25 @@ def main():
opts, args = getopt.getopt(args, 'p:')
prefix = ''
for o, a in opts:
- if p == '-p': prefix = a
+ if p == '-p': prefix = a
f = sys.stdin
allrevs = []
while 1:
- file = getnextfile(f)
- if not file: break
- revs = []
- while 1:
- rev = getnextrev(f, file)
- if not rev:
- break
- revs.append(rev)
- if revs:
- allrevs[len(allrevs):] = revs
+ file = getnextfile(f)
+ if not file: break
+ revs = []
+ while 1:
+ rev = getnextrev(f, file)
+ if not rev:
+ break
+ revs.append(rev)
+ if revs:
+ allrevs[len(allrevs):] = revs
allrevs.sort()
allrevs.reverse()
for rev in allrevs:
- formatrev(rev, prefix)
+ formatrev(rev, prefix)
parsedateprog = regex.compile(
'^date: \([0-9]+\)/\([0-9]+\)/\([0-9]+\) ' +
@@ -48,46 +48,46 @@ authormap = {
def formatrev(rev, prefix):
dateline, file, revline, log = rev
if parsedateprog.match(dateline) >= 0:
- fields = parsedateprog.group(1, 2, 3, 4, 5, 6)
- author = parsedateprog.group(7)
- if authormap.has_key(author): author = authormap[author]
- tfields = map(string.atoi, fields) + [0, 0, 0]
- tfields[5] = tfields[5] - time.timezone
- t = time.mktime(tuple(tfields))
- print time.ctime(t), '', author
- words = string.split(log)
- words[:0] = ['*', prefix + file + ':']
- maxcol = 72-8
- col = maxcol
- for word in words:
- if col > 0 and col + len(word) >= maxcol:
- print
- print '\t' + word,
- col = -1
- else:
- print word,
- col = col + 1 + len(word)
- print
- print
+ fields = parsedateprog.group(1, 2, 3, 4, 5, 6)
+ author = parsedateprog.group(7)
+ if authormap.has_key(author): author = authormap[author]
+ tfields = map(string.atoi, fields) + [0, 0, 0]
+ tfields[5] = tfields[5] - time.timezone
+ t = time.mktime(tuple(tfields))
+ print time.ctime(t), '', author
+ words = string.split(log)
+ words[:0] = ['*', prefix + file + ':']
+ maxcol = 72-8
+ col = maxcol
+ for word in words:
+ if col > 0 and col + len(word) >= maxcol:
+ print
+ print '\t' + word,
+ col = -1
+ else:
+ print word,
+ col = col + 1 + len(word)
+ print
+ print
startprog = regex.compile("^Working file: \(.*\)$")
def getnextfile(f):
while 1:
- line = f.readline()
- if not line: return None
- if startprog.match(line) >= 0:
- file = startprog.group(1)
- # Skip until first revision
- while 1:
- line = f.readline()
- if not line: return None
- if line[:10] == '='*10: return None
- if line[:10] == '-'*10: break
-## print "Skipped", line,
- return file
-## else:
-## print "Ignored", line,
+ line = f.readline()
+ if not line: return None
+ if startprog.match(line) >= 0:
+ file = startprog.group(1)
+ # Skip until first revision
+ while 1:
+ line = f.readline()
+ if not line: return None
+ if line[:10] == '='*10: return None
+ if line[:10] == '-'*10: break
+## print "Skipped", line,
+ return file
+## else:
+## print "Ignored", line,
def getnextrev(f, file):
# This is called when we are positioned just after a '---' separator
@@ -95,14 +95,14 @@ def getnextrev(f, file):
dateline = f.readline()
log = ''
while 1:
- line = f.readline()
- if not line: break
- if line[:10] == '='*10:
- # Ignore the *last* log entry for each file since it
- # is the revision since which we are logging.
- return None
- if line[:10] == '-'*10: break
- log = log + line
+ line = f.readline()
+ if not line: break
+ if line[:10] == '='*10:
+ # Ignore the *last* log entry for each file since it
+ # is the revision since which we are logging.
+ return None
+ if line[:10] == '-'*10: break
+ log = log + line
return dateline, file, revline, log
if __name__ == '__main__':
diff --git a/Demo/pdist/rcsclient.py b/Demo/pdist/rcsclient.py
index 20dffeca23..5d88a57981 100755
--- a/Demo/pdist/rcsclient.py
+++ b/Demo/pdist/rcsclient.py
@@ -22,8 +22,8 @@ import client
class RCSProxyClient(client.SecureClient):
- def __init__(self, address, verbose = client.VERBOSE):
- client.SecureClient.__init__(self, address, verbose)
+ def __init__(self, address, verbose = client.VERBOSE):
+ client.SecureClient.__init__(self, address, verbose)
def openrcsclient(opts = []):
diff --git a/Demo/pdist/rcslib.py b/Demo/pdist/rcslib.py
index 55d764d298..223ddca98e 100755
--- a/Demo/pdist/rcslib.py
+++ b/Demo/pdist/rcslib.py
@@ -36,304 +36,304 @@ class RCS:
okchars = string.letters + string.digits + '-_=+.'
def __init__(self):
- """Constructor."""
- pass
+ """Constructor."""
+ pass
def __del__(self):
- """Destructor."""
- pass
+ """Destructor."""
+ pass
# --- Informational methods about a single file/revision ---
def log(self, name_rev, otherflags = ''):
- """Return the full log text for NAME_REV as a string.
+ """Return the full log text for NAME_REV as a string.
- Optional OTHERFLAGS are passed to rlog.
+ Optional OTHERFLAGS are passed to rlog.
- """
- f = self._open(name_rev, 'rlog ' + otherflags)
- data = f.read()
- status = self._closepipe(f)
- if status:
- data = data + "%s: %s" % status
- elif data[-1] == '\n':
- data = data[:-1]
- return data
+ """
+ f = self._open(name_rev, 'rlog ' + otherflags)
+ data = f.read()
+ status = self._closepipe(f)
+ if status:
+ data = data + "%s: %s" % status
+ elif data[-1] == '\n':
+ data = data[:-1]
+ return data
def head(self, name_rev):
- """Return the head revision for NAME_REV"""
- dict = self.info(name_rev)
- return dict['head']
+ """Return the head revision for NAME_REV"""
+ dict = self.info(name_rev)
+ return dict['head']
def info(self, name_rev):
- """Return a dictionary of info (from rlog -h) for NAME_REV
-
- The dictionary's keys are the keywords that rlog prints
- (e.g. 'head' and its values are the corresponding data
- (e.g. '1.3').
-
- XXX symbolic names and locks are not returned
-
- """
- f = self._open(name_rev, 'rlog -h')
- dict = {}
- while 1:
- line = f.readline()
- if not line: break
- if line[0] == '\t':
- # XXX could be a lock or symbolic name
- # Anything else?
- continue
- i = string.find(line, ':')
- if i > 0:
- key, value = line[:i], string.strip(line[i+1:])
- dict[key] = value
- status = self._closepipe(f)
- if status:
- raise IOError, status
- return dict
+ """Return a dictionary of info (from rlog -h) for NAME_REV
+
+ The dictionary's keys are the keywords that rlog prints
+ (e.g. 'head' and its values are the corresponding data
+ (e.g. '1.3').
+
+ XXX symbolic names and locks are not returned
+
+ """
+ f = self._open(name_rev, 'rlog -h')
+ dict = {}
+ while 1:
+ line = f.readline()
+ if not line: break
+ if line[0] == '\t':
+ # XXX could be a lock or symbolic name
+ # Anything else?
+ continue
+ i = string.find(line, ':')
+ if i > 0:
+ key, value = line[:i], string.strip(line[i+1:])
+ dict[key] = value
+ status = self._closepipe(f)
+ if status:
+ raise IOError, status
+ return dict
# --- Methods that change files ---
def lock(self, name_rev):
- """Set an rcs lock on NAME_REV."""
- name, rev = self.checkfile(name_rev)
- cmd = "rcs -l%s %s" % (rev, name)
- return self._system(cmd)
+ """Set an rcs lock on NAME_REV."""
+ name, rev = self.checkfile(name_rev)
+ cmd = "rcs -l%s %s" % (rev, name)
+ return self._system(cmd)
def unlock(self, name_rev):
- """Clear an rcs lock on NAME_REV."""
- name, rev = self.checkfile(name_rev)
- cmd = "rcs -u%s %s" % (rev, name)
- return self._system(cmd)
+ """Clear an rcs lock on NAME_REV."""
+ name, rev = self.checkfile(name_rev)
+ cmd = "rcs -u%s %s" % (rev, name)
+ return self._system(cmd)
def checkout(self, name_rev, withlock=0, otherflags=""):
- """Check out NAME_REV to its work file.
+ """Check out NAME_REV to its work file.
- If optional WITHLOCK is set, check out locked, else unlocked.
+ If optional WITHLOCK is set, check out locked, else unlocked.
- The optional OTHERFLAGS is passed to co without
- interpretation.
+ The optional OTHERFLAGS is passed to co without
+ interpretation.
- Any output from co goes to directly to stdout.
+ Any output from co goes to directly to stdout.
- """
- name, rev = self.checkfile(name_rev)
- if withlock: lockflag = "-l"
- else: lockflag = "-u"
- cmd = 'co %s%s %s %s' % (lockflag, rev, otherflags, name)
- return self._system(cmd)
+ """
+ name, rev = self.checkfile(name_rev)
+ if withlock: lockflag = "-l"
+ else: lockflag = "-u"
+ cmd = 'co %s%s %s %s' % (lockflag, rev, otherflags, name)
+ return self._system(cmd)
def checkin(self, name_rev, message=None, otherflags=""):
- """Check in NAME_REV from its work file.
-
- The optional MESSAGE argument becomes the checkin message
- (default "<none>" if None); or the file description if this is
- a new file.
-
- The optional OTHERFLAGS argument is passed to ci without
- interpretation.
-
- Any output from ci goes to directly to stdout.
-
- """
- name, rev = self._unmangle(name_rev)
- new = not self.isvalid(name)
- if not message: message = "<none>"
- if message and message[-1] != '\n':
- message = message + '\n'
- lockflag = "-u"
- textfile = None
- try:
- if new:
- textfile = tempfile.mktemp()
- f = open(textfile, 'w')
- f.write(message)
- f.close()
- cmd = 'ci %s%s -t%s %s %s' % \
- (lockflag, rev, textfile, otherflags, name)
- else:
- message = regsub.gsub('\([\\"$`]\)', '\\\\\\1', message)
- cmd = 'ci %s%s -m"%s" %s %s' % \
- (lockflag, rev, message, otherflags, name)
- return self._system(cmd)
- finally:
- if textfile: self._remove(textfile)
+ """Check in NAME_REV from its work file.
+
+ The optional MESSAGE argument becomes the checkin message
+ (default "<none>" if None); or the file description if this is
+ a new file.
+
+ The optional OTHERFLAGS argument is passed to ci without
+ interpretation.
+
+ Any output from ci goes to directly to stdout.
+
+ """
+ name, rev = self._unmangle(name_rev)
+ new = not self.isvalid(name)
+ if not message: message = "<none>"
+ if message and message[-1] != '\n':
+ message = message + '\n'
+ lockflag = "-u"
+ textfile = None
+ try:
+ if new:
+ textfile = tempfile.mktemp()
+ f = open(textfile, 'w')
+ f.write(message)
+ f.close()
+ cmd = 'ci %s%s -t%s %s %s' % \
+ (lockflag, rev, textfile, otherflags, name)
+ else:
+ message = regsub.gsub('\([\\"$`]\)', '\\\\\\1', message)
+ cmd = 'ci %s%s -m"%s" %s %s' % \
+ (lockflag, rev, message, otherflags, name)
+ return self._system(cmd)
+ finally:
+ if textfile: self._remove(textfile)
# --- Exported support methods ---
def listfiles(self, pat = None):
- """Return a list of all version files matching optional PATTERN."""
- files = os.listdir(os.curdir)
- files = filter(self._isrcs, files)
- if os.path.isdir('RCS'):
- files2 = os.listdir('RCS')
- files2 = filter(self._isrcs, files2)
- files = files + files2
- files = map(self.realname, files)
- return self._filter(files, pat)
+ """Return a list of all version files matching optional PATTERN."""
+ files = os.listdir(os.curdir)
+ files = filter(self._isrcs, files)
+ if os.path.isdir('RCS'):
+ files2 = os.listdir('RCS')
+ files2 = filter(self._isrcs, files2)
+ files = files + files2
+ files = map(self.realname, files)
+ return self._filter(files, pat)
def isvalid(self, name):
- """Test whether NAME has a version file associated."""
- namev = self.rcsname(name)
- return (os.path.isfile(namev) or
- os.path.isfile(os.path.join('RCS', namev)))
+ """Test whether NAME has a version file associated."""
+ namev = self.rcsname(name)
+ return (os.path.isfile(namev) or
+ os.path.isfile(os.path.join('RCS', namev)))
def rcsname(self, name):
- """Return the pathname of the version file for NAME.
-
- The argument can be a work file name or a version file name.
- If the version file does not exist, the name of the version
- file that would be created by "ci" is returned.
-
- """
- if self._isrcs(name): namev = name
- else: namev = name + ',v'
- if os.path.isfile(namev): return namev
- namev = os.path.join('RCS', os.path.basename(namev))
- if os.path.isfile(namev): return namev
- if os.path.isdir('RCS'):
- return os.path.join('RCS', namev)
- else:
- return namev
+ """Return the pathname of the version file for NAME.
+
+ The argument can be a work file name or a version file name.
+ If the version file does not exist, the name of the version
+ file that would be created by "ci" is returned.
+
+ """
+ if self._isrcs(name): namev = name
+ else: namev = name + ',v'
+ if os.path.isfile(namev): return namev
+ namev = os.path.join('RCS', os.path.basename(namev))
+ if os.path.isfile(namev): return namev
+ if os.path.isdir('RCS'):
+ return os.path.join('RCS', namev)
+ else:
+ return namev
def realname(self, namev):
- """Return the pathname of the work file for NAME.
+ """Return the pathname of the work file for NAME.
- The argument can be a work file name or a version file name.
- If the work file does not exist, the name of the work file
- that would be created by "co" is returned.
+ The argument can be a work file name or a version file name.
+ If the work file does not exist, the name of the work file
+ that would be created by "co" is returned.
- """
- if self._isrcs(namev): name = namev[:-2]
- else: name = namev
- if os.path.isfile(name): return name
- name = os.path.basename(name)
- return name
+ """
+ if self._isrcs(namev): name = namev[:-2]
+ else: name = namev
+ if os.path.isfile(name): return name
+ name = os.path.basename(name)
+ return name
def islocked(self, name_rev):
- """Test whether FILE (which must have a version file) is locked.
-
- XXX This does not tell you which revision number is locked and
- ignores any revision you may pass in (by virtue of using rlog
- -L -R).
-
- """
- f = self._open(name_rev, 'rlog -L -R')
- line = f.readline()
- status = self._closepipe(f)
- if status:
- raise IOError, status
- if not line: return None
- if line[-1] == '\n':
- line = line[:-1]
- return self.realname(name_rev) == self.realname(line)
+ """Test whether FILE (which must have a version file) is locked.
+
+ XXX This does not tell you which revision number is locked and
+ ignores any revision you may pass in (by virtue of using rlog
+ -L -R).
+
+ """
+ f = self._open(name_rev, 'rlog -L -R')
+ line = f.readline()
+ status = self._closepipe(f)
+ if status:
+ raise IOError, status
+ if not line: return None
+ if line[-1] == '\n':
+ line = line[:-1]
+ return self.realname(name_rev) == self.realname(line)
def checkfile(self, name_rev):
- """Normalize NAME_REV into a (NAME, REV) tuple.
+ """Normalize NAME_REV into a (NAME, REV) tuple.
- Raise an exception if there is no corresponding version file.
+ Raise an exception if there is no corresponding version file.
- """
- name, rev = self._unmangle(name_rev)
- if not self.isvalid(name):
- raise os.error, 'not an rcs file %s' % `name`
- return name, rev
+ """
+ name, rev = self._unmangle(name_rev)
+ if not self.isvalid(name):
+ raise os.error, 'not an rcs file %s' % `name`
+ return name, rev
# --- Internal methods ---
def _open(self, name_rev, cmd = 'co -p', rflag = '-r'):
- """INTERNAL: open a read pipe to NAME_REV using optional COMMAND.
+ """INTERNAL: open a read pipe to NAME_REV using optional COMMAND.
- Optional FLAG is used to indicate the revision (default -r).
+ Optional FLAG is used to indicate the revision (default -r).
- Default COMMAND is "co -p".
+ Default COMMAND is "co -p".
- Return a file object connected by a pipe to the command's
- output.
+ Return a file object connected by a pipe to the command's
+ output.
- """
- name, rev = self.checkfile(name_rev)
- namev = self.rcsname(name)
- if rev:
- cmd = cmd + ' ' + rflag + rev
- return os.popen("%s %s" % (cmd, `namev`))
+ """
+ name, rev = self.checkfile(name_rev)
+ namev = self.rcsname(name)
+ if rev:
+ cmd = cmd + ' ' + rflag + rev
+ return os.popen("%s %s" % (cmd, `namev`))
def _unmangle(self, name_rev):
- """INTERNAL: Normalize NAME_REV argument to (NAME, REV) tuple.
+ """INTERNAL: Normalize NAME_REV argument to (NAME, REV) tuple.
- Raise an exception if NAME contains invalid characters.
+ Raise an exception if NAME contains invalid characters.
- A NAME_REV argument is either NAME string (implying REV='') or
- a tuple of the form (NAME, REV).
+ A NAME_REV argument is either NAME string (implying REV='') or
+ a tuple of the form (NAME, REV).
- """
- if type(name_rev) == type(''):
- name_rev = name, rev = name_rev, ''
- else:
- name, rev = name_rev
- for c in rev:
- if c not in self.okchars:
- raise ValueError, "bad char in rev"
- return name_rev
+ """
+ if type(name_rev) == type(''):
+ name_rev = name, rev = name_rev, ''
+ else:
+ name, rev = name_rev
+ for c in rev:
+ if c not in self.okchars:
+ raise ValueError, "bad char in rev"
+ return name_rev
def _closepipe(self, f):
- """INTERNAL: Close PIPE and print its exit status if nonzero."""
- sts = f.close()
- if not sts: return None
- detail, reason = divmod(sts, 256)
- if reason == 0: return 'exit', detail # Exit status
- signal = reason&0x7F
- if signal == 0x7F:
- code = 'stopped'
- signal = detail
- else:
- code = 'killed'
- if reason&0x80:
- code = code + '(coredump)'
- return code, signal
+ """INTERNAL: Close PIPE and print its exit status if nonzero."""
+ sts = f.close()
+ if not sts: return None
+ detail, reason = divmod(sts, 256)
+ if reason == 0: return 'exit', detail # Exit status
+ signal = reason&0x7F
+ if signal == 0x7F:
+ code = 'stopped'
+ signal = detail
+ else:
+ code = 'killed'
+ if reason&0x80:
+ code = code + '(coredump)'
+ return code, signal
def _system(self, cmd):
- """INTERNAL: run COMMAND in a subshell.
+ """INTERNAL: run COMMAND in a subshell.
- Standard input for the command is taken fron /dev/null.
+ Standard input for the command is taken fron /dev/null.
- Raise IOError when the exit status is not zero.
+ Raise IOError when the exit status is not zero.
- Return whatever the calling method should return; normally
- None.
+ Return whatever the calling method should return; normally
+ None.
- A derived class may override this method and redefine it to
- capture stdout/stderr of the command and return it.
+ A derived class may override this method and redefine it to
+ capture stdout/stderr of the command and return it.
- """
- cmd = cmd + " </dev/null"
- sts = os.system(cmd)
- if sts: raise IOError, "command exit status %d" % sts
+ """
+ cmd = cmd + " </dev/null"
+ sts = os.system(cmd)
+ if sts: raise IOError, "command exit status %d" % sts
def _filter(self, files, pat = None):
- """INTERNAL: Return a sorted copy of the given list of FILES.
-
- If a second PATTERN argument is given, only files matching it
- are kept. No check for valid filenames is made.
-
- """
- if pat:
- def keep(name, pat = pat):
- return fnmatch.fnmatch(name, pat)
- files = filter(keep, files)
- else:
- files = files[:]
- files.sort()
- return files
+ """INTERNAL: Return a sorted copy of the given list of FILES.
+
+ If a second PATTERN argument is given, only files matching it
+ are kept. No check for valid filenames is made.
+
+ """
+ if pat:
+ def keep(name, pat = pat):
+ return fnmatch.fnmatch(name, pat)
+ files = filter(keep, files)
+ else:
+ files = files[:]
+ files.sort()
+ return files
def _remove(self, fn):
- """INTERNAL: remove FILE without complaints."""
- try:
- os.unlink(fn)
- except os.error:
- pass
+ """INTERNAL: remove FILE without complaints."""
+ try:
+ os.unlink(fn)
+ except os.error:
+ pass
def _isrcs(self, name):
- """INTERNAL: Test whether NAME ends in ',v'."""
- return name[-2:] == ',v'
+ """INTERNAL: Test whether NAME ends in ',v'."""
+ return name[-2:] == ',v'