# HG changeset patch # User Benoit Allard # Date 1282314575 -7200 # Node ID 971a3a6e1df95b59f03f8217f231efe8d667a51d # Parent 5a30d0a6ca8300fe0cd177191104d3a5a742a44f Only create a .exists file when we add comment or signoff diff -r 5a30d0a6ca83 -r 971a3a6e1df9 review/api.py --- a/review/api.py Wed Jul 28 15:48:43 2010 +0200 +++ b/review/api.py Fri Aug 20 16:29:35 2010 +0200 @@ -423,6 +423,16 @@ return ReviewSignoff(**data) + def _create_exists_entry(self): + path = os.path.join(self.repo.root, self.node) + os.mkdir(path) + with open(os.path.join(path, '.exists'), 'w') as e: + pass + + cmdutil.commit(self.ui, self.repo, _commitfunc, + [os.path.join(path, '.exists')], + { 'message': 'Initialize review data for changeset %s' % self.node, + 'addremove': True, }) def __init__(self, ui, repo, target, node): """Initialize a ReviewChangeset. @@ -455,16 +465,6 @@ self.comments = [] self.signoffs = [] - path = os.path.join(self.repo.root, self.node) - os.mkdir(path) - with open(os.path.join(path, '.exists'), 'w') as e: - pass - - cmdutil.commit(ui, self.repo, _commitfunc, - [os.path.join(path, '.exists')], - { 'message': 'Initialize review data for changeset %s' % self.node, - 'addremove': True, }) - def signoffs_for_user(self, username): return filter(lambda s: s.author == username, self.signoffs) @@ -486,6 +486,9 @@ if existing: raise SignoffExists + if not (self.comments or self.signoffs): + self._create_exists_entry() + signoff = ReviewSignoff(fromlocal(self.ui.username()), util.makedate(), self.node, opinion, message, style) signoff._commit(self.ui, self.repo) @@ -509,6 +512,9 @@ if filename and not ufilename: ufilename = fromlocal(filename) + if not (self.comments or self.signoffs): + self._create_exists_entry() + comment = ReviewComment(fromlocal(self.ui.username()), util.makedate(), self.node, ufilename, filename, map(int, lines), message, style) comment._commit(self.ui, self.repo)