971a3a6e1df9

Only create a .exists file when we add comment or signoff
[view raw] [browse files]
author Benoit Allard <benoit@aeteurope.nl>
date Fri, 20 Aug 2010 16:29:35 +0200
parents 5a30d0a6ca83
children 48541d29e527
branches/tags (none)
files review/api.py

Changes

--- 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)