[PATCH 2 of 2 stable] convert: fix a test failure due to git change

Patrick Mézard patrick at mezard.eu
Wed Aug 1 06:52:35 CDT 2012


Le 01/08/12 09:50, Ross Lagerwall a écrit :
> # HG changeset patch
> # User Ross Lagerwall <rosslagerwall at gmail.com>
> # Date 1343668628 -7200
> # Branch stable
> # Node ID 95e11c7342effe59f7e95a7e84ddc21d0cfd34c6
> # Parent  c9b9d555c54b1a62dea5f6582294987282bb775b
> convert: fix a test failure due to git change
> 
> Since git v1.7.8.2-327-g926f1dd (the change was first released in
> git 1.7.10), git does not return non-zero when
> "git ls-remote --tags ..." is run and the repository is damaged.
> This causes the "damaged repository with missing commit" test in
> test-convert-git.t to unexpectedly succeed.
> 
> Fix this by aborting if git outputs any lines beginning with "error:".
> 
> diff --git a/hgext/convert/git.py b/hgext/convert/git.py
> --- a/hgext/convert/git.py
> +++ b/hgext/convert/git.py
> @@ -146,12 +146,14 @@
>      def gettags(self):
>          tags = {}
>          alltags = {}
> -        fh = self.gitopen('git ls-remote --tags "%s"' % self.path)
> +        fh = self.gitopen('git ls-remote --tags "%s" 2>&1' % self.path)
>          prefix = 'refs/tags/'

Unfortunately, it does not seem to work on Windows with msys git and python 2.6. My current theory is subprocess.Popen() messes up with the command-line when trying to escape things, I have a vague recollection of something similar happening when I wrote pysh. The git ls-remote call gives the expected output when run directly in a shell, so that is definitely a redirection issue.

Your patches go in the right direction. I agree with Mads they should be folded. Adding short comments to the test to tell how you list the commit/blob/tag objects (command line call is fine) would help us maintaining the whole thing without having to deal with git internal details.

I suggest we converge on your patchset first, and once it is ready I would try to refactor convert/git.py to use subprocess directly so the redirection works correctly.

--
Patrick Mézard



More information about the Mercurial-devel mailing list