# # # patch "tracvc/mtn/automate.py" # from [5dea534be3d7b634fae702b6f5477179dbcb9b93] # to [b17b0d676f3b38ba2542b997bcc63c59e49cce23] # ============================================================ --- tracvc/mtn/automate.py 5dea534be3d7b634fae702b6f5477179dbcb9b93 +++ tracvc/mtn/automate.py b17b0d676f3b38ba2542b997bcc63c59e49cce23 @@ -65,8 +65,8 @@ self.db = db self.binary = binary - def get_list(self, what): - conn = Connection(self.db, "list " + what, self.binary) + def get_list(self, what, cmd = "list"): + conn = Connection(self.db, "%s %s" % (cmd, what) , self.binary) return conn.read() @@ -345,12 +345,50 @@ for match in TAGS_RULE.finditer(self.list.get_list("tags")): tags.append((self._u(match.group('tag')), match.group('rev'))) return tags + + @memoize(get_cachespec) + def roster(self, rev): + """Returns the roster associated with a certain revision. + !Note! get_roster is currently an unofficial monotone command + and maybe subject to changes in the future.""" + byname = {} + byident = {} + result = self.list.get_list(rev, "get_roster") + for stanza in basic_io.get_stanzas(result): + rawinfo = basic_io.get_hash_from_stanza(stanza) + if rawinfo.has_key('dir'): + info = NodeInfo('dir', '/' + rawinfo['dir'], int(rawinfo['ident']), + rawinfo['birth'], rawinfo['path_mark']) + elif rawinfo.has_key('file'): + info = NodeInfo('file', '/' + rawinfo['file'], int(rawinfo['ident']), + rawinfo['birth'], rawinfo['path_mark'], + rawinfo['content'], rawinfo['content_mark']) + else: + continue + byname[info.name] = info + byident[info.ident] = info + return (byname, byident) + + class Changeset(object): def __init__(self, oldrev): + self.oldrev = oldrev # the old rev this cs is against + self.added = {} # nodename -> kind + self.renamed = {} # newname -> oldname + self.patched = [] # list of newnames + self.deleted = [] # list of oldnames + + +class NodeInfo(object): + + def __init__(self, kind, name, ident, birth, path_mark, + content = None, content_mark = None ): + self.kind = kind + self.content = content + self.name = name + self.ident = ident # mtn's internal file number + self.birth = birth # revision in which this nide was born + self.path_mark = path_mark # marked rev wrt to the node's name + self.content_mark = content_mark # marked rev wrt to the node's content - self.oldrev = oldrev - self.added = {} - self.renamed = {} - self.patched = [] - self.deleted = []