You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@subversion.apache.org by Jon Trowbridge <tr...@ximian.com> on 2002/08/25 06:19:15 UTC

Ignored vs. Unversioned

I've come across a small problem in how subversion handles ignored
files.

In svn_wc.h, the comment starting at line 612 states that:

 * Ignored files should have a text_status of svn_wc_status_none.
 * Non-ignored Files that are not under version control should have a
   text_status of svn_wc_status_unversioned.

However, this isn't how things work out in practice.  When I call
svn_client_status with the no_ignore flag set, both ignored and
unversioned files come back with text_status svn_wc_status_unversioned.

Actually being able to distinguish between these two types of files
would be helpful to me for my work on gsvn.

I've attached a patch that "fixes"[1] this, in the sense that ignored
files will come back with a text_status of svn_wc_status_none.

Thanks,
-JT


[1] I have no idea what kind of breakage this could lead to in other
    parts of the code, so I'm calling this a "fix" rather than a fix.
    Someone who actually knows what is going on will have to think it
    through.
 




Re: Ignored vs. Unversioned

Posted by Philip Martin <ph...@codematters.co.uk>.
Jon Trowbridge <tr...@ximian.com> writes:

> Yes, I understand that.  What I'm saying is that it would be useful if,
> while not ignoring any files, there was some indicatation of which of
> the files would have been ignored if no_ignore had been FALSE.

I see now, sorry it took so long.

> 
> The comments in svn_wc.h (unless I've misinterpreted them) say that this
> should happen, by setting the text status of files that would have been
> ignored to svn_wc_status_none.  However, it isn't happening.

The comments in svn_wc.h (assuming you mean svn_wc_statuses) are
obviously incomplete, they don't mention NO_IGNORE :-(  So it's
difficult to say whether you misinterpreted them.

--
Philip, notes we missed the chance to have an option --ignore-ignore

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Ignored vs. Unversioned

Posted by Jon Trowbridge <tr...@ximian.com>.
On Sun, 2002-08-25 at 13:47, Philip Martin wrote:
> Jon Trowbridge <tr...@ximian.com> writes:
> > 
> > (1) Unversioned files that we are explicitly ignoring because they match
> >     a pattern in svn:ignore (or one of the default patterns).
> >     For example, foo.c~
> 
> When no_ignore is TRUE there are *no* files that we are explicitly
> ignoring, svn:ignore is not used.  That's what no_ignore means.
> 

Yes, I understand that.  What I'm saying is that it would be useful if,
while not ignoring any files, there was some indicatation of which of
the files would have been ignored if no_ignore had been FALSE.

The comments in svn_wc.h (unless I've misinterpreted them) say that this
should happen, by setting the text status of files that would have been
ignored to svn_wc_status_none.  However, it isn't happening.

(One alternative might be to create a new status type,
svn_wc_status_ignored.  That might have a bit less of a hacky, "magic
number"ish feeling, if that is something that you are concerned about.)

> > A bit of background might be helpful: I'm working on a Gtk+ Subversion
> > client (which lives in /clients/gsvn), and I want to have a "hide
> > ignored files" option so that you can look at a directory and not see
> > all of the foo~, foo.o, foo.lo, #foo#, etc. files.
> 
> That sounds like all the files not returned by svn_client_status when
> get_all is TRUE and no_ignore is FALSE.
> 
>     call svn_client_status to get status hash
>     get list of all files
>     for each file in list of all files
>       if file is not in status hash
>          file is ignored so don't display it
>       else
>          display file
> 
> which is the same as
> 
>     call svn_client_status to get status hash
>     display all files in status hash

To do what I want to do using the current svn_client_status (get a list
of all files, and know which ones would be ignored due to matching a
svn:ignore or default pattern) requires that I either:

 (1) Call svn_client_status twice, once w/ no_ignore TRUE and once with
     no_ignore FALSE, and compare the two returned status hashes to
     figure out which files are ignored due to svn:ignore/default
     patterns.

 (2) Call svn_client_status w/ no_ignore TRUE, then walk across the
     directory manually and inspect every file.  I can then conclude
     that any "extra" files I find, files that aren't mentioned in
     status hash, were ignored due to svn:ignore/default patterns.

Both of these require that we do some relatively expensive disk I/O
(walking across the directory looking at the files) twice, when it
really could just be done once by the original call to
svn_client_status.

Another alternative would be to call svn_client_status every time the
show/hide ignored files flag is toggled... which would also be a
reasonable solution, but again it shouldn't really be necessary.  If the
call to svn_client_status w/ no_ignore=TRUE simply flagged the
would-have-been-ignored files in some way (like setting the
text_status), then there is no need to extra calls to svn_client_status,
manual walking the directory, etc. etc.  I can just svn_client_status
once, and then I have all of the information I need... all I have to do
is toggle how that information is displayed.

Obviously this isn't that big a deal.  As Philip correctly points out,
there are plenty of ways to work around this issue.  But I think it
would be worthwhile do change svn_client_status to behave in the way
I've propsed because:

  * It is more efficient, and allows one call to svn_client_status to
    do all of the work.  

  * This change would actually produce the behavior promised in the
    comments in svn_wc.h.  If things don't get changed so that the
    text_status of ignored files gets set to svn_wc_status_none, then at
    least the comments in svn_wc.h should be changed to not promise
    that behavior.

> > Obviously I could work around this problem by just looking at the
> > svn:ignore property...
> > Ben Sussman told me that was totally wrong,
> > and that I should just let Subversion do it for me. :)
> 
> Doing it yourself means that your client may not behave the same way
> as the command line client:

Yes.  IMO, that would be bad. I can't think of any good reason why a GUI
client should ignore a different set of files than the cmd-line client.

-JT


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Ignored vs. Unversioned

Posted by Philip Martin <ph...@codematters.co.uk>.
Jon Trowbridge <tr...@ximian.com> writes:

> I'm sorry for being unclear.  When no_ignore is TRUE, I would like to be
> able to distinguish between:
> 
> (1) Unversioned files that we are explicitly ignoring because they match
>     a pattern in svn:ignore (or one of the default patterns).
>     For example, foo.c~

When no_ignore is TRUE there are *no* files that we are explicitly
ignoring, svn:ignore is not used.  That's what no_ignore means.

> (2) All other unversioned files.
> 
> My interpretation of the comments in svn_wc.h is that files of type (1)
> should have their text_status set to svn_wc_status_none, and while type
> (2) files should have a text_status of svn_wc_status_unversioned.
> 
> A bit of background might be helpful: I'm working on a Gtk+ Subversion
> client (which lives in /clients/gsvn), and I want to have a "hide
> ignored files" option so that you can look at a directory and not see
> all of the foo~, foo.o, foo.lo, #foo#, etc. files.

That sounds like all the files not returned by svn_client_status when
get_all is TRUE and no_ignore is FALSE.

    call svn_client_status to get status hash
    get list of all files
    for each file in list of all files
      if file is not in status hash
         file is ignored so don't display it
      else
         display file

which is the same as

    call svn_client_status to get status hash
    display all files in status hash


> Obviously I could work around this problem by just looking at the
> svn:ignore property on the directory and matching the patterns to the
> filenames in the GUI... but when I did exactly that in an earlier
> incarnation of this client, Ben Sussman told me that was totally wrong,
> and that I should just let Subversion do it for me. :)

Doing it yourself means that your client may not behave the same way
as the command line client: the command line client gets an optional
default ignore pattern from ~/.subversion/config and if your client
doesn't then it would be different.  However different is only wrong
if you are aiming to be the same :-)  You could quite legitimately
produce a client that was different.

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Ignored vs. Unversioned

Posted by Jon Trowbridge <tr...@ximian.com>.
On Sun, 2002-08-25 at 10:26, Philip Martin wrote:
> 
> I am confused by your comments.  If you have no_ignore set TRUE then
> that means that there are no ignored files.  From that it follows that
> all files on disk are either versioned or unversioned.  Why do you
> expect there to be any ignored files if no_ignore is set TRUE?
> 

I'm sorry for being unclear.  When no_ignore is TRUE, I would like to be
able to distinguish between:

(1) Unversioned files that we are explicitly ignoring because they match
    a pattern in svn:ignore (or one of the default patterns).
    For example, foo.c~

(2) All other unversioned files.

My interpretation of the comments in svn_wc.h is that files of type (1)
should have their text_status set to svn_wc_status_none, and while type
(2) files should have a text_status of svn_wc_status_unversioned.

A bit of background might be helpful: I'm working on a Gtk+ Subversion
client (which lives in /clients/gsvn), and I want to have a "hide
ignored files" option so that you can look at a directory and not see
all of the foo~, foo.o, foo.lo, #foo#, etc. files.

However, this is pretty useless if I can't distinguish between ignored
files and files that just aren't (yet) under version control.  It is a
pretty safe assumption that nobody will want to use a GUI to put their
emacs backup files or .o files under version control, so it is nice to
be able to keep them from cluttering up the directory listing... but the
GUI should always show other unversioned files and give the user an
option of adding them.

Obviously I could work around this problem by just looking at the
svn:ignore property on the directory and matching the patterns to the
filenames in the GUI... but when I did exactly that in an earlier
incarnation of this client, Ben Sussman told me that was totally wrong,
and that I should just let Subversion do it for me. :)

Thanks,
-JT


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org

Re: Ignored vs. Unversioned

Posted by Philip Martin <ph...@codematters.co.uk>.
Jon Trowbridge <tr...@ximian.com> writes:

> I've come across a small problem in how subversion handles ignored
> files.
> 
> In svn_wc.h, the comment starting at line 612 states that:
> 
>  * Ignored files should have a text_status of svn_wc_status_none.
>  * Non-ignored Files that are not under version control should have a
>    text_status of svn_wc_status_unversioned.
> 
> However, this isn't how things work out in practice.  When I call
> svn_client_status with the no_ignore flag set, both ignored and
> unversioned files come back with text_status svn_wc_status_unversioned.
> 
> Actually being able to distinguish between these two types of files
> would be helpful to me for my work on gsvn.
> 
> I've attached a patch that "fixes"[1] this, in the sense that ignored
> files will come back with a text_status of svn_wc_status_none.

I am confused by your comments.  If you have no_ignore set TRUE then
that means that there are no ignored files.  From that it follows that
all files on disk are either versioned or unversioned.  Why do you
expect there to be any ignored files if no_ignore is set TRUE?

-- 
Philip Martin

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org