# HG changeset patch # User Christophe de Vienne # Date 1414446030 -3600 # Node ID 9ee9ef21460ca6bdc203ab2e87e5ab5fec5e8c3b # Parent 3c3734c184d9e41787ede241c22d370e44fa0caa ReviewChangeset loads precursors comments diff -r 3c3734c184d9 -r 9ee9ef21460c review/api.py --- a/review/api.py Mon Oct 27 22:38:16 2014 +0100 +++ b/review/api.py Mon Oct 27 22:40:30 2014 +0100 @@ -9,6 +9,7 @@ from mercurial.node import hex from mercurial import ui as _ui from mercurial import demandimport +from mercurial import obsolete demandimport.ignore.append('json') try: @@ -454,22 +455,31 @@ self.target = target self.ui = ui self.node = node - - if '%s/.exists' % self.node in self.repo['tip']: - _match = lambda p: lambda fn: fn.startswith(p) + self.allnodes = [ + hex(n) for n in obsolete.allprecursors( + target.obsstore, (self.node.decode('hex'),)) + ] - relevant = filter(_match(node), self.repo['tip']) - commentfns = filter(_match('%s/comments' % node), relevant) - signofffns = filter(_match('%s/signoffs' % node), relevant) + self.comments = [] + self.signoffs = [] + + _match = lambda p: lambda fn: fn.startswith(p) + + for node in self.allnodes: + if '%s/.exists' % node in self.repo['tip']: - self.comments = [self._load_comment_file(fn) for fn in commentfns] - self.comments.sort(key=operator.attrgetter('local_datetime')) + relevant = filter(_match(node), self.repo['tip']) + commentfns = filter(_match('%s/comments' % node), relevant) + signofffns = filter(_match('%s/signoffs' % node), relevant) - self.signoffs = [self._load_signoff_file(fn) for fn in signofffns] - self.signoffs.sort(key=operator.attrgetter('local_datetime')) - else: - self.comments = [] - self.signoffs = [] + self.comments.extend( + [self._load_comment_file(fn) for fn in commentfns]) + + self.signoffs.extend( + [self._load_signoff_file(fn) for fn in signofffns]) + + self.comments.sort(key=operator.attrgetter('local_datetime')) + self.signoffs.sort(key=operator.attrgetter('local_datetime')) def signoffs_for_user(self, username): return filter(lambda s: s.author == username, self.signoffs) @@ -492,8 +502,7 @@ if existing: raise SignoffExists - if not (self.comments or self.signoffs): - self._create_exists_entry() + self._create_exists_entry() signoff = ReviewSignoff(fromlocal(self.ui.username()), util.makedate(), self.node, opinion, message, style) @@ -518,8 +527,7 @@ if filename and not ufilename: ufilename = fromlocal(filename) - if not (self.comments or self.signoffs): - self._create_exists_entry() + self._create_exists_entry() comment = ReviewComment(fromlocal(self.ui.username()), util.makedate(), self.node, ufilename, filename, map(int, lines), message, style)