You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2012/03/31 13:23:40 UTC
[lucy-commits] svn commit: r1307771 - in /lucy/trunk/clownfish: perl/t/501-include_dir.t
src/CFCHierarchy.c
Author: nwellnhof
Date: Sat Mar 31 11:23:39 2012
New Revision: 1307771
URL: http://svn.apache.org/viewvc?rev=1307771&view=rev
Log:
LUCY-215 Allow filename clash between source and include dirs
This can happen when rebuilding an already installed extension. It should be
safe if to ignore the file from the include dir because it will probably
be replaced with the version from the source dir later.
Thinking more about it, allowing other class name clashes between source and
include dirs doesn't seem like good idea to me now, because they can end up
in an inconsistent include dir after installation.
Modified:
lucy/trunk/clownfish/perl/t/501-include_dir.t
lucy/trunk/clownfish/src/CFCHierarchy.c
Modified: lucy/trunk/clownfish/perl/t/501-include_dir.t
URL: http://svn.apache.org/viewvc/lucy/trunk/clownfish/perl/t/501-include_dir.t?rev=1307771&r1=1307770&r2=1307771&view=diff
==============================================================================
--- lucy/trunk/clownfish/perl/t/501-include_dir.t (original)
+++ lucy/trunk/clownfish/perl/t/501-include_dir.t Sat Mar 31 11:23:39 2012
@@ -127,25 +127,20 @@ my $file_clash = 't/cfclash/file';
Clownfish::CFC::Model::Class->_clear_registry();
}
-SKIP: {
- skip( "source/include class name clash not yet implemented", 1 );
-
+{
my $hierarchy = Clownfish::CFC::Model::Hierarchy->new(dest => $dest);
$hierarchy->add_source_dir($source);
$hierarchy->add_include_dir($class_clash);
- $hierarchy->build;
+ eval { $hierarchy->build; };
- my $classes = $hierarchy->ordered_classes;
- is( scalar @$classes, 3, "source/include class name clash" );
+ like( $@, qr/Conflict with existing class Animal::Dog/, "source/include class name clash" );
Clownfish::CFC::Model::Class->_clear_registry();
}
-SKIP: {
- skip( "source/include filename clash not yet implemented", 1 );
-
+{
my $hierarchy = Clownfish::CFC::Model::Hierarchy->new(dest => $dest);
$hierarchy->add_source_dir($source);
Modified: lucy/trunk/clownfish/src/CFCHierarchy.c
URL: http://svn.apache.org/viewvc/lucy/trunk/clownfish/src/CFCHierarchy.c?rev=1307771&r1=1307770&r2=1307771&view=diff
==============================================================================
--- lucy/trunk/clownfish/src/CFCHierarchy.c (original)
+++ lucy/trunk/clownfish/src/CFCHierarchy.c Sat Mar 31 11:23:39 2012
@@ -264,6 +264,22 @@ S_parse_cf_files(CFCHierarchy *self, con
memcpy(path_part, src, path_part_len);
path_part[path_part_len] = '\0';
+ // Make sure path_part is unique
+ CFCFile *existing = S_fetch_file(self, path_part);
+ if (existing) {
+ if (is_included && !CFCFile_included(existing)) {
+ // Allow filename clash between source and include dirs
+ CFCUtil_warn("Warning: File %s.cfh from source dir takes "
+ "precedence over file from include dir",
+ path_part);
+ // Ignore file
+ continue;
+ }
+ else {
+ CFCUtil_die("File %s.cfh already registered", path_part);
+ }
+ }
+
CFCFileSpec *file_spec = CFCFileSpec_new(source_dir, path_part,
is_included);
@@ -441,15 +457,9 @@ S_fetch_file(CFCHierarchy *self, const c
static void
S_add_file(CFCHierarchy *self, CFCFile *file) {
CFCUTIL_NULL_CHECK(file);
- const char *path_part = CFCFile_get_path_part(file);
CFCClass **classes = CFCFile_classes(file);
for (size_t i = 0; self->files[i] != NULL; i++) {
CFCFile *existing = self->files[i];
- const char *old_path_part = CFCFile_get_path_part(existing);
- if (strcmp(path_part, old_path_part) == 0) {
- CFCUtil_die("File %s.cfh already registered",
- path_part);
- }
CFCClass **existing_classes = CFCFile_classes(existing);
for (size_t j = 0; classes[j] != NULL; j++) {
const char *new_class_name = CFCClass_get_class_name(classes[j]);