[PATCH 2 of 2 stable] convert: fix a test failure due to git change
Mads Kiilerich
mads at kiilerich.com
Wed Aug 1 10:04:02 UTC 2012
On 01/08/12 09:50, Ross Lagerwall wrote:
> # 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.
Will this fix one of the tests you introduced in the previous patch?
If so: That test should be added in this patch instead. We don't want
intermediate states where the test suite is failing.
If not: Please add another test.
> 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/'
>
> # Build complete list of tags, both annotated and bare ones
> for line in fh:
> line = line.strip()
> + if line.startswith("error:"):
> + raise util.Abort(_('cannot read tags from %s') % self.path)
Hmm. Duplicating an error message already found a few lines later. Not
so pretty. But it seems like a more elegant solution would be less
elegant ;-)
> node, tag = line.split(None, 1)
> if not tag.startswith(prefix):
> continue
> alltags[tag[len(prefix):]] = node
> if fh.close():
> raise util.Abort(_('cannot read tags from %s') % self.path)
/Mads
More information about the Mercurial-devel
mailing list