5
Provide a simplified interface on RCS files, locally or remotely.
6
The functionality is geared towards implementing some sort of
7
remote CVS like utility. It is modeled after the similar module
10
The module defines two classes:
12
RCSProxyLocal -- used for local access
13
RCSProxyServer -- used on the server side of remote access
15
The corresponding client class, RCSProxyClient, is defined in module
18
The remote classes are instantiated with an IP address and an optional
49
self._dirstack.append(save)
52
if not self._dirstack:
53
raise os.error, "empty directory stack"
54
dir = self._dirstack[-1]
56
del self._dirstack[-1]
58
def listsubdirs(self, pat = None):
59
files = os.listdir(os.curdir)
60
files = filter(os.path.isdir, files)
61
return self._filter(files, pat)
63
def isdir(self, name):
64
return os.path.isdir(name)
66
def mkdir(self, name):
69
def rmdir(self, name):
73
class RCSProxyLocal(rcslib.RCS, DirSupport):
76
rcslib.RCS.__init__(self)
77
DirSupport.__init__(self)
80
DirSupport.__del__(self)
81
rcslib.RCS.__del__(self)
83
def sumlist(self, list = None):
84
return self._list(self.sum, list)
86
def sumdict(self, list = None):
87
return self._dict(self.sum, list)
89
def sum(self, name_rev):
90
f = self._open(name_rev)
94
buffer = f.read(BUFFERSIZE)
101
def get(self, name_rev):
102
f = self._open(name_rev)
107
def put(self, name_rev, data, message=None):
108
name, rev = self._unmangle(name_rev)
112
self.checkin(name_rev, message)
115
def _list(self, function, list = None):
116
"""INTERNAL: apply FUNCTION to all files in LIST.
118
Return a list of the results.
120
The list defaults to all files in the directory if None.
124
list = self.listfiles()
128
res.append((name, function(name)))
129
except (os.error, IOError):
130
res.append((name, None))
133
def _dict(self, function, list = None):
134
"""INTERNAL: apply FUNCTION to all files in LIST.
136
Return a dictionary mapping files to results.
138
The list defaults to all files in the directory if None.
142
list = self.listfiles()
146
dict[name] = function(name)
147
except (os.error, IOError):
152
class RCSProxyServer(RCSProxyLocal, server.SecureServer):
154
def __init__(self, address, verbose = server.VERBOSE):
155
RCSProxyLocal.__init__(self)
156
server.SecureServer.__init__(self, address, verbose)
159
server.SecureServer._close(self)
160
RCSProxyLocal._close(self)
163
server.SecureServer._serve(self)
164
# Retreat into start directory
165
while self._dirstack: self.back()
172
port = string.atoi(sys.argv[1])
175
proxy = RCSProxyServer(('', port))
181
if not sys.argv[1:] or sys.argv[1] and sys.argv[1][0] in '0123456789':
184
proxy = RCSProxyLocal()
186
if hasattr(proxy, what):
187
attr = getattr(proxy, what)
189
print apply(attr, tuple(sys.argv[2:]))
193
print "%s: no such attribute" % what
197
if __name__ == '__main__':