iSabanin/mercurial-ruby — pull request #1 by potatosalad (2012-02-21 20:09:23+00:00)
Title: Ignore mercurial warnings printed to stderr as long as the exitstatus is 0

An error should only be raised if the process exited irregularly (non-zero).

Here's the example case I ran into:

```bash
$ hg id https://bitbucket.org/django/django
warning: bitbucket.org certificate with fingerprint 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b not verified (check hostfingerprints or web.cacerts config setting)
warning: bitbucket.org certificate with fingerprint 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b not verified (check hostfingerprints or web.cacerts config setting)
warning: bitbucket.org certificate with fingerprint 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b not verified (check hostfingerprints or web.cacerts config setting)
warning: bitbucket.org certificate with fingerprint 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b not verified (check hostfingerprints or web.cacerts config setting)
f96430a396e1
$ echo $?
0
```

Technically this command was successful, but when running it from the gem...

```ruby
>> Mercurial::Shell.run(["id ?", "https://bitbucket.org/django/django"], append_hg: true)
Mercurial::CommandError: warning: bitbucket.org certificate with fingerprint 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b not verified (check hostfingerprints or web.cacerts config setting)
warning: bitbucket.org certificate with fingerprint 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b not verified (check hostfingerprints or web.cacerts config setting)
warning: bitbucket.org certificate with fingerprint 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b not verified (check hostfingerprints or web.cacerts config setting)
warning: bitbucket.org certificate with fingerprint 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b not verified (check hostfingerprints or web.cacerts config setting)
from ~/.rvm/gems/ruby-1.9.3-p125/gems/mercurial-ruby-0.6.1/lib/mercurial-ruby/command.rb:69:in `raise_error_if_needed'
```

This pull request allows the previous command to run as expected...

```ruby
>> Mercurial::Shell.run(["id ?", "https://bitbucket.org/django/django"], append_hg: true)
=> "f96430a396e1\n"
```

...while still throwing a ruby exception if the exitstatus is not 0

```ruby
>> Mercurial::Shell.run(["id ?", "https://bitbucket.org/django/i-dont-exist"], append_hg: true)
Mercurial::CommandError: warning: bitbucket.org certificate with fingerprint 24:9c:45:8b:9c:aa:ba:55:4e:01:6d:58:ff:e4:28:7d:2a:14:ae:3b not verified (check hostfingerprints or web.cacerts config setting)
abort: HTTP Error 404: NOT FOUND
from ~/.rvm/gems/ruby-1.9.3-p125@pagoda/bundler/gems/mercurial-ruby-9f0166b30d06/lib/mercurial-ruby/command.rb:70:in `raise_error_if_needed'
```