Kaydet (Commit) 125d4ada authored tarafından Vladimir Glazunov's avatar Vladimir Glazunov

#i107041#

üst 2bc1a6dc
This diff is collapsed.
...@@ -57,12 +57,16 @@ sub new { ...@@ -57,12 +57,16 @@ sub new {
my $proto = shift; my $proto = shift;
my $class = ref($proto) || $proto; my $class = ref($proto) || $proto;
my $source_root = shift; my $source_root = shift;
my $self = {};
$self->{USER_SOURCE_ROOT} = undef;
if (defined $source_root) { if (defined $source_root) {
$self->{USER_SOURCE_ROOT} = $source_root;
$source_root =~ s/\\|\/$//; $source_root =~ s/\\|\/$//;
$source_root .= '/..';
} else { } else {
$source_root = $ENV{SOLARSRC}; $source_root = $ENV{SOURCE_ROOT_DIR};
}; };
my $self = {}; $source_root = Cwd::realpath($source_root);
$self->{DEBUG} = 0; $self->{DEBUG} = 0;
$self->{SOURCE_ROOT} = $source_root; $self->{SOURCE_ROOT} = $source_root;
$self->{REPOSITORIES} = {}; $self->{REPOSITORIES} = {};
...@@ -72,7 +76,7 @@ sub new { ...@@ -72,7 +76,7 @@ sub new {
$self->{MODULE_REPOSITORY} = {}; $self->{MODULE_REPOSITORY} = {};
$self->{REAL_MODULES} = {}; $self->{REAL_MODULES} = {};
$self->{SOURCE_CONFIG_FILE} = get_config_file($source_root); $self->{SOURCE_CONFIG_FILE} = get_config_file($source_root);
$self->{SOURCE_CONFIG_DEFAULT} = Cwd::realpath($source_root) .'/'.SOURCE_CONFIG_FILE_NAME; $self->{SOURCE_CONFIG_DEFAULT} = $source_root .'/'.SOURCE_CONFIG_FILE_NAME;
read_config_file($self); read_config_file($self);
bless($self, $class); bless($self, $class);
return $self; return $self;
...@@ -206,18 +210,39 @@ sub get_module_paths { ...@@ -206,18 +210,39 @@ sub get_module_paths {
sub get_config_file { sub get_config_file {
my $source_root = shift; my $source_root = shift;
foreach ($source_root, $source_root . '/..') { my $possible_path = $source_root . '/' . SOURCE_CONFIG_FILE_NAME;
if (-f $_ . '/' . SOURCE_CONFIG_FILE_NAME) { return $possible_path if (-f $possible_path);
return Cwd::realpath($_) .'/'.SOURCE_CONFIG_FILE_NAME; return '';
};
sub get_hg_root {
my $hg_root;
if (open(COMMAND, "hg root 2>&1 |")) {
foreach (<COMMAND>) {
next if (/^Not trusting file/);
chomp;
$hg_root = $_;
last;
};
close COMMAND;
chomp $hg_root;
if ($hg_root !~ /There is no Mercurial repository here/) {
return $hg_root;
}; };
}; };
return ''; croak('Cannot open find source_config and/or determine hg root directory for ' . cwd());
}; };
sub read_config_file { sub read_config_file {
my $self = shift; my $self = shift;
if (!$self->{SOURCE_CONFIG_FILE}) { if (!$self->{SOURCE_CONFIG_FILE}) {
${$self->{REPOSITORIES}}{File::Basename::basename($self->{SOURCE_ROOT})} = $self->{SOURCE_ROOT}; my $repository_root;
if (defined $self->{USER_SOURCE_ROOT}) {
$repository_root = $self->{USER_SOURCE_ROOT};
} else {
$repository_root = get_hg_root();
};
${$self->{REPOSITORIES}}{File::Basename::basename($repository_root)} = $repository_root;
return; return;
}; };
my $repository_section = 0; my $repository_section = 0;
...@@ -243,7 +268,7 @@ sub read_config_file { ...@@ -243,7 +268,7 @@ sub read_config_file {
next if (!$repository_section && !$module_section); next if (!$repository_section && !$module_section);
if (/\s*(\S+)=active\s*(\s+#)*/) { if (/\s*(\S+)=active\s*(\s+#)*/) {
if ($repository_section) { if ($repository_section) {
${$self->{REPOSITORIES}}{$1} = File::Basename::dirname($self->{SOURCE_ROOT}) . "/$1"; ${$self->{REPOSITORIES}}{$1} = $self->{SOURCE_ROOT} . "/$1";
next; next;
} }
if ($module_section) { if ($module_section) {
...@@ -254,6 +279,11 @@ sub read_config_file { ...@@ -254,6 +279,11 @@ sub read_config_file {
croak("Line $line in " . $self->{SOURCE_CONFIG_FILE} . 'violates format. Please make your checks!!'); croak("Line $line in " . $self->{SOURCE_CONFIG_FILE} . 'violates format. Please make your checks!!');
}; };
close SOURCE_CONFIG_FILE; close SOURCE_CONFIG_FILE;
if (!scalar keys %{$self->{REPOSITORIES}}) {
# Fallback - default repository is the directory where is our module...
my $hg_root = get_hg_root();
${$self->{REPOSITORIES}}{File::Basename::basename($hg_root)} = $hg_root;
};
} else { } else {
croak('Cannot open ' . $self->{SOURCE_CONFIG_FILE} . 'for reading'); croak('Cannot open ' . $self->{SOURCE_CONFIG_FILE} . 'for reading');
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment