# # # patch "tracmtn/automate.py" # from [e690c76f9e846869da4ce989ef87b775484e99b8] # to [8dfe915fa86a4380589606f4a0c16130bf9caf98] # ============================================================ --- tracmtn/automate.py e690c76f9e846869da4ce989ef87b775484e99b8 +++ tracmtn/automate.py 8dfe915fa86a4380589606f4a0c16130bf9caf98 @@ -2,7 +2,7 @@ Trac Plugin for Monotone """ Trac Plugin for Monotone -Copyright 2006-2008 Thomas Moschny (address@hidden) +Copyright 2006-2010 Thomas Moschny (address@hidden) {{{ This program is free software; you can redistribute it and/or modify @@ -111,23 +111,26 @@ class Automate(object): cmdstring += "l" cmdstring += lstring(cmd) - for arg in args: - cmdstring += lstring(arg) + if args: + for arg in args: + cmdstring += lstring(arg) cmdstring += "e" self._write(cmdstring) self._flush() def read_headers(self): + """Starting with version 0.46, the mtn process outputs a + header upon startup.""" headers = {} while True: line = self._readline().rstrip('\n') if not line: break - key, value = map(lambda s: s.strip(), line.split(':')) + key, value = [s.strip() for s in line.split(':')] headers[key] = value return headers - def command(self, cmd, args=[], opts={}): + def command(self, cmd, args=None, opts=None): """Send a command to mtn. Returns a tuple (status, result).""" # critical region: only one thread may send a command and read # back the result at a time @@ -288,8 +291,8 @@ class MTN(object): def branchnames(self): """Returns a list of branch names.""" - return map(to_unicode, #IGNORE:W0141 - self.automate.command("branches").splitlines()) + return [to_unicode(b) for b in + self.automate.command("branches").splitlines()] def branches(self): """Returns a list of (branch, oneoftheheads) tuples. Caveat: @@ -347,6 +350,7 @@ class MTN(object): return self.interface_version def min_interface_version(self, v): + """True if the interface version is at least v.""" return natsort_key(self.get_interface_version()) \ >= natsort_key(v)