Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hg commands can put innocuous error msgs on stderr which end up on stdout #59

Closed
GoogleCodeExporter opened this issue Mar 28, 2015 · 10 comments

Comments

@GoogleCodeExporter
Copy link

commented Mar 28, 2015

What steps will reproduce the problem?
1. hg root should generate some error
2. run upload.py
3. get AssertionError because of stderr ending up on stdout

What is the expected output? What do you see instead?

I expect the the command to execute. Instead, I get the following error:

Traceback (most recent call last):
  File "./upload.py", line 1338, in <module>
    main()
  File "./upload.py", line 1330, in main
    RealMain(sys.argv)
  File "./upload.py", line 1225, in RealMain
    vcs = GuessVCS(options)
  File "./upload.py", line 1189, in GuessVCS
    return MercurialVCS(options, out.strip())
  File "./upload.py", line 1015, in __init__
    assert cwd.startswith(self.repo_dir)
AssertionError

What version of the product are you using? On what operating system?
Using Mercurial version 1.0.2 and Python 2.5.2. On Ubuntu 8.04.

Please provide any additional information below.

Here's my shell session. 

atharh@pyro:~/some_repo$ hg root
*** failed to import extension hgext.inotify: No module named inotify
/home/atharh/some_repo

The assert in the python code above fails because the whole string,
"*** failed to import extension hgext.inotify: No module named inotify
/home/atharh/some_repo
"
ends up in self.repo_dir. It is important to ignore stderr in this case. I
will post a fix tomorrow.

Original issue reported on code.google.com by atharh on 20 Oct 2008 at 11:18

@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

The problem is that RunShellWithReturnCode() redirects stderr to stdout. AFAICT 
we
have no command that expects some output on stderr so it should be safe not to
redirect stderr to stdout in RunShellWithReturnCode(). But we need to prove 
that.

Original comment by albrecht.andi on 22 Oct 2008 at 3:20

  • Changed state: Accepted
  • Added labels: ****
  • Removed labels: ****
@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

I agree with you. I am attaching a patch here. RunShellWithReturnCode() now 
takes an
extra parameter called include_stderr. If include_stderr is true, stderr is
redirected to stdout, so any command which needs to have stderr redirected can 
set it
to True. I have set include_stderr to False by default.

Original comment by atharh on 23 Oct 2008 at 12:20

  • Added labels: ****
  • Removed labels: ****

Attachments:

@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

Original comment by albrecht.andi on 23 Oct 2008 at 4:28

  • Added labels: ****
  • Removed labels: ****
@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

Thanks for your patch, but I don't think we need stderr anywhere, so I've 
uploaded an
alternative version to codereview (http://codereview.appspot.com/7688).

Original comment by albrecht.andi on 29 Oct 2008 at 5:07

  • Changed state: Started
  • Added labels: ****
  • Removed labels: ****
@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

Committed r367. Please download upload.py again.

Original comment by albrecht.andi on 30 Oct 2008 at 5:35

  • Changed state: Fixed
  • Added labels: ****
  • Removed labels: ****
@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

Looks great. Thanks!

Original comment by atharh on 30 Oct 2008 at 5:47

  • Added labels: ****
  • Removed labels: ****
@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

hmm, every time I run upload.py I now get

"'hg' is not recognized as an internal or external command,
operable program or batch file."

Original comment by john.abd...@gmail.com on 7 Nov 2008 at 10:56

  • Added labels: ****
  • Removed labels: ****
@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

btw this on Windows.

Original comment by john.abd...@gmail.com on 7 Nov 2008 at 11:02

  • Added labels: ****
  • Removed labels: ****
@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

Confirmed, that's on Windows only. It prints out this warning message on stderr 
if a
command can't be found.

I've uploaded a patch: http://codereview.appspot.com/7762

Original comment by albrecht.andi on 8 Nov 2008 at 11:55

  • Changed state: Started
  • Added labels: ****
  • Removed labels: ****
@GoogleCodeExporter

This comment has been minimized.

Copy link
Author

commented Mar 28, 2015

Committed r371.

Original comment by albrecht.andi on 1 Dec 2008 at 5:54

  • Changed state: Fixed
  • Added labels: ****
  • Removed labels: ****
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.