darcs

Issue 1655 warnings should go to stderr

Title warnings should go to stderr
Priority feature Status given-up
Milestone Resolved in
Superseder Nosy List darcs-devel, dmitry.kurochkin, galbolle, kowey, zooko
Assigned To
Topics UI

Created on 2009-10-24.15:49:14 by zooko, last changed 2017-07-30.23:38:37 by gh.

Messages
msg9020 (view) Author: zooko Date: 2009-10-24.15:49:12
I have a tool -- http://allmydata.org/trac/darcsver/browser/README.txt -- which 
invokes darcs and parses the output.  Things are easier for tools like this if 
stdout never has anything but the expected data, i.e. when you invoke "darcs 
changes --xml" stdout either has nothing or has some changes in XML format.  
Exceptional messages, warnings, metadata, etc, should go to stderr.  Apparently 
with the current darcs trunk, the warning about crcs goes to stdout:

HACL yukyuk:~/playground/tailor$ darcs changes --xml-output --from-tag=^tailor 
1>/dev/null
darcs: Couldn't find a tag matching "tag-name ^tailor"
HACL yukyuk:~/playground/tailor$ darcs changes --xml-output --from-tag=^tailor 
2>/dev/null

Warning: CRC errors found. These are probably harmless but should be repaired.
See 'darcs gzcrcs --help' for more information.
msg9021 (view) Author: kowey Date: 2009-10-24.15:53:17
Adding Florent as he's done some work on this.
msg9029 (view) Author: zooko Date: 2009-10-25.15:47:35
So it turns out that this breaks my darcsver tool (in the case that there are crc errors 
present).

With darcs-2.2.0 installed:

-------
$ python setup.py darcsver
running darcsver
setup.py darcsver: wrote '0.9.35' into _version.py
-------

After upgrading to 2.3.1+271 patches it gets a parse error since the stdout is no longer well-
formed XML:

-------
$ python setup.py darcsver
running darcsver
Traceback (most recent call last):
  File "setup.py", line 36, in <module>
    'License :: GNU General Public License',
  File "/usr/lib/python2.6/distutils/core.py", line 152, in setup
    dist.run_commands()
  File "/usr/lib/python2.6/distutils/dist.py", line 975, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python2.6/distutils/dist.py", line 995, in run_command
    cmd_obj.run()
  File "/usr/local/lib/python2.6/dist-packages/darcsver-unknown-
py2.6.egg/darcsver/setuptools_command.py", line 77, in run
    (rc, verstr) = darcsvermodule.update(self.project_name, self.version_file, 
self.count_all_patches, abort_if_snapshot=self.abort_if_snapshot, loud=loud, EXE_NAME="setup.py 
darcsver")
  File "/usr/local/lib/python2.6/dist-packages/darcsver-unknown-
py2.6.egg/darcsver/darcsvermodule.py", line 112, in update
    doc = xml.dom.minidom.parseString(output)
  File "/usr/lib/python2.6/xml/dom/minidom.py", line 1928, in parseString
    return expatbuilder.parseString(string)
  File "/usr/lib/python2.6/xml/dom/expatbuilder.py", line 940, in parseString
    return builder.parseString(string)
  File "/usr/lib/python2.6/xml/dom/expatbuilder.py", line 223, in parseString
    parser.Parse(string, True)
xml.parsers.expat.ExpatError: junk after document element: line 288, column 0
-------

The tail of the string that it attempted to parse looks like this:

<name>Document the &apos;overwrite-tags&apos; for git</name>\n-<comment>Also, emit a critical 
log indicating the possible source of the\nproblem, mentioning the 
option.</comment>\n</patch>\n</changelog>\n\nWarning: CRC errors found. These are probably 
harmless but should be repaired.\nSee 'darcs gzcrcs --help' for more information.\n\n

I've made a new version of darcsver which before XML parsing scans for "</changelog>" and 
strips off everything which follows it.  That appears to restore darcsver to correct behavior 
in this case.

If you're planning to release another stable in the 2.3 series then if you could move that 
warning from stdout to stderr this would allow the current version of darcsver to continue to 
work.  (This could be useful because, for example, some of my projects have a copy of darcsver 
bundled in with the project's own source code, so it will continue to be using the old version 
of darcsver even after I've published a newer one with this work-around.)

In any case, in the future it might be convenient if darcs uses stderr for warnings, 
exceptions, errors, and "communication to the user" and reserves stdout for a structured value 
that can be consumed programmatically (when that makes sense).
History
Date User Action Args
2009-10-24 15:49:15zookocreate
2009-10-24 15:53:20koweysetpriority: feature
status: unknown -> needs-implementation
topic: + UI
messages: + msg9021
nosy: + galbolle, kowey
2009-10-25 15:47:38zookosetmessages: + msg9029
2017-07-30 23:38:37ghsetstatus: needs-implementation -> given-up