diff options
Diffstat (limited to 'IkiWiki/Plugin')
-rw-r--r-- | IkiWiki/Plugin/bzr.pm | 38 | ||||
-rw-r--r-- | IkiWiki/Plugin/git.pm | 46 | ||||
-rw-r--r-- | IkiWiki/Plugin/mercurial.pm | 34 | ||||
-rw-r--r-- | IkiWiki/Plugin/monotone.pm | 32 | ||||
-rw-r--r-- | IkiWiki/Plugin/norcs.pm | 111 | ||||
-rw-r--r-- | IkiWiki/Plugin/svn.pm | 38 | ||||
-rw-r--r-- | IkiWiki/Plugin/tla.pm | 34 |
7 files changed, 188 insertions, 145 deletions
diff --git a/IkiWiki/Plugin/bzr.pm b/IkiWiki/Plugin/bzr.pm index 5df522f6e..39227cbae 100644 --- a/IkiWiki/Plugin/bzr.pm +++ b/IkiWiki/Plugin/bzr.pm @@ -1,6 +1,5 @@ #!/usr/bin/perl - -package IkiWiki; +package IkiWiki::Plugin::bzr; use warnings; use strict; @@ -8,19 +7,34 @@ use IkiWiki; use Encode; use open qw{:utf8 :std}; -hook(type => "checkconfig", id => "bzr", call => sub { #{{{ +sub import { #{{{ + hook(type => "checkconfig", id => "bzr", call => \&checkconfig); + hook(type => "getsetup", id => "bzr", call => \&getsetup); + hook(type => "rcs", id => "rcs_update", call => \&rcs_update); + hook(type => "rcs", id => "rcs_prepedit", call => \&rcs_prepedit); + hook(type => "rcs", id => "rcs_commit", call => \&rcs_commit); + hook(type => "rcs", id => "rcs_commit_staged", call => \&rcs_commit_staged); + hook(type => "rcs", id => "rcs_add", call => \&rcs_add); + hook(type => "rcs", id => "rcs_remove", call => \&rcs_remove); + hook(type => "rcs", id => "rcs_rename", call => \&rcs_rename); + hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges); + hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff); + hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime); +} #}}} + +sub checkconfig () { #{{{ if (! defined $config{diffurl}) { $config{diffurl}=""; } - if (length $config{bzr_wrapper}) { + if (defined $config{bzr_wrapper} && length $config{bzr_wrapper}) { push @{$config{wrappers}}, { wrapper => $config{bzr_wrapper}, wrappermode => (defined $config{bzr_wrappermode} ? $config{bzr_wrappermode} : "06755"), }; } -}); #}}} +} #}}} -hook(type => "getsetup", id => "bzr", call => sub { #{{{ +sub getsetup () { #{{{ return bzr_wrapper => { type => "string", @@ -50,7 +64,7 @@ hook(type => "getsetup", id => "bzr", call => sub { #{{{ safe => 1, rebuild => 1, }, -}); #}}} +} #}}} sub bzr_log ($) { #{{{ my $out = shift; @@ -101,10 +115,10 @@ sub bzr_author ($$) { #{{{ my ($user, $ipaddr) = @_; if (defined $user) { - return possibly_foolish_untaint($user); + return IkiWiki::possibly_foolish_untaint($user); } elsif (defined $ipaddr) { - return "Anonymous from ".possibly_foolish_untaint($ipaddr); + return "Anonymous from ".IkiWiki::possibly_foolish_untaint($ipaddr); } else { return "Anonymous"; @@ -116,7 +130,7 @@ sub rcs_commit ($$$;$$) { #{{{ $user = bzr_author($user, $ipaddr); - $message = possibly_foolish_untaint($message); + $message = IkiWiki::possibly_foolish_untaint($message); if (! length $message) { $message = "no message given"; } @@ -137,7 +151,7 @@ sub rcs_commit_staged ($$$) { $user = bzr_author($user, $ipaddr); - $message = possibly_foolish_untaint($message); + $message = IkiWiki::possibly_foolish_untaint($message); if (! length $message) { $message = "no message given"; } @@ -172,7 +186,7 @@ sub rcs_remove ($) { # {{{ sub rcs_rename ($$) { # {{{ my ($src, $dest) = @_; - my $parent = dirname($dest); + my $parent = IkiWiki::dirname($dest); if (system("bzr", "add", "--quiet", "$config{srcdir}/$parent") != 0) { warn("bzr add $parent failed\n"); } diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 6c9aca650..b20793d86 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -1,6 +1,5 @@ #!/usr/bin/perl - -package IkiWiki; +package IkiWiki::Plugin::git; use warnings; use strict; @@ -11,7 +10,22 @@ use open qw{:utf8 :std}; my $sha1_pattern = qr/[0-9a-fA-F]{40}/; # pattern to validate Git sha1sums my $dummy_commit_msg = 'dummy commit'; # message to skip in recent changes -hook(type => "checkconfig", id => "git", call => sub { #{{{ +sub import { #{{{ + hook(type => "checkconfig", id => "git", call => \&checkconfig); + hook(type => "getsetup", id => "git", call => \&getsetup); + hook(type => "rcs", id => "rcs_update", call => \&rcs_update); + hook(type => "rcs", id => "rcs_prepedit", call => \&rcs_prepedit); + hook(type => "rcs", id => "rcs_commit", call => \&rcs_commit); + hook(type => "rcs", id => "rcs_commit_staged", call => \&rcs_commit_staged); + hook(type => "rcs", id => "rcs_add", call => \&rcs_add); + hook(type => "rcs", id => "rcs_remove", call => \&rcs_remove); + hook(type => "rcs", id => "rcs_rename", call => \&rcs_rename); + hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges); + hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff); + hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime); +} #}}} + +sub checkconfig () { #{{{ if (! defined $config{diffurl}) { $config{diffurl}=""; } @@ -21,15 +35,15 @@ hook(type => "checkconfig", id => "git", call => sub { #{{{ if (! defined $config{gitmaster_branch}) { $config{gitmaster_branch}="master"; } - if (length $config{git_wrapper}) { + if (defined $config{git_wrapper} && length $config{git_wrapper}) { push @{$config{wrappers}}, { wrapper => $config{git_wrapper}, wrappermode => (defined $config{git_wrappermode} ? $config{git_wrappermode} : "06755"), }; } -}); #}}} +} #}}} -hook(type => "getsetup", id => "git", call => sub { #{{{ +sub getsetup () { #{{{ return git_wrapper => { type => "string", @@ -73,9 +87,9 @@ hook(type => "getsetup", id => "git", call => sub { #{{{ safe => 0, # paranoia rebuild => 0, }, -}); #}}} +} #}}} -sub _safe_git (&@) { #{{{ +sub safe_git (&@) { #{{{ # Start a child process safely without resorting /bin/sh. # Return command output or success state (in scalar context). @@ -107,12 +121,12 @@ sub _safe_git (&@) { #{{{ return wantarray ? @lines : ($? == 0); } # Convenient wrappers. -sub run_or_die ($@) { _safe_git(\&error, @_) } -sub run_or_cry ($@) { _safe_git(sub { warn @_ }, @_) } -sub run_or_non ($@) { _safe_git(undef, @_) } +sub run_or_die ($@) { safe_git(\&error, @_) } +sub run_or_cry ($@) { safe_git(sub { warn @_ }, @_) } +sub run_or_non ($@) { safe_git(undef, @_) } #}}} -sub _merge_past ($$$) { #{{{ +sub merge_past ($$$) { #{{{ # Unlike with Subversion, Git cannot make a 'svn merge -rN:M file'. # Git merge commands work with the committed changes, except in the # implicit case of '-m' of git checkout(1). So we should invent a @@ -206,7 +220,7 @@ sub _merge_past ($$$) { #{{{ return $conflict; } #}}} -sub _parse_diff_tree ($@) { #{{{ +sub parse_diff_tree ($@) { #{{{ # Parse the raw diff tree chunk and return the info hash. # See git-diff-tree(1) for the syntax. @@ -326,7 +340,7 @@ sub git_commit_info ($;$) { #{{{ my ($prefix) = run_or_die('git', 'rev-parse', '--show-prefix'); my @ci; - while (my $parsed = _parse_diff_tree(($prefix or ""), \@raw_lines)) { + while (my $parsed = parse_diff_tree(($prefix or ""), \@raw_lines)) { push @ci, $parsed; } @@ -379,7 +393,7 @@ sub rcs_commit ($$$;$$) { #{{{ my ($prev) = $rcstoken =~ /^($sha1_pattern)$/; # untaint if (defined $cur && defined $prev && $cur ne $prev) { - my $conflict = _merge_past($prev, $file, $dummy_commit_msg); + my $conflict = merge_past($prev, $file, $dummy_commit_msg); return $conflict if defined $conflict; } @@ -402,7 +416,7 @@ sub rcs_commit_staged ($$$) { # git commit returns non-zero if file has not been really changed. # so we should ignore its exit status (hence run_or_non). - $message = possibly_foolish_untaint($message); + $message = IkiWiki::possibly_foolish_untaint($message); if (run_or_non('git', 'commit', '--cleanup=verbatim', '-q', '-m', $message)) { if (length $config{gitorigin_branch}) { diff --git a/IkiWiki/Plugin/mercurial.pm b/IkiWiki/Plugin/mercurial.pm index 3a98e09d8..738be8c32 100644 --- a/IkiWiki/Plugin/mercurial.pm +++ b/IkiWiki/Plugin/mercurial.pm @@ -1,6 +1,5 @@ #!/usr/bin/perl - -package IkiWiki; +package IkiWiki::Plugin::mercurial; use warnings; use strict; @@ -8,19 +7,34 @@ use IkiWiki; use Encode; use open qw{:utf8 :std}; -hook(type => "checkconfig", id => "mercurial", call => sub { #{{{ +sub import { #{{{ + hook(type => "checkconfig", id => "mercurial", call => \&checkconfig); + hook(type => "getsetup", id => "mercurial", call => \&getsetup); + hook(type => "rcs", id => "rcs_update", call => \&rcs_update); + hook(type => "rcs", id => "rcs_prepedit", call => \&rcs_prepedit); + hook(type => "rcs", id => "rcs_commit", call => \&rcs_commit); + hook(type => "rcs", id => "rcs_commit_staged", call => \&rcs_commit_staged); + hook(type => "rcs", id => "rcs_add", call => \&rcs_add); + hook(type => "rcs", id => "rcs_remove", call => \&rcs_remove); + hook(type => "rcs", id => "rcs_rename", call => \&rcs_rename); + hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges); + hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff); + hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime); +} #}}} + +sub checkconfig () { #{{{ if (! defined $config{diffurl}) { $config{diffurl}=""; } - if (length $config{mercurial_wrapper}) { + if (exists $config{mercurial_wrapper} && length $config{mercurial_wrapper}) { push @{$config{wrappers}}, { wrapper => $config{mercurial_wrapper}, wrappermode => (defined $config{mercurial_wrappermode} ? $config{mercurial_wrappermode} : "06755"), }; } -}); #}}} +} #}}} -hook(type => "getsetup", id => "mercurial", call => sub { #{{{ +sub getsetup () { #{{{ return mercurial_wrapper => { type => "string", @@ -50,7 +64,7 @@ hook(type => "getsetup", id => "mercurial", call => sub { #{{{ safe => 1, rebuild => 1, }, -}); #}}} +} #}}} sub mercurial_log ($) { #{{{ my $out = shift; @@ -113,16 +127,16 @@ sub rcs_commit ($$$;$$) { #{{{ my ($file, $message, $rcstoken, $user, $ipaddr) = @_; if (defined $user) { - $user = possibly_foolish_untaint($user); + $user = IkiWiki::possibly_foolish_untaint($user); } elsif (defined $ipaddr) { - $user = "Anonymous from ".possibly_foolish_untaint($ipaddr); + $user = "Anonymous from ".IkiWiki::possibly_foolish_untaint($ipaddr); } else { $user = "Anonymous"; } - $message = possibly_foolish_untaint($message); + $message = IkiWiki::possibly_foolish_untaint($message); if (! length $message) { $message = "no message given"; } diff --git a/IkiWiki/Plugin/monotone.pm b/IkiWiki/Plugin/monotone.pm index d7e8f296a..4b9be316a 100644 --- a/IkiWiki/Plugin/monotone.pm +++ b/IkiWiki/Plugin/monotone.pm @@ -1,6 +1,5 @@ #!/usr/bin/perl - -package IkiWiki; +package IkiWiki::Plugin::monotone; use warnings; use strict; @@ -11,7 +10,22 @@ use Date::Format qw(time2str); my $sha1_pattern = qr/[0-9a-fA-F]{40}/; # pattern to validate sha1sums -hook(type => "checkconfig", id => "monotone", call => sub { #{{{ +sub import { #{{{ + hook(type => "checkconfig", id => "monotone", call => \&checkconfig); + hook(type => "getsetup", id => "monotone", call => \&getsetup); + hook(type => "rcs", id => "rcs_update", call => \&rcs_update); + hook(type => "rcs", id => "rcs_prepedit", call => \&rcs_prepedit); + hook(type => "rcs", id => "rcs_commit", call => \&rcs_commit); + hook(type => "rcs", id => "rcs_commit_staged", call => \&rcs_commit_staged); + hook(type => "rcs", id => "rcs_add", call => \&rcs_add); + hook(type => "rcs", id => "rcs_remove", call => \&rcs_remove); + hook(type => "rcs", id => "rcs_rename", call => \&rcs_rename); + hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges); + hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff); + hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime); +} #}}} + +sub checkconfig () { #{{{ if (!defined($config{mtnrootdir})) { $config{mtnrootdir} = $config{srcdir}; } @@ -47,9 +61,9 @@ hook(type => "checkconfig", id => "monotone", call => sub { #{{{ wrappermode => (defined $config{mtn_wrappermode} ? $config{mtn_wrappermode} : "06755"), }; } -}); #}}} +} #}}} -hook(type => "getsetup", id => "monotone", call => sub { #{{{ +sub getsetup () { #{{{ return mtn_wrapper => { type => "string", @@ -99,7 +113,7 @@ hook(type => "getsetup", id => "monotone", call => sub { #{{{ safe => 0, # path rebuild => 0, }, -}); #}}} +} #}}} sub get_rev () { #{{{ my $sha1 = `mtn --root=$config{mtnrootdir} automate get_base_revision_id`; @@ -156,7 +170,7 @@ sub mtn_merge ($$$$) { #{{{ return $mergeRev; } #}}} -sub commit_file_to_new_rev($$$$$$$$) { #{{{ +sub commit_file_to_new_rev ($$$$$$$$) { #{{{ my $automator=shift; my $wsfilename=shift; my $oldFileID=shift; @@ -398,7 +412,7 @@ sub rcs_commit ($$$;$$) { #{{{ if (system("mtn", "--root=$config{mtnrootdir}", "commit", "--quiet", "--author", $author, "--key", $config{mtnkey}, "-m", - possibly_foolish_untaint($message), $file) != 0) { + IkiWiki::possibly_foolish_untaint($message), $file) != 0) { debug("Traditional commit failed! Returning data as conflict."); my $conflict=readfile("$config{srcdir}/$file"); if (system("mtn", "--root=$config{mtnrootdir}", "revert", @@ -443,7 +457,7 @@ sub rcs_commit_staged ($$$) { if (system("mtn", "--root=$config{mtnrootdir}", "commit", "--quiet", "--author", $author, "--key", $config{mtnkey}, "-m", - possibly_foolish_untaint($message)) != 0) { + IkiWiki::possibly_foolish_untaint($message)) != 0) { error("Monotone commit failed"); } } diff --git a/IkiWiki/Plugin/norcs.pm b/IkiWiki/Plugin/norcs.pm index 04ba5f028..72c66569c 100644 --- a/IkiWiki/Plugin/norcs.pm +++ b/IkiWiki/Plugin/norcs.pm @@ -1,99 +1,58 @@ #!/usr/bin/perl # Stubs for no revision control. - -package IkiWiki; +package IkiWiki::Plugin::norcs; use warnings; use strict; use IkiWiki; -sub rcs_update () { - # Update working directory to current version. - # (May be more complex for distributed RCS.) -} - -sub rcs_prepedit ($) { - # Prepares to edit a file under revision control. Returns a token - # that must be passed into rcs_commit when the file is ready - # for committing. - # The file is relative to the srcdir. +sub import { #{{{ + hook(type => "rcs", id => "rcs_update", call => \&rcs_update); + hook(type => "rcs", id => "rcs_prepedit", call => \&rcs_prepedit); + hook(type => "rcs", id => "rcs_commit", call => \&rcs_commit); + hook(type => "rcs", id => "rcs_commit_staged", call => \&rcs_commit_staged); + hook(type => "rcs", id => "rcs_add", call => \&rcs_add); + hook(type => "rcs", id => "rcs_remove", call => \&rcs_remove); + hook(type => "rcs", id => "rcs_rename", call => \&rcs_rename); + hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges); + hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff); + hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime); +} #}}} + +sub rcs_update () { #{{{ +} #}}} + +sub rcs_prepedit ($) { #{{{ return "" -} +} #}}} -sub rcs_commit ($$$;$$) { - # Tries to commit the page; returns undef on _success_ and - # a version of the page with the rcs's conflict markers on failure. - # The file is relative to the srcdir. +sub rcs_commit ($$$;$$) { #{{{ my ($file, $message, $rcstoken, $user, $ipaddr) = @_; return undef # success -} +} #}}} -sub rcs_commit_staged ($$$) { - # Commits all staged changes. Changes can be staged using rcs_add, - # rcs_remove, and rcs_rename. +sub rcs_commit_staged ($$$) { #{{{ my ($message, $user, $ipaddr)=@_; return undef # success -} +} #}}} -sub rcs_add ($) { - # Add a file. The filename is relative to the root of the srcdir. - # Note that this should not check the new file in, it should only - # prepare for it to be checked in when rcs_commit is called. - # Note that the file may be in a new subdir that is not yet added - # to version control; the subdir can be added if so. -} +sub rcs_add ($) { #{{{ +} #}}} -sub rcs_remove ($) { - # Remove a file. The filename is relative to the root of the srcdir. - # Note that this should not check the removal in, it should only - # prepare for it to be checked in when rcs_commit is called. - # Note that the new file may be in a new subdir that is not yet added - # to version control; the subdir can be added if so. -} +sub rcs_remove ($) { #{{{ +} #}}} -sub rcs_rename ($$) { - # Rename a file. The filenames are relative to the root of the srcdir. - # Note that this should not commit the rename, it should only - # prepare it for when rcs_commit is called. - # The new filename may be in a new subdir, that is not yet added to - # version control. If so, the subdir will exist already, and should - # be added to revision control. -} +sub rcs_rename ($$) { #{{{ +} #}}} -sub rcs_recentchanges ($) { - # Examine the RCS history and generate a list of recent changes. - # The data structure returned for each change is: - # { - # rev => # the RCSs id for this commit - # user => # name of user who made the change, - # committype => # either "web" or the name of the rcs, - # when => # time when the change was made, - # message => [ - # { line => "commit message line" }, - # { line => "commit message line" }, - # # etc, - # ], - # pages => [ - # { - # page => # name of page changed, - # diffurl => # optional url to a diff showing - # # the changes, - # }, - # # repeat for each page changed in this commit, - # ], - # } -} +sub rcs_recentchanges ($) { #{{{ +} #}}} -sub rcs_diff ($) { - # Optional, used to get diffs for recentchanges. - # The parameter is the rev from rcs_recentchanges. - # Should return a list of lines of the diff (including \n) in list - # context, and the whole diff in scalar context. -} +sub rcs_diff ($) { #{{{ +} #}}} -sub rcs_getctime ($) { - # Optional, used to get the page creation time from the RCS. +sub rcs_getctime ($) { #{{{ error gettext("getctime not implemented"); -} +} #}}} 1 diff --git a/IkiWiki/Plugin/svn.pm b/IkiWiki/Plugin/svn.pm index 0e7df3659..05312a1ed 100644 --- a/IkiWiki/Plugin/svn.pm +++ b/IkiWiki/Plugin/svn.pm @@ -1,13 +1,27 @@ #!/usr/bin/perl - -package IkiWiki; +package IkiWiki::Plugin::svn; use warnings; use strict; use IkiWiki; use POSIX qw(setlocale LC_CTYPE); -hook(type => "checkconfig", id => "svn", call => sub { #{{{ +sub import { #{{{ + hook(type => "checkconfig", id => "svn", call => \&checkconfig); + hook(type => "getsetup", id => "svn", call => \&getsetup); + hook(type => "rcs", id => "rcs_update", call => \&rcs_update); + hook(type => "rcs", id => "rcs_prepedit", call => \&rcs_prepedit); + hook(type => "rcs", id => "rcs_commit", call => \&rcs_commit); + hook(type => "rcs", id => "rcs_commit_staged", call => \&rcs_commit_staged); + hook(type => "rcs", id => "rcs_add", call => \&rcs_add); + hook(type => "rcs", id => "rcs_remove", call => \&rcs_remove); + hook(type => "rcs", id => "rcs_rename", call => \&rcs_rename); + hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges); + hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff); + hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime); +} #}}} + +sub checkconfig () { #{{{ if (! defined $config{diffurl}) { $config{diffurl}=""; } @@ -20,15 +34,15 @@ hook(type => "checkconfig", id => "svn", call => sub { #{{{ $config{svnpath}=~s/\/$//; $config{svnpath}=~s/^\///; } - if (length $config{svn_wrapper}) { + if (defined $config{svn_wrapper} && length $config{svn_wrapper}) { push @{$config{wrappers}}, { wrapper => $config{svn_wrapper}, wrappermode => (defined $config{svn_wrappermode} ? $config{svn_wrappermode} : "04755"), }; } -}); #}}} +} #}}} -hook(type => "getsetup", id => "svn", call => sub { #{{{ +sub getsetup () { #{{{ return svnrepo => { type => "string", @@ -72,7 +86,7 @@ hook(type => "getsetup", id => "svn", call => sub { #{{{ safe => 1, rebuild => 1, }, -}); #}}} +} #}}} # svn needs LC_CTYPE set to a UTF-8 locale, so try to find one. Any will do. sub find_lc_ctype() { @@ -160,7 +174,7 @@ sub rcs_commit ($$$;$$) { #{{{ if (system("svn", "commit", "--quiet", "--encoding", "UTF-8", "-m", - possibly_foolish_untaint($message), + IkiWiki::possibly_foolish_untaint($message), $config{srcdir}) != 0) { my $conflict=readfile("$config{srcdir}/$file"); if (system("svn", "revert", "--quiet", "$config{srcdir}/$file") != 0) { @@ -186,7 +200,7 @@ sub rcs_commit_staged ($$$) { if (system("svn", "commit", "--quiet", "--encoding", "UTF-8", "-m", - possibly_foolish_untaint($message), + IkiWiki::possibly_foolish_untaint($message), $config{srcdir}) != 0) { warn("svn commit failed\n"); return 1; # failure @@ -199,10 +213,10 @@ sub rcs_add ($) { #{{{ my $file=shift; if (-d "$config{srcdir}/.svn") { - my $parent=dirname($file); + my $parent=IkiWiki::dirname($file); while (! -d "$config{srcdir}/$parent/.svn") { $file=$parent; - $parent=dirname($file); + $parent=IkiWiki::dirname($file); } if (system("svn", "add", "--quiet", "$config{srcdir}/$file") != 0) { @@ -329,7 +343,7 @@ sub rcs_recentchanges ($) { #{{{ } #}}} sub rcs_diff ($) { #{{{ - my $rev=possibly_foolish_untaint(int(shift)); + my $rev=IkiWiki::possibly_foolish_untaint(int(shift)); return `svnlook diff $config{svnrepo} -r$rev --no-diff-deleted`; } #}}} diff --git a/IkiWiki/Plugin/tla.pm b/IkiWiki/Plugin/tla.pm index e1389a346..b95c1a522 100644 --- a/IkiWiki/Plugin/tla.pm +++ b/IkiWiki/Plugin/tla.pm @@ -1,24 +1,38 @@ #!/usr/bin/perl - -package IkiWiki; +package IkiWiki::Plugin::tla; use warnings; use strict; use IkiWiki; -hook(type => "checkconfig", id => "tla", call => sub { #{{{ +sub import { #{{{ + hook(type => "checkconfig", id => "tla", call => \&checkconfig); + hook(type => "getsetup", id => "tla", call => \&getsetup); + hook(type => "rcs", id => "rcs_update", call => \&rcs_update); + hook(type => "rcs", id => "rcs_prepedit", call => \&rcs_prepedit); + hook(type => "rcs", id => "rcs_commit", call => \&rcs_commit); + hook(type => "rcs", id => "rcs_commit_staged", call => \&rcs_commit_staged); + hook(type => "rcs", id => "rcs_add", call => \&rcs_add); + hook(type => "rcs", id => "rcs_remove", call => \&rcs_remove); + hook(type => "rcs", id => "rcs_rename", call => \&rcs_rename); + hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges); + hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff); + hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime); +} #}}} + +sub checkconfig () { #{{{ if (! defined $config{diffurl}) { $config{diffurl}=""; } - if (length $config{tla_wrapper}) { + if (defined $config{tla_wrapper} && length $config{tla_wrapper}) { push @{$config{wrappers}}, { wrapper => $config{tla_wrapper}, wrappermode => (defined $config{tla_wrappermode} ? $config{tla_wrappermode} : "06755"), }; } -}); #}}} +} #}}} -hook(type => "getsetup", id => "tla", call => sub { #{{{ +sub getsetup () { #{{{ return tla_wrapper => { type => "string", @@ -48,9 +62,9 @@ hook(type => "getsetup", id => "tla", call => sub { #{{{ safe => 1, rebuild => 1, }, -}); #}}} +} #}}} -sub quiet_system (@) { +sub quiet_system (@) { #{{{ # See Debian bug #385939. open (SAVEOUT, ">&STDOUT"); close STDOUT; @@ -60,7 +74,7 @@ sub quiet_system (@) { open (STDOUT, ">&SAVEOUT"); close SAVEOUT; return $ret; -} +} #}}} sub rcs_update () { #{{{ if (-d "$config{srcdir}/{arch}") { @@ -110,7 +124,7 @@ sub rcs_commit ($$$;$$) { #{{{ } if (quiet_system("tla", "commit", - "-L".possibly_foolish_untaint($message), + "-L".IkiWiki::possibly_foolish_untaint($message), '-d', $config{srcdir}) != 0) { my $conflict=readfile("$config{srcdir}/$file"); if (system("tla", "undo", "-n", "--quiet", "-d", "$config{srcdir}") != 0) { |