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

Ross Lagerwall rosslagerwall at gmail.com
Wed Aug 1 02:50:38 CDT 2012


# 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/'
 
         # 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)
             node, tag = line.split(None, 1)
             if not tag.startswith(prefix):
                 continue


More information about the Mercurial-devel mailing list