From: <sum...@us...> - 2008-03-28 03:10:23
|
Revision: 7106 http://translate.svn.sourceforge.net/translate/?rev=7106&view=rev Author: sumpfralle Date: 2008-03-27 20:10:24 -0700 (Thu, 27 Mar 2008) Log Message: ----------- added mercurial (hg) versioncontrol support (contributed by Miklos Vajna) Modified Paths: -------------- src/trunk/translate/storage/versioncontrol/__init__.py Added Paths: ----------- src/trunk/translate/storage/versioncontrol/hg.py Modified: src/trunk/translate/storage/versioncontrol/__init__.py =================================================================== --- src/trunk/translate/storage/versioncontrol/__init__.py 2008-03-27 13:04:00 UTC (rev 7105) +++ src/trunk/translate/storage/versioncontrol/__init__.py 2008-03-28 03:10:24 UTC (rev 7106) @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- # -# Copyright 2004-2007 Zuza Software Foundation +# Copyright 2004-2008 Zuza Software Foundation # # This file is part of translate. # @@ -33,7 +33,7 @@ import re import os -DEFAULT_RCS = ["svn", "cvs", "darcs", "git", "bzr"] +DEFAULT_RCS = ["svn", "cvs", "darcs", "git", "bzr", "hg"] """the names of all supported revision control systems modules of the same name containing a class with the same name are expected Added: src/trunk/translate/storage/versioncontrol/hg.py =================================================================== --- src/trunk/translate/storage/versioncontrol/hg.py (rev 0) +++ src/trunk/translate/storage/versioncontrol/hg.py 2008-03-28 03:10:24 UTC (rev 7106) @@ -0,0 +1,84 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# Copyright 2004-2008 Zuza Software Foundation +# +# This file is part of translate. +# +# translate is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# translate is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with translate; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + + +from translate.storage.versioncontrol import run_command +from translate.storage.versioncontrol import GenericRevisionControlSystem + +class hg(GenericRevisionControlSystem): + """Class to manage items under revision control of mercurial.""" + + RCS_METADIR = ".hg" + SCAN_PARENTS = True + + def update(self, revision=None): + """Does a clean update of the given path + + @param revision: ignored for hg + """ + # revert local changes (avoids conflicts) + command = ["hg", "-R", self.root_dir, "revert", + "--all", self.location_abs] + exitcode, output_revert, error = run_command(command) + if exitcode != 0: + raise IOError("[Mercurial] error running '%s': %s" % (command, error)) + # pull new patches + command = ["hg", "-R", self.root_dir, "pull"] + exitcode, output_pull, error = run_command(command) + if exitcode != 0: + raise IOError("[Mercurial] error running '%s': %s" % (command, error)) + # update working directory + command = ["hg", "-R", self.root_dir, "update"] + exitcode, output_update, error = run_command(command) + if exitcode != 0: + raise IOError("[Mercurial] error running '%s': %s" % (command, error)) + return output_revert + output_pull + output_update + + def commit(self, message=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] + exitcode, output_commit, error = run_command(command) + if exitcode != 0: + raise IOError("[Mercurial] Error running '%s': %s" \ + % (command, error)) + # push changes + command = ["hg", "-R", self.root_dir, "push"] + exitcode, output_push, error = run_command(command) + if exitcode != 0: + raise IOError("[Mercurial] Error running '%s': %s" \ + % (command, error)) + return output_commit + output_push + + def getcleanfile(self, revision=None): + """Get a clean version of a file from the hg repository""" + # run hg cat + command = ["hg", "-R", self.root_dir, "cat", + self.location_abs] + exitcode, output, error = run_command(command) + if exitcode != 0: + raise IOError("[Mercurial] Error running '%s': %s" \ + % (command, error)) + return output + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |