darcs

Issue 371 wish: less confusing error messages for replace --token-chars

Title wish: less confusing error messages for replace --token-chars
Priority wishlist Status resolved
Milestone Resolved in
Superseder Nosy List darcs-devel, dmitry.kurochkin, kowey, markstos, thorkilnaur, tommy, trentbuck
Assigned To
Topics FauxBug

Created on 2006-12-20.08:54:57 by trentbuck, last changed 2009-08-27.13:58:18 by admin.

Messages
msg1362 (view) Author: twb Date: 2006-12-20.08:54:46
The following transcript demonstrates the issue.

    $ darcs --version
    1.0.9rc1 (release candidate 1)

    $ darcs --exact-version
    darcs compiled on Nov 12 2006, at 05:43:35
    # configured Mon Oct  9 15:12:44 EDT 2006
    ./configure --no-create --no-recursion

    Context:

    [TAG 1.0.9rc1
    Tommy Pettersson <ptp@lysator.liu.se>**20061008175207]

    $ mkdir x

    $ cd x

    $ darcs init

    $ touch x

    $ darcs rec -lam x x
    Recording changes in "x":

    Finished recording patch 'x'

    $ darcs replace --token-chars '[^ \n\t]' x x x

    darcs failed:  Space not allowed in tokens:  [^ \n\t]

    $ echo $?
    2
msg1364 (view) Author: tommy Date: 2006-12-20.18:34:18
On Wed, Dec 20, 2006 at 08:54:58AM +0000, Trent Buck wrote:
>     $ darcs replace --token-chars '[^ \n\t]' x x x
> 
>     darcs failed:  Space not allowed in tokens:  [^ \n\t]

This is wonderful. :-)

I'm sorry, but this in not a bug, although I won't blame anyone
for thinking so. Or it _is_ rather an error message bug. Well,
at the bottom of everything there's a design error, that I've
promised to fix (any year now...)

The word token in the error message should be token specifier,
or something. The whole error message should probably be more
verbose and explain that the reason spaces are not allowed in
token( specifier)s is darcs can't store them with the current
replace patch format.

Hmm, If I'm not misstating the token specifier [^x] would
perfectly well match tokens with spaces in them.

A patch with a well thought out error message would be most
welcome.
msg2034 (view) Author: kowey Date: 2007-08-09.07:36:09
See also related issue245
msg2073 (view) Author: kowey Date: 2007-08-15.15:49:41
There is a documentation bug hidden in this, in that we actually tell the user: 

You may prefer to define tokens in terms
of delimiting characters instead of allowed characters using a flag such as
\verb!--token-chars '[^ \n\t]'!, which would define a token as being
white-space delimited.
msg2560 (view) Author: markstos Date: 2008-01-18.03:48:18
I'll just add a "me too" to this. No other find and replace utility I've ever
used  has required me to also a define a "token spec" in addition to what I find
and replace. When I have tried to do so with darcs I have failed, and thus not
used "darcs replace" when I might have otherwise.  

Could it just be be optional?
msg2757 (view) Author: droundy Date: 2008-01-25.20:24:11
On Fri, Jan 18, 2008 at 03:48:20AM -0000, Mark Stosberg wrote:
> I'll just add a "me too" to this. No other find and replace utility I've ever
> used  has required me to also a define a "token spec" in addition to what I find
> and replace. When I have tried to do so with darcs I have failed, and thus not
> used "darcs replace" when I might have otherwise.  
> 
> Could it just be be optional?

The token spec *is* optional.  Perhaps we should document this better?
-- 
David Roundy
Department of Physics
Oregon State University
msg2759 (view) Author: markstos Date: 2008-01-25.20:40:34
David Roundy wrote:
> 
> On Fri, Jan 18, 2008 at 03:48:20AM -0000, Mark Stosberg wrote:
>> I'll just add a "me too" to this. No other find and replace utility I've ever
>> used  has required me to also a define a "token spec" in addition to what I find
>> and replace. When I have tried to do so with darcs I have failed, and thus not
>> used "darcs replace" when I might have otherwise.  
>>
>> Could it just be be optional?
> 
> The token spec *is* optional.  Perhaps we should document this better?

Thanks for the follow-up, David.

Is it really optional, if it has a default, and the default isn't what I 
want?

My optional, I meant "the notion is not considered" rather than "a 
default token spec is provided", which I what I believe the correct 
behavior is.
msg2767 (view) Author: droundy Date: 2008-01-25.20:55:53
On Fri, Jan 25, 2008 at 08:40:35PM -0000, Mark Stosberg wrote:
> David Roundy wrote:
> > On Fri, Jan 18, 2008 at 03:48:20AM -0000, Mark Stosberg wrote:
> >> I'll just add a "me too" to this. No other find and replace utility I've ever
> >> used  has required me to also a define a "token spec" in addition to what I find
> >> and replace. When I have tried to do so with darcs I have failed, and thus not
> >> used "darcs replace" when I might have otherwise.  
> >>
> >> Could it just be be optional?
> > 
> > The token spec *is* optional.  Perhaps we should document this better?
> 
> Thanks for the follow-up, David.
> 
> Is it really optional, if it has a default, and the default isn't what I 
> want?
> 
> My optional, I meant "the notion is not considered" rather than "a 
> default token spec is provided", which I what I believe the correct 
> behavior is.

I mean that it has a default value.  Actually it has two defaults,
depending on whether or not you have a '.' in either of your tokens.  How
do you imagine it could work without any definition of tokens? The only way
I could imagine doing that would be to construct the set of possible token
characters as a union of the characters in the new and old tokens.  But
that would have the disadvantage that almost any pair of token replace
patches would conflict.
-- 
David Roundy
Department of Physics
Oregon State University
msg2771 (view) Author: markstos Date: 2008-01-25.21:25:52
> I mean that it has a default value.  Actually it has two defaults,
> depending on whether or not you have a '.' in either of your tokens.  How
> do you imagine it could work without any definition of tokens? 

When I normally do a find and replace I just tell the system to find "a" 
and replace it with "b". There are no other tokens.

Now, maybe I'm not considering what it means for darcs to implement a 
find-and-replace patch that works reasonably. Maybe token-chars are 
required for the darcs case.

They just aren't for the common text-editor or programming case, which 
is every other case for me.

The good news is that recording a find-and-replace as I'm used to in a 
regular patch has worked perfectly fine for me for as an alternative.

   Mark
msg2773 (view) Author: droundy Date: 2008-01-25.21:57:33
On Fri, Jan 25, 2008 at 09:25:53PM -0000, Mark Stosberg wrote:
> When I normally do a find and replace I just tell the system to find "a" 
> and replace it with "b". There are no other tokens.
> 
> Now, maybe I'm not considering what it means for darcs to implement a 
> find-and-replace patch that works reasonably. Maybe token-chars are 
> required for the darcs case.

Yes, darcs only allows invertible changes, which a normal find-and-replace
most certainly is not.
-- 
David Roundy
Department of Physics
Oregon State University
msg4531 (view) Author: kowey Date: 2008-05-05.16:07:44
I think this is resolved by my issue245 fix.  Please shout if you disagree.
History
Date User Action Args
2006-12-20 08:54:57trentbuckcreate
2006-12-20 18:34:25tommysetstatus: unread -> unknown
nosy: + beschmi
messages: + msg1364
2007-03-09 08:10:36koweysetnosy: droundy, tommy, beschmi, kowey, trentbuck
title: --token-chars with complementary set broken in 1.0.9rc1 -> error messages for --token-chars are confusing
2007-03-09 08:10:54koweysettopic: + FauxBug
nosy: droundy, tommy, beschmi, kowey, trentbuck
2007-03-09 08:11:29koweysetpriority: bug -> wishlist
nosy: droundy, tommy, beschmi, kowey, trentbuck
title: error messages for --token-chars are confusing -> less confusing error messages for replace --token-chars
2007-08-09 07:35:51koweysetnosy: droundy, tommy, beschmi, kowey, trentbuck
superseder: + more precise 'Bad token spec' error messages.
2007-08-09 07:36:10koweysetsuperseder: - more precise 'Bad token spec' error messages.
messages: + msg2034
2007-08-15 15:49:42koweysetmessages: + msg2073
2008-01-18 03:48:20markstossetnosy: + markstos
messages: + msg2560
2008-01-25 20:24:13droundysetnosy: droundy, tommy, beschmi, kowey, markstos, trentbuck
messages: + msg2757
2008-01-25 20:40:35markstossetnosy: droundy, tommy, beschmi, kowey, markstos, trentbuck
messages: + msg2759
2008-01-25 20:55:55droundysetnosy: droundy, tommy, beschmi, kowey, markstos, trentbuck
messages: + msg2767
2008-01-25 21:25:53markstossetnosy: droundy, tommy, beschmi, kowey, markstos, trentbuck
messages: + msg2771
2008-01-25 21:57:35droundysetnosy: droundy, tommy, beschmi, kowey, markstos, trentbuck
messages: + msg2773
2008-02-11 01:28:04markstossetstatus: unknown -> deferred
nosy: droundy, tommy, beschmi, kowey, markstos, trentbuck
title: less confusing error messages for replace --token-chars -> wish: less confusing error messages for replace --token-chars
2008-05-05 16:07:46koweysetstatus: deferred -> resolved
nosy: + dagit
messages: + msg4531
2009-08-06 17:47:56adminsetnosy: + jast, Serware, dmitry.kurochkin, darcs-devel, zooko, mornfall, simon, thorkilnaur, - droundy, trentbuck
2009-08-06 20:43:41adminsetnosy: - beschmi
2009-08-10 21:59:53adminsetnosy: + trentbuck, - darcs-devel, zooko, jast, Serware, mornfall
2009-08-10 23:58:41adminsetnosy: - dagit
2009-08-25 17:59:42adminsetnosy: + darcs-devel, - simon
2009-08-27 13:58:18adminsetnosy: tommy, kowey, markstos, darcs-devel, trentbuck, thorkilnaur, dmitry.kurochkin