[PATCH stable-v2] convert: fix a test failure due to git change (issue3428)

Ross Lagerwall rosslagerwall at gmail.com
Fri Aug 3 08:07:16 CDT 2012


On 08/03/2012 12:54 AM, Mads Kiilerich wrote:
> Ross Lagerwall wrote, On 08/01/2012 06:44 PM:
>> # HG changeset patch
>> # User Ross Lagerwall <rosslagerwall at gmail.com>
>> # Date 1343838158 -7200
>> # Branch stable
>> # Node ID 8df5a0dfab4cde5e936b63d631842becb989ce1f
>> # Parent  3ccb49ed1cc13cf71cd780e998f200ed974ec271
>> convert: fix a test failure due to git change (issue3428)
> 
> If I understand it correctly this could be seen as doing 3 things:
> 
> 1: make the test deterministic, avoid randomly hitting the case that fails:

Yes.
> 
>> --- a/tests/test-convert-git.t
>> +++ b/tests/test-convert-git.t
>> @@ -281,20 +281,32 @@
>>     abort: --sourcesort is not supported by this data source
>>     [255]
>>   -damage git repository and convert again
>> +damaged git repository tests:
>> +In case the hard-coded hashes change, the following commands can be
>> used to
>> +list the hashes and their corresponding types in the repository:
>> +cd git-repo4/.git/objects
>> +find . -type f | cut -c 3- | sed 's_/__' | xargs -n 1 -t git cat-file -t
>> +cd ../../..
>>   -  $ cat > damage.py <<EOF
>> -  > import os
>> -  > import stat
>> -  > for root, dirs, files in os.walk('git-repo4/.git/objects'):
>> -  >     if files:
>> -  >         path = os.path.join(root, files[0])
>> -  >         if os.name == 'nt':
>> -  >             os.chmod(path, stat.S_IWUSR)
>> -  >         os.remove(path)
>> -  >         break
>> -  > EOF
>> -  $ python damage.py
>> -  $ hg convert git-repo4 git-repo4-broken-hg 2>&1 | \
>> -  >     grep 'abort:' | sed 's/abort:.*/abort:/g'
>> -  abort:
>> +damage git repository by renaming a blob object
>> +
>> +  $ BLOB_OBJ=8b/137891791fe96927ad78e64b0aad7bded08bdc
>> +  $ mv git-repo4/.git/objects/$BLOB_OBJ
>> git-repo4/.git/objects/$BLOB_OBJ.tmp
>> +  $ hg convert git-repo4 git-repo4-broken-hg 2>&1 | grep 'abort:'
>> +  abort: cannot read 'blob' object at
>> 8b137891791fe96927ad78e64b0aad7bded08bdc
>> +  $ mv git-repo4/.git/objects/$BLOB_OBJ.tmp
>> git-repo4/.git/objects/$BLOB_OBJ
>> +
> 
>> +damage git repository by renaming a tree object
>> +
>> +  $ TREE_OBJ=72/49f083d2a63a41cc737764a86981eb5f3e4635
>> +  $ mv git-repo4/.git/objects/$TREE_OBJ
>> git-repo4/.git/objects/$TREE_OBJ.tmp
>> +  $ hg convert git-repo4 git-repo4-broken-hg 2>&1 | grep 'abort:'
>> +  abort: cannot read changes in 1c0ce3c5886f83a1d78a7b517cdff5cf9ca17bdd
> 
> 2: reintroduce the test case that was hit randomly and would fail with
> some git versions ... but fix the failure ... at least on linux:

To fix the failure, stderr needs to be processed, so it's difficult to
fix it without putting in a shell hack like '2>&1' in the command string
or doing it properly and re-working the process creation.

In other words, this part doesn't work without the subprocess changes.
> 
>>           # 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
> 
>> +damage git repository by renaming a commit object
>> +
>> +  $ COMMIT_OBJ=1c/0ce3c5886f83a1d78a7b517cdff5cf9ca17bdd
>> +  $ mv git-repo4/.git/objects/$COMMIT_OBJ
>> git-repo4/.git/objects/$COMMIT_OBJ.tmp
>> +  $ hg convert git-repo4 git-repo4-broken-hg 2>&1 | grep 'abort:'
>> +  abort: cannot read tags from git-repo4/.git
>> +  $ mv git-repo4/.git/objects/$COMMIT_OBJ.tmp
>> git-repo4/.git/objects/$COMMIT_OBJ
>> +
> 
> 3: the rest ;-)
> 
> I guess 1 and 2 would have been included in 2.3 if split up that way ...
> and now they are obvious candidates for 2.3.1 . The remaining subprocess
> changes might need some further discussion and perhaps should wait for 2.4.
> 
> My comment:
> 1: we have some subprocess / popen abstractions in util
> 2: we regularly have issues with the places that don't use these
> abstractions
> 3: ...
> 
I think this could be done by using util.popen3 and processing the
stderr in a separate loop. This is probably safe enough to go into 2.3.1.

I don't think it would be useful to make some of the changes in 2.3.1
and some in 2.4 if *all* of them are required to make the test suite run
correctly on all platforms.

Regards
-- 
Ross Lagerwall

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 294 bytes
Desc: OpenPGP digital signature
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20120803/03f6612d/attachment.pgp>


More information about the Mercurial-devel mailing list