# # # patch "tracvc/mtn/automate.py" # from [9a4ae3091e1ab0f865a560e0504964fbefa361a8] # to [7ac27cb8830df9e1128667831255400a975bf138] # ============================================================ --- tracvc/mtn/automate.py 9a4ae3091e1ab0f865a560e0504964fbefa361a8 +++ tracvc/mtn/automate.py 7ac27cb8830df9e1128667831255400a975bf138 @@ -97,21 +97,31 @@ class Automate(object): break return status, result - def _write_cmd(self, cmd, args): - """Assemble command and args and send it to mtn.""" + def _write_cmd(self, cmd, args, opts): + """Assemble the cmdline from command, args and opts and send + it to mtn.""" def lstring(string): """Prepend string with its length followed by a colon.""" return "%d:%s" % (len(string), string) - cmdstring = "l" + lstring(cmd) + cmdstring = "" + + if opts: + cmdstring += "o" + for name, val in opts.iteritems(): + cmdstring += lstring(name) + lstring(val) + cmdstring += "e" + + cmdstring += "l" + cmdstring += lstring(cmd) for arg in args: cmdstring += lstring(arg) cmdstring += "e" self._write(cmdstring) self._flush() - def command(self, cmd, *args): + def command(self, cmd, args=[], opts={}): """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 @@ -148,28 +158,28 @@ class MTN(object): def heads(self, name): """Returns a list containing the head revs of branch 'name'.""" - return self.automate.command("heads", name).splitlines() + return self.automate.command("heads", [name]).splitlines() def children(self, rev): """Returns a list of the children of rev.""" - return self.automate.command("children", rev).splitlines() + return self.automate.command("children", [rev]).splitlines() @memoize(get_cachespec) # IGNORE:E0602 def parents(self, rev): """Returns a list of the parents of rev.""" - return self.automate.command("parents", rev).splitlines() + return self.automate.command("parents", [rev]).splitlines() def ancestors(self, revs): """Returns a list of the ancestors of rev.""" - return self.automate.command("ancestors", *revs).splitlines() #IGNORE:W0142 + return self.automate.command("ancestors", revs).splitlines() def toposort(self, revs): """Sorts revisions topologically.""" - return self.automate.command("toposort", *revs).splitlines() #IGNORE:W0142 + return self.automate.command("toposort", revs).splitlines() def all_revs(self): """Returns a list of all revs in the repository.""" - return self.automate.command("select", '').splitlines() + return self.automate.command("select", ['']).splitlines() def roots(self): """Returns a list of all root revisions.""" @@ -187,7 +197,7 @@ class MTN(object): def select(self, selector): """Returns a list of revisions selected by the selector.""" return self.automate.command("select", - selector.encode('utf-8')).splitlines() + [selector.encode('utf-8')]).splitlines() @memoize(get_cachespec) # IGNORE:E0602 def manifest(self, rev): @@ -196,7 +206,7 @@ class MTN(object): The manifest is a dictionary: path -> (kind, file_id, attrs), with kind being 'file' or 'dir', and attrs being a dictionary attr_name -> attr_value.""" - raw_manifest = self.automate.command("get_manifest_of", rev) + raw_manifest = self.automate.command("get_manifest_of", [rev]) manifest = {} # stanzas have variable length, trigger on next 'path' ... @@ -220,7 +230,7 @@ class MTN(object): """Returns a dictionary of certs for rev. There might be more than one cert of the same name, so their values are collected in a list.""" - raw_certs = self.automate.command("certs", rev) + raw_certs = self.automate.command("certs", [rev]) certs = {} for key, values in basic_io.items(raw_certs): @@ -233,7 +243,7 @@ class MTN(object): def file(self, file_id): """Returns the file contents for a given file id.""" - return self.automate.command("get_file", file_id) + return self.automate.command("get_file", [file_id]) @memoize(get_cachespec) # IGNORE:E0602 def file_length(self, file_id): @@ -244,7 +254,7 @@ class MTN(object): def changesets(self, rev): """Parses a textual changeset into an instance of the Changeset class.""" - raw_changesets = self.automate.command("get_revision", rev) + raw_changesets = self.automate.command("get_revision", [rev]) changesets = [] oldpath = None @@ -323,7 +333,7 @@ class MTN(object): Currently returns an empty list for directories.""" raw_content_changed = self.automate.command("get_content_changed", - rev, path[1:]) + [rev, path[1:]]) revs = [] for key, values in basic_io.items(raw_content_changed): if key == 'content_mark':