[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: [PATCH]: status "I" not consistently shown for ignored directory

From: Julian Foad <julianfoad_at_btopenworld.com>
Date: 2003-07-26 02:23:13 CEST

Philip Martin wrote:
> Julian Foad <julianfoad@btopenworld.com> writes:
>
>>The fix duplicates a block of code from further up in the same
>>function (which handled a file rather than a directory). I could
>>not see an elegant way to avoid that, but would like it if someone
>>else can.
>
> Make it a separate function that gets called from the two places?

Thanks for the enlightenment ;-) Seriously, because it is rather few lines (4 statements taking up 11 lines) taking rather many (8) parameters, I am not sure whether that would be better, and would be glad of your opinion.

>>+ status = 1
>>+ for line in stat_output:
>>+ if re.match("I +newdir", line):
>>+ status = 0
...
> An RE is probably over the top as the number of spaces should be
> known. When I wrote something like that someone (Greg?) suggested

This is all copied from the existing test above it. I should have said: my knowledge of Python and of the svn test suite were zero recently and I am only learning by example. But I am glad to learn more from you.

> for line in stat_output:
> if line.find("I newdir") != -1:
> break
...
> However I would probably drop run_svn altogether. It would be better
> to use run_and_verify_status but I don't know if that supports 'I', if
> it doesn't I would use something like
>
> run_and_verify_svn(None, ['I newdir\n'], [], 'status', '--no-ignore')

That all looks much better. I understand the principle of "run_and_verify_status" but not the details of how to use it. "run_and_verify_svn" is easy and reasonably appropriate. Now I can combine the two tests, and have the combined version neater than the old single test.

Patch re-attached with the main code untouched but the test script much improved.

Log message:
[[[
Fix status indicator "I": when an ignored directory was given as an explicit
argument, its status was reported as "?".

* subversion/libsvn_wc/status.c
 (svn_wc_statuses)

* subversion/tests/clients/cmdline/stat_tests.py
 (status_for_unignored_dir) New function.
 (test_list) Add the new test.
]]]

- Julian

Index: subversion/libsvn_wc/status.c
===================================================================
--- subversion/libsvn_wc/status.c (revision 6580)
+++ subversion/libsvn_wc/status.c (working copy)
@@ -831,10 +831,20 @@
       /* A wc format of 0 means this directory is not being versioned
          at all (not by Subversion, anyway). */
       if (wc_format_version == 0)
- return add_status_structure
- (statushash, path, NULL, NULL, NULL,
- svn_node_dir, FALSE, FALSE, notify_func, notify_baton, pool);
+ {
+ char *name;
+ apr_array_header_t *patterns;
 
+ patterns = apr_array_make (pool, 1, sizeof(const char *));
+ SVN_ERR (collect_ignore_patterns (patterns, ignores,
+ adm_access, pool));
+
+ name = svn_path_basename (path, pool);
+ return add_unversioned_item (name, kind, statushash,
+ adm_access, patterns, TRUE,
+ notify_func, notify_baton, pool);
+ }
+
       SVN_ERR (svn_wc_is_wc_root (&is_root, path, adm_access, pool));
       if (! is_root)
         {
Index: subversion/tests/clients/cmdline/stat_tests.py
===================================================================
--- subversion/tests/clients/cmdline/stat_tests.py (revision 6580)
+++ subversion/tests/clients/cmdline/stat_tests.py (working copy)
@@ -317,9 +317,16 @@
   return 0
 
 
-def status_for_unignored_file(sbox):
- "status for unignored file"
+# Regression: in r6580, "svn status ignored-dir ignored-file" was reporting
+# "? unversioned-ignored-dir"
+# "I unversioned-ignored-file"
+# while "svn status --no-ignore ." was correctly reporting
+# "I unversioned-ignored-dir"
+# "I unversioned-ignored-file"
 
+def status_for_unignored_file_and_dir(sbox):
+ "status for unignored file and directory"
+
   sbox.build()
 
   wc_dir = sbox.wc_dir
@@ -329,33 +336,23 @@
 
   try:
     svntest.main.file_append('newfile', 'this is a new file')
- svntest.main.run_svn(None, 'propset', 'svn:ignore', 'newfile', '.')
+ os.makedirs('newdir')
+ svntest.main.run_svn(None, 'propset', 'svn:ignore', 'new*', '.')
 
     # status on the directory with --no-ignore
- stat_output, err_output = svntest.main.run_svn(None, 'status',
- '--no-ignore', '.')
- if err_output:
- raise svntest.Failure
- status = 1
- for line in stat_output:
- if re.match("I +newfile", line):
- status = 0
+ svntest.actions.run_and_verify_svn(None,
+ [' M .\n',
+ 'I newdir\n',
+ 'I newfile\n'],
+ [],
+ 'status', '--no-ignore', '.')
 
- if (status == 1):
- raise svntest.Failure
-
     # status specifying the file explicitly on the command line
- stat_output, err_output = svntest.main.run_svn(None, 'status', 'newfile')
-
- if err_output:
- raise svntest.Failure
- status = 1
- for line in stat_output:
- if re.match("I +newfile", line):
- status = 0
-
- if (status == 1):
- raise svntest.Failure
+ svntest.actions.run_and_verify_svn(None,
+ ['I newdir\n',
+ 'I newfile\n'],
+ [],
+ 'status', 'newdir', 'newfile')
   
   finally:
     os.chdir(was_cwd)
@@ -531,7 +528,7 @@
               status_type_change,
               Skip(status_type_change_to_symlink, (os.name != 'posix')),
               status_with_new_files_pending,
- status_for_unignored_file,
+ status_for_unignored_file_and_dir,
               status_for_nonexistent_file,
               status_file_needs_update,
               status_uninvited_parent_directory,

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Sat Jul 26 02:16:02 2003

This is an archived mail posted to the Subversion Dev mailing list.

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.