- # Avoid overwriting any existing files.
- foreach my $key (qw{srcdir destdir repository dumpsetup}) {
- next unless exists $config{$key};
- my $add="";
- while (-e $config{$key}.$add) {
- $add=1 if ! $add;
- $add++;
+sub import (@) {
+ my $this=shift;
+ $config{setuptype}='Yaml';
+ IkiWiki::Setup::merge({@_});
+
+ if (! $config{force_overwrite}) {
+ # Avoid overwriting any existing files.
+ foreach my $key (qw{srcdir destdir repository dumpsetup}) {
+ next unless exists $config{$key};
+ my $add="";
+ my $dir=IkiWiki::dirname($config{$key})."/";
+ my $base=IkiWiki::basename($config{$key});
+ while (-e $dir.$add.$base) {
+ $add=1 if ! $add;
+ $add++;
+ }
+ $config{$key}=$dir.$add.$base;
+ }
+ }
+
+ # Set up wrapper
+ if ($config{rcs}) {
+ if ($config{rcs} eq 'git') {
+ $config{git_wrapper}=$config{repository}."/hooks/post-update";
+ }
+ elsif ($config{rcs} eq 'svn') {
+ $config{svn_wrapper}=$config{repository}."/hooks/post-commit";
+ }
+ elsif ($config{rcs} eq 'monotone') {
+ $config{mtn_wrapper}=$config{srcdir}."_MTN/ikiwiki-netsync-hook";
+ }
+ elsif ($config{rcs} eq 'darcs') {
+ $config{darcs_wrapper}=$config{repository}."/_darcs/ikiwiki-wrapper";
+ }
+ elsif ($config{rcs} eq 'bzr') {
+ # TODO
+ print STDERR "warning: do not know how to set up the bzr_wrapper hook!\n";
+ }
+ elsif ($config{rcs} eq 'mercurial') {
+ # TODO
+ print STDERR "warning: do not know how to set up the mercurial_wrapper hook!\n";
+ }
+ elsif ($config{rcs} eq 'tla') {
+ # TODO
+ print STDERR "warning: do not know how to set up the tla_wrapper hook!\n";
+ }
+ elsif ($config{rcs} eq 'cvs') {
+ $config{cvs_wrapper}=$config{repository}."/CVSROOT/post-commit";
+ }
+ else {
+ error sprintf(gettext("unsupported revision control system %s"),
+ $config{rcs});