Re: [translate-pootle] [PATCH] Support for the Mercurial version control system

2008-03-27 Thread Lars Kruse
Hi Miklos!

> i would recommend using hg clone , that will make hg push work
> without any additional url. (and Pootle uses this feature)

ok - nice to know!


I uploaded your combined patches to the trunk repository as r7106.

Now there are already six supported versioncontrol systems - great!

Lars

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
Translate-pootle mailing list
Translate-pootle@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/translate-pootle


Re: [translate-pootle] [PATCH] Support for the Mercurial version control system

2008-03-27 Thread Miklos Vajna
On Thu, Mar 27, 2008 at 06:25:51AM +0100, Lars Kruse <[EMAIL PROTECTED]> wrote:
> I am not used to mercurial, so I just downloaded a mercurial repository as an
> example:
>  hg init test
>  cd test
>  hg pull http://selenic.com/repo/hg-stable
>  hg update

i would recommend using hg clone , that will make hg push work
without any additional url. (and Pootle uses this feature)

> Then I switched to the translate directory and tested the "getcleanfile"
> function:
>  python storage/versioncontrol/__init__.py SOME_DIR/test/mercurial/repo.py
> 
> The resulting error message was: 
>  abort: mercurial/repo.py not under root
> 
> This problem seems to be fixed after replacing "self.location_rel" with
> "self.location_abs" in "getcleanfile" in "hg.py".
> 
> So I guess, that mercurial needs the absolute file location (in contrast to 
> git
> and darcs). But I could not verify this for the "update" and the "commit"
> function in "hg.py", since I don't have a real repository for testing.
> 
> Could you check, if everything works after replacing the two
> occurrences of "location_rel" with "location_abs"?

just checked, hg always requires an absolute pathname. i did not notice
this as the repo was inside the pootle dir. fortunatelly it's
consistent, so i've fixed update() as well.

> I noticed another thing while going through the code: in "commit" the location
> of the specific file is not used. I guess, this results in a commit of the
> complete local working copy, or? This behaviour would be different from the
> other interfaces (svn, cvs, ...) .Could you check that, too, please?

oh, my bad. sure, it was a shortcoming on my side, fixed.

patch - against my previous one - attached.
diff --git a/translate/storage/versioncontrol/hg.py 
b/translate/storage/versioncontrol/hg.py
index 639f91e..d73f7e8 100644
--- a/translate/storage/versioncontrol/hg.py
+++ b/translate/storage/versioncontrol/hg.py
@@ -36,7 +36,7 @@ class hg(GenericRevisionControlSystem):
 """
 # revert local changes (avoids conflicts)
 command = ["hg", "-R", self.root_dir, "revert",
-"--all", self.location_rel]
+"--all", self.location_abs]
 exitcode, output_revert, error = run_command(command)
 if exitcode != 0:
 raise IOError("[Mercurial] error running '%s': %s" % (command, 
error))
@@ -57,7 +57,8 @@ class hg(GenericRevisionControlSystem):
 if message is None:
 message = ""
 # commit changes
-command = ["hg", "-R", self.root_dir, "commit", "-m", message]
+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" \
@@ -74,7 +75,7 @@ class hg(GenericRevisionControlSystem):
 """Get a clean version of a file from the hg repository"""
 # run hg cat
 command = ["hg", "-R", self.root_dir, "cat",
-self.location_rel]
+self.location_abs]
 exitcode, output, error = run_command(command)
 if exitcode != 0:
 raise IOError("[Mercurial] Error running '%s': %s" \


pgpYrR6k7QPia.pgp
Description: PGP signature
-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace___
Translate-pootle mailing list
Translate-pootle@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/translate-pootle


Re: [translate-pootle] [PATCH] Support for the Mercurial version control system

2008-03-26 Thread Lars Kruse
Hi Miklos,

> i think the only popular vcs today that is unsupported by Pootle is hg.
> so i've made a patch to add support for it :)

that is great!


> patch attached, any feedback is appreciated.

The code itself looks fine to me.

I am not used to mercurial, so I just downloaded a mercurial repository as an
example:
 hg init test
 cd test
 hg pull http://selenic.com/repo/hg-stable
 hg update

Then I switched to the translate directory and tested the "getcleanfile"
function:
 python storage/versioncontrol/__init__.py SOME_DIR/test/mercurial/repo.py

The resulting error message was: 
 abort: mercurial/repo.py not under root

This problem seems to be fixed after replacing "self.location_rel" with
"self.location_abs" in "getcleanfile" in "hg.py".

So I guess, that mercurial needs the absolute file location (in contrast to git
and darcs). But I could not verify this for the "update" and the "commit"
function in "hg.py", since I don't have a real repository for testing.

Could you check, if everything works after replacing the two
occurrences of "location_rel" with "location_abs"?

I noticed another thing while going through the code: in "commit" the location
of the specific file is not used. I guess, this results in a commit of the
complete local working copy, or? This behaviour would be different from the
other interfaces (svn, cvs, ...) .Could you check that, too, please?

It feels great to see the number of supported systems growing!

regards,
Lars

-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
Translate-pootle mailing list
Translate-pootle@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/translate-pootle


Re: [translate-pootle] [PATCH] Support for the Mercurial version control system

2008-03-26 Thread F Wolff
Op Woensdag 2008-03-26 skryf Miklos Vajna:
> hi,
> 
> i think the only popular vcs today that is unsupported by Pootle is hg.
> so i've made a patch to add support for it :)
> 
> patch attached, any feedback is appreciated.

Hallo Miklos

Great! With Mercurial, I think we cover almost everything that is
important! I have already built the next release of the toolkit, so this
will have to go into the next version, but if Lars is happy, we can
commit this straight after the release (in fact I think he already
reviewed it).

Thanks again!
Friedel


-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
___
Translate-pootle mailing list
Translate-pootle@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/translate-pootle


Re: [translate-pootle] [PATCH] Support for the Mercurial version control system

2008-03-25 Thread Miklos Vajna
On Wed, Mar 26, 2008 at 02:19:59AM +0100, Miklos Vajna <[EMAIL PROTECTED]> 
wrote:
> +# Copyright 2004-2007 Zuza Software Foundation

oops, this should be 2008, i just copy&pasted the header from an other
file.


pgp3NMejkTttP.pgp
Description: PGP signature
-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace___
Translate-pootle mailing list
Translate-pootle@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/translate-pootle


[translate-pootle] [PATCH] Support for the Mercurial version control system

2008-03-25 Thread Miklos Vajna
hi,

i think the only popular vcs today that is unsupported by Pootle is hg.
so i've made a patch to add support for it :)

patch attached, any feedback is appreciated.
Support for the Mercurial version control system

---
 translate/storage/versioncontrol/__init__.py |2 +-
 translate/storage/versioncontrol/hg.py   |   83 ++
 2 files changed, 84 insertions(+), 1 deletions(-)
 create mode 100644 translate/storage/versioncontrol/hg.py

diff --git a/translate/storage/versioncontrol/__init__.py 
b/translate/storage/versioncontrol/__init__.py
index b249165..3403984 100644
--- a/translate/storage/versioncontrol/__init__.py
+++ b/translate/storage/versioncontrol/__init__.py
@@ -33,7 +33,7 @@ TODO:
 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
diff --git a/translate/storage/versioncontrol/hg.py 
b/translate/storage/versioncontrol/hg.py
new file mode 100644
index 000..639f91e
--- /dev/null
+++ b/translate/storage/versioncontrol/hg.py
@@ -0,0 +1,83 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# 
+# Copyright 2004-2007 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_rel]
+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]
+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_rel]
+exitcode, output, error = run_command(command)
+if exitcode != 0:
+raise IOError("[Mercurial] Error running '%s': %s" \
+% (command, error))
+return output
+


pgpCCYyOHlfBe.pgp
Description: PGP signature
-
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace_