Issue 1548 darcs show contents doesn't enforce mandatory argument

Title darcs show contents doesn't enforce mandatory argument
Priority bug Status resolved
Milestone Resolved in
Superseder Nosy List darcs-devel, dmitry.kurochkin, gwern, jaredj, kowey, thorkilnaur, twb
Assigned To
Topics ProbablyEasy, UI

Created on 2009-08-21.14:51:44 by gwern, last changed 2010-03-21.15:33:21 by twb.

msg8313 (view) Author: gwern Date: 2009-08-21.14:51:41
The help for darcs query contents claims:

 Outputs a specific version of a file.

This would seem to imply that there *must* be a filename argument, else what is
it doing? However, darcs does not require a filename argument and will exit

[10:50 AM] 0Mb$ darcs query contents --match='hash
"20090820015315-823f1-5364754c6be3b162b9d0e60d1211725932995f9d.gz"' && echo foo

(This is on the darcs-wikirepo)

[10:50 AM] 0Mb$ darcs --version (beta 4)

Worse, darcs query contents will happily process an entire repo even when no
filename argument, a sometimes tedious process:

[10:51 AM] 0Mb$ time darcs query contents --match='hash

real	0m5.470s
user	0m3.624s
sys	0m1.788s
msg8314 (view) Author: kowey Date: 2009-08-21.14:56:03
This should be fairly straightforward to fix.  It may be worth also considering
the interactions with the bit of code that filters out non-repo-paths
msg8585 (view) Author: twb Date: 2009-08-29.07:07:26
> Usage: darcs show contents [OPTION]... [FILE]...

The problem is that these are meaningful:

    darcs show contents f
    darcs show contents f1 f2 ... fn

but this is not:

    darcs show contents

I am not sure if "one-or-more" can be expressed by the current
command_extra_args setup.  Perhaps the bodge of using -1 to mean "zero
or more" could be extended such that -2 means "one or more".

We could work around it by simply removing the ability to "cat"
multiple files at once, but it means that the (uncommon?) case of

    darcs show contents f1 f2 ... fn

will be O(n) instead of O(1), which could be very slow if you are
fetching a very old repository state.

All this aside, I suppose the command_extra_args = -1 could be left
as-is, and simply case have

    show_contents_cmd opts [] = <throw an error here>

I'll try that presently.
msg10396 (view) Author: twb Date: 2010-03-21.15:33:18
The following patch updated the status of issue1548 to be resolved:

* Resolve issue1548: show contents requires at least one argument. 
Ignore-this: c15286919e827a5e7fdad01c75acccfe
Date User Action Args
2009-08-21 14:51:44gwerncreate
2009-08-21 14:56:09koweysetpriority: bug
status: unknown -> needs-implementation
topic: + ProbablyEasy, UI
messages: + msg8314
nosy: + jaredj
2009-08-25 18:15:52adminsetnosy: + darcs-devel, - simon
2009-08-27 14:28:41adminsetnosy: kowey, darcs-devel, thorkilnaur, gwern, jaredj, dmitry.kurochkin
2009-08-29 07:07:29twbsetnosy: + twb
messages: + msg8585
2010-03-15 14:56:52koweysettitle: darcs query contents doesn't enforce mandatory argument -> darcs show contents doesn't enforce mandatory argument
2010-03-21 15:33:21twbsetstatus: needs-implementation -> resolved
messages: + msg10396