damned-lies r1466 - in trunk: . stats vertimus



Author: claudep
Date: Wed Mar  4 21:31:05 2009
New Revision: 1466
URL: http://svn.gnome.org/viewvc/damned-lies?rev=1466&view=rev

Log:
2009-03-04  Claude Paroz  <claude 2xlibre net>

	* stats/models.py: bugs_base and bugs_product may be null.
	commit_po takes a user argument so the commit can be attributed to the
	right person.
	* vertimus/models.py: New 'Submit to repository' action for modules which
	have write access.

Modified:
   trunk/ChangeLog
   trunk/stats/models.py
   trunk/vertimus/models.py

Modified: trunk/stats/models.py
==============================================================================
--- trunk/stats/models.py	(original)
+++ trunk/stats/models.py	Wed Mar  4 21:31:05 2009
@@ -51,8 +51,8 @@
     homepage = models.URLField(null=True, blank=True)
     description = models.TextField(null=True, blank=True)
     comment = models.TextField(null=True, blank=True)
-    bugs_base = models.CharField(max_length=50)
-    bugs_product = models.CharField(max_length=50)
+    bugs_base = models.CharField(max_length=50, null=True, blank=True)
+    bugs_product = models.CharField(max_length=50, null=True, blank=True)
     bugs_component = models.CharField(max_length=50, null=True, blank=True)
     vcs_type = models.CharField(max_length=5, choices=VCS_TYPE_CHOICES)
     # URLField is too restrictive for vcs_root
@@ -492,7 +492,7 @@
             self.checkout_lock.release()
         return 1
 
-    def commit_po(self, po_file, domain, language):
+    def commit_po(self, po_file, domain, language, user):
         """ Commit the file 'po_file' in the branch VCS repository """
         if self.is_vcs_readonly():
             raise Exception, "This branch is in read-only mode. Unable to commit"
@@ -541,10 +541,12 @@
                 commit_message = "Updated %s translation." % language.name
             # FIXME: edit changelog?
             # git commit -m "Updated %s translation."
-            utils.run_shell_command("cd \"%(dest)s\" && git checkout %(branch)s && git commit -m \"%(msg)s\"" % {
+            utils.run_shell_command("cd \"%(dest)s\" && git checkout %(branch)s && git commit -m \"%(msg)s\" --author \"%(name)s <%(email)s>\"" % {
                        'dest':    commit_dir,
                        'branch':  self.name,
                        'msg': commit_message,
+                       'name': user.name,
+                       'email': user.email,
                        }, raise_on_error=True)
             # git push
             utils.run_shell_command("cd \"%(dest)s\" && git checkout %(branch)s && git push" % {
@@ -552,6 +554,8 @@
                        'branch':  self.name,
                        'msg': commit_message,
                        }, raise_on_error=True)
+        # Finish by updating stats
+        self.update_stats(force=False)
 
 
 DOMAIN_TYPE_CHOICES = (

Modified: trunk/vertimus/models.py
==============================================================================
--- trunk/vertimus/models.py	(original)
+++ trunk/vertimus/models.py	Wed Mar  4 21:31:05 2009
@@ -18,7 +18,7 @@
 # along with Damned Lies; if not, write to the Free Software Foundation, Inc.,
 # 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
-import os
+import os, sys
 
 from datetime import datetime
 from django.db import models
@@ -199,6 +199,8 @@
             action_names = ['TC', 'RP', 'TR']
         else:
             action_names = []
+        if not self.branch.is_vcs_readonly() and person.is_committer(self.language.team):
+            action_names.insert(1, 'CI')
 
         return self._get_available_actions(person, action_names)
 
@@ -222,6 +224,8 @@
     def get_available_actions(self, person):
         if person.is_committer(self.language.team):
             action_names = ['RC', 'TR']
+            if not self.branch.is_vcs_readonly():
+                action_names.insert(1, 'CI')
         else:
             action_names = []
             
@@ -263,7 +267,7 @@
     'WC',
     'RT', 'UT',
     'RP', 'UP',
-    'TC', 'RC',
+    'TC', 'CI', 'RC',
     'IC', 'TR',
     'BA', 'UNDO')
 
@@ -593,6 +597,29 @@
         self.send_mail_new_state(state, new_state, committers)
         return new_state
 
+class ActionCI(ActionAbstract):
+    name = 'CI'
+    description = _('Submit to repository')
+    file_is_prohibited = True
+    
+    def _new_state(self):
+        return StateCommitted()
+    
+    def apply(self, state, person, comment=None, file=None):
+        self.save_action_db(state, person, comment, file)
+        action_with_po = self.get_previous_action_with_po()
+        try:
+            state.branch.commit_po(action_with_po.file.path, state.domain, state.language, person)            
+            new_state = self._new_state()
+        except:
+            # Commit failed, state unchanged
+            person.message_set.create(message=_("The commit failed. The error was: '%s'") % sys.exc_info()[1])
+            self._action_db.delete()
+            new_state = state 
+        if state != new_state:
+            self.send_mail_new_state(state, new_state, (state.language.team.mailing_list,))
+        return new_state
+
 class ActionRC(ActionAbstract):
     name = 'RC'
     # Translators: this indicates a committer is going to commit the file in the repository
@@ -726,7 +753,7 @@
                                       state_db__domain=kwargs['domain'],
                                       file__endswith=".po")
     for action in actions:
-        action.merge_file_with_pot(potfile=kwargs['potfile'])
+        action.merge_file_with_pot(kwargs['potfile'])
 pot_has_changed.connect(update_uploaded_files)
 
 def merge_uploaded_file(sender, instance, **kwargs):



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]