Guido van Rossum | 464f62b | 1995-06-23 22:41:34 +0000 | [diff] [blame] | 1 | """Customize this file to change the default client etc. |
| 2 | |
| 3 | (In general, it is probably be better to make local operation the |
| 4 | default and to require something like an RCSSERVER environment |
| 5 | variable to enable remote operation.) |
| 6 | |
| 7 | """ |
Guido van Rossum | 8bcd301 | 1995-04-28 14:31:36 +0000 | [diff] [blame] | 8 | |
| 9 | import string |
| 10 | |
Guido van Rossum | 177df7d | 1995-04-28 19:23:13 +0000 | [diff] [blame] | 11 | # These defaults don't belong here -- they should be taken from the |
| 12 | # environment or from a hidden file in the current directory |
| 13 | |
Guido van Rossum | 8bcd301 | 1995-04-28 14:31:36 +0000 | [diff] [blame] | 14 | HOST = 'voorn.cwi.nl' |
| 15 | PORT = 4127 |
Guido van Rossum | 8bcd301 | 1995-04-28 14:31:36 +0000 | [diff] [blame] | 16 | VERBOSE = 1 |
Guido van Rossum | 464f62b | 1995-06-23 22:41:34 +0000 | [diff] [blame] | 17 | LOCAL = 0 |
Guido van Rossum | 72974f3 | 1995-06-23 21:59:12 +0000 | [diff] [blame] | 18 | |
| 19 | import client |
| 20 | |
| 21 | |
| 22 | class RCSProxyClient(client.SecureClient): |
| 23 | |
| 24 | def __init__(self, address, verbose = client.VERBOSE): |
| 25 | client.SecureClient.__init__(self, address, verbose) |
| 26 | |
| 27 | |
Guido van Rossum | 8bcd301 | 1995-04-28 14:31:36 +0000 | [diff] [blame] | 28 | def openrcsclient(opts = []): |
| 29 | "open an RCSProxy client based on a list of options returned by getopt" |
| 30 | import RCSProxy |
| 31 | host = HOST |
| 32 | port = PORT |
Guido van Rossum | 8bcd301 | 1995-04-28 14:31:36 +0000 | [diff] [blame] | 33 | verbose = VERBOSE |
Guido van Rossum | 464f62b | 1995-06-23 22:41:34 +0000 | [diff] [blame] | 34 | local = LOCAL |
Guido van Rossum | 177df7d | 1995-04-28 19:23:13 +0000 | [diff] [blame] | 35 | directory = None |
Guido van Rossum | 8bcd301 | 1995-04-28 14:31:36 +0000 | [diff] [blame] | 36 | for o, a in opts: |
| 37 | if o == '-h': |
| 38 | host = a |
| 39 | if ':' in host: |
| 40 | i = string.find(host, ':') |
| 41 | host, p = host[:i], host[i+1:] |
| 42 | if p: |
| 43 | port = string.atoi(p) |
| 44 | if o == '-p': |
| 45 | port = string.atoi(a) |
| 46 | if o == '-d': |
| 47 | directory = a |
| 48 | if o == '-v': |
| 49 | verbose = verbose + 1 |
| 50 | if o == '-q': |
| 51 | verbose = 0 |
Guido van Rossum | 464f62b | 1995-06-23 22:41:34 +0000 | [diff] [blame] | 52 | if o == '-L': |
| 53 | local = 1 |
| 54 | if local: |
| 55 | import RCSProxy |
| 56 | x = RCSProxy.RCSProxyLocal() |
| 57 | else: |
| 58 | address = (host, port) |
| 59 | x = RCSProxyClient(address, verbose) |
Guido van Rossum | 177df7d | 1995-04-28 19:23:13 +0000 | [diff] [blame] | 60 | if not directory: |
| 61 | try: |
| 62 | directory = open("CVS/Repository").readline() |
| 63 | except IOError: |
| 64 | pass |
| 65 | else: |
| 66 | if directory[-1] == '\n': |
| 67 | directory = directory[:-1] |
Guido van Rossum | 8bcd301 | 1995-04-28 14:31:36 +0000 | [diff] [blame] | 68 | if directory: |
| 69 | x.cd(directory) |
| 70 | return x |