On Sun, Jul 20, 2008 at 04:27:38PM +0200, Lars Kruse <[EMAIL PROTECTED]> wrote:
> > Second, this is on my TODO for a very long time. Given that now I see
> > that this may be useful for others as well, I'll give it a try. I don't
> > think it'll be hard to do.
> 
> great!

Here it is.

The status of the backends:

* cvs: ignore
* darcs: use darcs record --author
* bzr: use bzr commit --author
* hg: use hg commit --user
* git (and git_old): use git commit --author
* svn: ignore

Example:

$ git log -1
commit 8878fc7e5ca35e4d489be1c5ddaaf6cee108c0a1
Author: S T Artup <[EMAIL PROTECTED]>
Date:   Sun Jul 20 23:51:46 2008 +0200

    Commit from Pootle by user startup. 31 of 31 messages translated (0 fuzzy).
Index: Pootle/projects.py
===================================================================
--- Pootle/projects.py  (revision 7806)
+++ Pootle/projects.py  (working copy)
@@ -598,7 +598,8 @@
     statsstring = "%d of %d messages translated (%d fuzzy)." % \
         (stats["translated"], stats["total"], stats["fuzzy"])
     versioncontrol.commitfile(pathname, message="Commit from %s by user %s. 
%s" % 
-        (session.server.instance.title, session.username, statsstring))
+        (session.server.instance.title, session.username, statsstring),
+        author="%s <%s>" % (session.prefs.name, session.prefs.email))
 
   def converttemplates(self, session):
     """creates PO files from the templates"""
Index: translate/storage/versioncontrol/cvs.py
===================================================================
--- translate/storage/versioncontrol/cvs.py     (revision 7806)
+++ translate/storage/versioncontrol/cvs.py     (working copy)
@@ -126,7 +126,7 @@
         else:
             return output
 
-    def commit(self, message=None):
+    def commit(self, message=None, author=None):
         """Commits the file and supplies the given commit message if present"""
         working_dir = os.path.dirname(self.location_abs)
         filename = os.path.basename(self.location_abs)
Index: translate/storage/versioncontrol/darcs.py
===================================================================
--- translate/storage/versioncontrol/darcs.py   (revision 7806)
+++ translate/storage/versioncontrol/darcs.py   (working copy)
@@ -54,13 +54,14 @@
             raise IOError("[Darcs] error running '%s': %s" % (command, error))
         return output_revert + output_pull
 
-    def commit(self, message=None):
+    def commit(self, message=None, author=None):
         """Commits the file and supplies the given commit message if present"""
         if message is None:
             message = ""
         # set change message
         command = ["darcs", "record", "-a", "--repodir", self.root_dir,
-                "--skip-long-comment", "-m", message, self.location_rel]
+                "--skip-long-comment", "-m", message,
+                "--author", author, self.location_rel]
         exitcode, output_record, error = run_command(command)
         if exitcode != 0:
             raise IOError("[Darcs] Error running darcs command '%s': %s" \
Index: translate/storage/versioncontrol/bzr.py
===================================================================
--- translate/storage/versioncontrol/bzr.py     (revision 7806)
+++ translate/storage/versioncontrol/bzr.py     (working copy)
@@ -53,12 +53,14 @@
                     % (self.location_abs, error))
         return output_revert + output_pull
 
-    def commit(self, message=None):
+    def commit(self, message=None, author=None):
         """Commits the file and supplies the given commit message if present"""
         # bzr commit
         command = ["bzr", "commit"]
         if message:
             command.extend(["-m", message])
+        if author:
+            command.extend(["--author", author])
         # the filename is the last argument
         command.append(self.location_abs)
         exitcode, output_commit, error = run_command(command)
Index: translate/storage/versioncontrol/hg.py
===================================================================
--- translate/storage/versioncontrol/hg.py      (revision 7806)
+++ translate/storage/versioncontrol/hg.py      (working copy)
@@ -59,13 +59,13 @@
             raise IOError("[Mercurial] error running '%s': %s" % (command, 
error))
         return output_revert + output_pull + output_update
 
-    def commit(self, message=None):
+    def commit(self, message=None, author=None):
         """Commits the file and supplies the given commit message if present"""
         if message is None:
             message = ""
         # commit changes
         command = ["hg", "-R", self.root_dir, "commit", "-m", message,
-                self.location_abs]
+                "--user", author, self.location_abs]
         exitcode, output_commit, error = run_command(command)
         if exitcode != 0:
             raise IOError("[Mercurial] Error running '%s': %s" \
Index: translate/storage/versioncontrol/__init__.py
===================================================================
--- translate/storage/versioncontrol/__init__.py        (revision 7806)
+++ translate/storage/versioncontrol/__init__.py        (working copy)
@@ -243,7 +243,7 @@
                 + " 'getcleanfile' is missing")
 
 
-    def commit(self, revision=None):
+    def commit(self, revision=None, author=None):
         """Dummy to be overridden by real implementations"""
         raise NotImplementedError("Incomplete RCS interface implementation:" \
                 + " 'commit' is missing")
@@ -319,10 +319,10 @@
 def getcleanfile(filename, revision=None):
     return get_versioned_object(filename).getcleanfile(revision)
 
-def commitfile(filename, message=None):
-    return get_versioned_object(filename).commit(message)
+def commitfile(filename, message=None, author=None):
+    return get_versioned_object(filename).commit(message, author)
 
-def commitdirectory(directory, message=None):
+def commitdirectory(directory, message=None, author=None):
     """commit all files below the given directory
 
     files that are just symlinked into the directory are supported, too
@@ -330,7 +330,7 @@
     # for now all files are committed separately
     # should we combine them into one commit?
     for rcs_obj in get_versioned_objects_recursive(directory):
-        rcs_obj.commit(message)
+        rcs_obj.commit(message, author)
 
 def updatedirectory(directory):
     """update all files below the given directory
Index: translate/storage/versioncontrol/git_old.py
===================================================================
--- translate/storage/versioncontrol/git_old.py (revision 7806)
+++ translate/storage/versioncontrol/git_old.py (working copy)
@@ -114,7 +114,7 @@
             raise IOError("[GIT] pull failed (%s): %s" % (command, error))
         return output_checkout + output_pull
 
-    def commit(self, message=None):
+    def commit(self, message=None, author=None):
         """Commits the file and supplies the given commit message if present"""
         working_dir = os.path.dirname(self.location_abs)
         original_dir = os.getcwd()
@@ -147,6 +147,8 @@
         command = self._get_git_command(["commit"])
         if message:
             command.extend(["-m", message])
+        if author:
+            command.extend(["--author", author])
         exitcode, output_commit, error = run_command(command)
         if exitcode != 0:
             # something went wrong - go back to the original directory
Index: translate/storage/versioncontrol/git.py
===================================================================
--- translate/storage/versioncontrol/git.py     (revision 7806)
+++ translate/storage/versioncontrol/git.py     (working copy)
@@ -82,7 +82,7 @@
             raise IOError("[GIT] pull failed (%s): %s" % (command, error))
         return output_checkout + output_pull
 
-    def commit(self, message=None):
+    def commit(self, message=None, author=None):
         """Commits the file and supplies the given commit message if present"""
         # add the file
         command = self._get_git_command(["add", self.location_rel])
@@ -94,6 +94,8 @@
         command = self._get_git_command(["commit"])
         if message:
             command.extend(["-m", message])
+        if message:
+            command.extend(["--author", author])
         exitcode, output_commit, error = run_command(command)
         if exitcode != 0:
             if len(error):
Index: translate/storage/versioncontrol/svn.py
===================================================================
--- translate/storage/versioncontrol/svn.py     (revision 7806)
+++ translate/storage/versioncontrol/svn.py     (working copy)
@@ -57,7 +57,7 @@
                     % (command, error))
         return output_revert + output_update
 
-    def commit(self, message=None):
+    def commit(self, message=None, author):
         """commit the file and return the given message if present"""
         command = ["svn", "-q", "--non-interactive", "commit"]
         if message:

Attachment: pgpKOhOuzKZ86.pgp
Description: PGP signature

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Translate-pootle mailing list
Translate-pootle@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/translate-pootle

Reply via email to