comparison mercurial/wireproto.py @ 14970:592e45b7d43e

wireproto: use safehasattr or getattr instead of hasattr
author Augie Fackler <durin42@gmail.com>
date Mon, 25 Jul 2011 16:05:01 -0500
parents e7c9fdbbb902
children f4522df38c65
comparison
equal deleted inserted replaced
14969:a3f97038c1c2 14970:592e45b7d43e
15 # abstract batching support 15 # abstract batching support
16 16
17 class future(object): 17 class future(object):
18 '''placeholder for a value to be set later''' 18 '''placeholder for a value to be set later'''
19 def set(self, value): 19 def set(self, value):
20 if hasattr(self, 'value'): 20 if util.safehasattr(self, 'value'):
21 raise error.RepoError("future is already set") 21 raise error.RepoError("future is already set")
22 self.value = value 22 self.value = value
23 23
24 class batcher(object): 24 class batcher(object):
25 '''base class for batches of commands submittable in a single request 25 '''base class for batches of commands submittable in a single request
56 self.remote = remote 56 self.remote = remote
57 def submit(self): 57 def submit(self):
58 req, rsp = [], [] 58 req, rsp = [], []
59 for name, args, opts, resref in self.calls: 59 for name, args, opts, resref in self.calls:
60 mtd = getattr(self.remote, name) 60 mtd = getattr(self.remote, name)
61 if hasattr(mtd, 'batchable'): 61 batchablefn = getattr(mtd, 'batchable', None)
62 batchable = getattr(mtd, 'batchable')(mtd.im_self, *args, **opts) 62 if batchablefn is not None:
63 batchable = batchablefn(mtd.im_self, *args, **opts)
63 encargsorres, encresref = batchable.next() 64 encargsorres, encresref = batchable.next()
64 if encresref: 65 if encresref:
65 req.append((name, encargsorres,)) 66 req.append((name, encargsorres,))
66 rsp.append((batchable, encresref, resref,)) 67 rsp.append((batchable, encresref, resref,))
67 else: 68 else: