# # # patch "tracvc/mtn/automate.py" # from [8fc528706d3090c199eb3acd578c62e398ca161b] # to [f68419b8a6d34829c44c017fbb7f440b65531d3c] # # patch "tracvc/mtn/backend.py" # from [30e62c11bf7539ff1af2f7d333e9282e217e6e70] # to [f439fb155ad89c24203b0b8cd073d347816c76a2] # ============================================================ --- tracvc/mtn/automate.py 8fc528706d3090c199eb3acd578c62e398ca161b +++ tracvc/mtn/automate.py f68419b8a6d34829c44c017fbb7f440b65531d3c @@ -215,7 +215,7 @@ elif key == 'attr': attrs[value[0]] = value[1] elif key == 'file' or key == 'dir': - path = '/' + (value or '') + path = '/' + value kind = key if path: manifest[path] = (kind, content, attrs) self.manifest_cache[rev] = manifest @@ -268,13 +268,20 @@ if status == 0: return result def changeset(self, rev): - """Returns a changeset dictionary processed to be consumed by Trac.""" + """ + Fetches and pre-processes a changeset. + + The changeset is a dictionary oldrev->changes, with changes + itself being a dictionary newpath->(type, change, + oldpath). type is 'file' or 'dir' or None + (i.e. unknown/irrelevant), and change can be 'add', 'move' or + 'edit'. Deletions are put in a list for newpath==None. + """ if rev in self.changeset_cache: return self.changeset_cache[rev] status, result = self.automate.command("get_revision", rev) if status != 0: return [] changeset = {} - changeset[None] = {} def add_slash(path): return '/' + path @@ -286,13 +293,14 @@ renames, changeset[oldrev] = {}, {} elif entry.has_key('add_dir'): path = add_slash(entry['add_dir']) - changeset[None][path] = ('dir', 'add', None) + changeset[oldrev][path] = ('dir', 'add', None) elif entry.has_key('add_file'): path = add_slash(entry['add_file']) - changeset[None][path] = ('file', 'add', None) + changeset[oldrev][path] = ('file', 'add', None) elif entry.has_key('delete'): path = add_slash(entry['delete']) - changeset[oldrev][None] = (None, 'delete', path) + # deletes are simply listed + changeset[oldrev].setdefault(None, []).append(path) elif entry.has_key('rename'): oldpath = add_slash(entry['rename']) newpath = add_slash(entry['to']) @@ -308,8 +316,7 @@ changeset[oldrev][path] = ('file', 'edit', path) # fixme: what about 'set' and 'clear'? These are edits, # but not if applied to new files. - if not changeset[None]: - del changeset[None] + self.changeset_cache[rev] = changeset return changeset ============================================================ --- tracvc/mtn/backend.py 30e62c11bf7539ff1af2f7d333e9282e217e6e70 +++ tracvc/mtn/backend.py f439fb155ad89c24203b0b8cd073d347816c76a2 @@ -341,14 +341,25 @@ Changeset.MOVE, and kind is one of Node.FILE or Node.DIRECTORY. """ changeset = self.mtn.changeset(self.rev) - for oldrev in changeset: + oldrevs = changeset.keys() + oldrevs.sort() + for oldrev in oldrevs: changes = changeset[oldrev] - for path in changes: - kind, change, opath = changes[path] - if change == 'edit' and path != opath: - # extra entry for the move itself - yield path, kind, 'move', opath, oldrev - yield path, kind, change, opath, oldrev + paths = changes.keys() + paths.sort() + for path in paths: + if path == None: + # deletions + oldpaths = changes[None] + oldpaths.sort() + for oldpath in oldpaths: + yield None, None, 'delete', oldpath, oldrev + else: + kind, change, oldpath = changes[path] + if change == 'edit' and path != oldpath: + # extra entry for the move itself + yield path, kind, 'move', oldpath, oldrev + yield path, kind, change, oldpath, oldrev def get_properties(self): """Generator that provides additional metadata for this changeset.