Ticket #257: perforce.patch
| File perforce.patch, 4.4 KB (added by , 18 years ago) |
|---|
-
perforce.
old new 49 49 """ 50 50 Repository implementation for perforce 51 51 """ 52 p4c = p4.P4() 53 p4init = 0 52 54 53 55 def __init__(self, name, authz, log, port, user, client, passwd, maxItems): 54 56 Repository.__init__(self, name, authz, log) 55 self.p4c = p4.P4() 56 self.p4c.port = port 57 self.p4c.user = user 58 self.p4c.client = client 59 self.p4c.password = passwd 60 self.p4c.parse_forms() 57 if(self.__class__.p4init == 0): 58 self.__class__.p4init = 1 59 self.__class__.p4c = p4.P4() 60 self.__class__.p4c.port = port 61 self.__class__.p4c.user = user 62 self.__class__.p4c.client = client 63 self.__class__.p4c.password = passwd 64 self.__class__.p4c.parse_forms() 61 65 try: 62 self.p4c.connect() 66 self.__class__.p4c.connect() 67 except self.__class__.p4c.P4Error: 68 for e in p4.errors: 69 self.log.debug(e) 70 self.__class__.p4init = 0 63 71 # cache the first few changes 72 try: 64 73 self.history = [] 65 changes = self. p4c.run("changes", "-m", maxItems, "-s", "submitted")74 changes = self.__class__.p4c.run("changes", "-m", maxItems, "-s", "submitted") 66 75 for change in changes: 67 76 self.history.append(change['change']) 68 77 69 except self. p4c.P4Error:78 except self.__class__.p4c.P4Error: 70 79 for e in p4.errors: 71 80 self.log.debug(e) 72 81 … … 86 95 change = { } 87 96 try: 88 97 if rev != None: 89 change = self. p4c.run_describe(rev)[0]98 change = self.__class__.p4c.run_describe(rev)[0] 90 99 else: 91 100 young = self.get_youngest_rev() 92 change = self. p4c.run_describe(young)[0]93 except self. p4c.P4Error:101 change = self.__class__.p4c.run_describe(young)[0] 102 except self.__class__.p4c.P4Error: 94 103 for e in p4.errors: 95 104 self.log.debug(e) 96 return PerforceChangeset(self. p4c, rev, change, self.log)105 return PerforceChangeset(self.__class__.p4c, rev, change, self.log) 97 106 98 107 99 108 def has_node(self, path, rev): … … 123 132 124 133 if path.endswith("...") == True: 125 134 path2 = path.rstrip('...') 126 dir = self. p4c.run("dirs", path2)135 dir = self.__class__.p4c.run("dirs", path2) 127 136 else: 128 dir = self. p4c.run("dirs", path)137 dir = self.__class__.p4c.run("dirs", path) 129 138 130 139 if len(dir) != 0: 131 140 kind = Node.DIRECTORY … … 133 142 kind = Node.FILE 134 143 else: 135 144 kind = Node.DIRECTORY 136 return PerforceNode(path, rev, self. p4c, self.log, kind)145 return PerforceNode(path, rev, self.__class__.p4c, self.log, kind) 137 146 138 147 139 148 def get_oldest_rev(self): … … 145 154 """ 146 155 Return the youngest revision in the repository. 147 156 """ 148 rev = self. p4c.run("changes", "-m", "1", "-s", "submitted")[0]['change']157 rev = self.__class__.p4c.run("changes", "-m", "1", "-s", "submitted")[0]['change'] 149 158 #self.log.debug("*** get_youngest_rev rev = %s" % (rev)) 150 159 151 160 if rev != self.history[0]: 152 161 count = int(rev) - int(self.history[0]) 153 changes = self. p4c.run("changes", "-m", count, "-s", "submitted")162 changes = self.__class__.p4c.run("changes", "-m", count, "-s", "submitted") 154 163 idx = 0 155 164 for change in changes: 156 165 num = change['change'] … … 212 221 if path.startswith("//") == False: 213 222 path = path.rstrip('/') 214 223 path = '/' + path 215 dir = self. p4c.run("dirs", path)224 dir = self.__class__.p4c.run("dirs", path) 216 225 if len(dir) != 0: 217 226 kind = Node.DIRECTORY 218 227 else: … … 391 400 def get_content_length(self): 392 401 if self.isdir: 393 402 return None 394 type = self.p4c.run("fstat", "- Ol", self.path)403 type = self.p4c.run("fstat", "-l", self.path) 395 404 if type[0]['headAction'].startswith('delete') == True: 396 405 return 0 397 406 #self.log.debug("*** get_content_length = %s" % type)
