diff options
Diffstat (limited to 'IkiWiki/Rcs')
-rw-r--r-- | IkiWiki/Rcs/Stub.pm | 21 | ||||
-rw-r--r-- | IkiWiki/Rcs/bzr.pm | 14 | ||||
-rw-r--r-- | IkiWiki/Rcs/git.pm | 22 | ||||
-rw-r--r-- | IkiWiki/Rcs/mercurial.pm | 14 | ||||
-rw-r--r-- | IkiWiki/Rcs/monotone.pm | 14 | ||||
-rw-r--r-- | IkiWiki/Rcs/svn.pm | 51 | ||||
-rw-r--r-- | IkiWiki/Rcs/tla.pm | 14 |
7 files changed, 141 insertions, 9 deletions
diff --git a/IkiWiki/Rcs/Stub.pm b/IkiWiki/Rcs/Stub.pm index 375591c96..43a2f2029 100644 --- a/IkiWiki/Rcs/Stub.pm +++ b/IkiWiki/Rcs/Stub.pm @@ -24,6 +24,14 @@ 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. + 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. + my ($message, $user, $ipaddr)=@_; return undef # success } @@ -31,12 +39,25 @@ 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_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_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. } sub rcs_recentchanges ($) { diff --git a/IkiWiki/Rcs/bzr.pm b/IkiWiki/Rcs/bzr.pm index ca60190ea..e414e85d2 100644 --- a/IkiWiki/Rcs/bzr.pm +++ b/IkiWiki/Rcs/bzr.pm @@ -80,6 +80,14 @@ sub rcs_commit ($$$;$$) { #{{{ return undef; # success } #}}} +sub rcs_commit_staged ($$$) { + # Commits all staged changes. Changes can be staged using rcs_add, + # rcs_remove, and rcs_rename. + my ($message, $user, $ipaddr)=@_; + + error("rcs_commit_staged not implemented for bzr"); # TODO +} + sub rcs_add ($) { # {{{ my ($file) = @_; @@ -95,6 +103,12 @@ sub rcs_remove ($) { # {{{ error("rcs_remove not implemented for bzr"); # TODO } #}}} +sub rcs_rename ($$) { # {{{ + my ($src, $dest) = @_; + + error("rcs_rename not implemented for bzr"); # TODO +} #}}} + sub rcs_recentchanges ($) { #{{{ my ($num) = @_; diff --git a/IkiWiki/Rcs/git.pm b/IkiWiki/Rcs/git.pm index b02b286bd..ecf560d0b 100644 --- a/IkiWiki/Rcs/git.pm +++ b/IkiWiki/Rcs/git.pm @@ -318,7 +318,16 @@ sub rcs_commit ($$$;$$) { #{{{ my $conflict = _merge_past($prev, $file, $dummy_commit_msg); return $conflict if defined $conflict; } - + + rcs_add($file); + return rcs_commit_staged($message, $user, $ipaddr); +} #}}} + +sub rcs_commit_staged ($$$) { + # Commits all staged changes. Changes can be staged using rcs_add, + # rcs_remove, and rcs_rename. + my ($message, $user, $ipaddr)=@_; + # Set the commit author and email to the web committer. my %env=%ENV; if (defined $user || defined $ipaddr) { @@ -330,7 +339,8 @@ sub rcs_commit ($$$;$$) { #{{{ # 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); - if (run_or_non('git', 'commit', '--cleanup=verbatim', '-q', '-m', $message, '-i', $file)) { + if (run_or_non('git', 'commit', '--cleanup=verbatim', + '-q', '-m', $message)) { if (length $config{gitorigin_branch}) { run_or_cry('git', 'push', $config{gitorigin_branch}); } @@ -338,7 +348,7 @@ sub rcs_commit ($$$;$$) { #{{{ %ENV=%env; return undef; # success -} #}}} +} sub rcs_add ($) { # {{{ # Add file to archive. @@ -356,6 +366,12 @@ sub rcs_remove ($) { # {{{ run_or_cry('git', 'rm', '-f', $file); } #}}} +sub rcs_rename ($$) { # {{{ + my ($src, $dest) = @_; + + run_or_cry('git', 'mv', '-f', $src, $dest); +} #}}} + sub rcs_recentchanges ($) { #{{{ # List of recent changes. diff --git a/IkiWiki/Rcs/mercurial.pm b/IkiWiki/Rcs/mercurial.pm index 1bfcf6242..8c3f03e07 100644 --- a/IkiWiki/Rcs/mercurial.pm +++ b/IkiWiki/Rcs/mercurial.pm @@ -92,6 +92,14 @@ sub rcs_commit ($$$;$$) { #{{{ return undef; # success } #}}} +sub rcs_commit_staged ($$$) { + # Commits all staged changes. Changes can be staged using rcs_add, + # rcs_remove, and rcs_rename. + my ($message, $user, $ipaddr)=@_; + + error("rcs_commit_staged not implemented for mercurial"); # TODO +} + sub rcs_add ($) { # {{{ my ($file) = @_; @@ -107,6 +115,12 @@ sub rcs_remove ($) { # {{{ error("rcs_remove not implemented for mercurial"); # TODO } #}}} +sub rcs_rename ($$) { # {{{ + my ($src, $dest) = @_; + + error("rcs_rename not implemented for mercurial"); # TODO +} #}}} + sub rcs_recentchanges ($) { #{{{ my ($num) = @_; diff --git a/IkiWiki/Rcs/monotone.pm b/IkiWiki/Rcs/monotone.pm index 948edac0a..97d9c7a30 100644 --- a/IkiWiki/Rcs/monotone.pm +++ b/IkiWiki/Rcs/monotone.pm @@ -359,6 +359,14 @@ sub rcs_commit ($$$;$$) { #{{{ return undef # success } #}}} +sub rcs_commit_staged ($$$) { + # Commits all staged changes. Changes can be staged using rcs_add, + # rcs_remove, and rcs_rename. + my ($message, $user, $ipaddr)=@_; + + error("rcs_commit_staged not implemented for monotone"); # TODO +} + sub rcs_add ($) { #{{{ my $file=shift; @@ -376,6 +384,12 @@ sub rcs_remove ($) { # {{{ error("rcs_remove not implemented for monotone"); # TODO } #}}} +sub rcs_rename ($$) { # {{{ + my ($src, $dest) = @_; + + error("rcs_rename not implemented for monotone"); # TODO +} #}}} + sub rcs_recentchanges ($) { #{{{ my $num=shift; my @ret; diff --git a/IkiWiki/Rcs/svn.pm b/IkiWiki/Rcs/svn.pm index 6c15c2ca9..9081c3902 100644 --- a/IkiWiki/Rcs/svn.pm +++ b/IkiWiki/Rcs/svn.pm @@ -117,6 +117,28 @@ sub rcs_commit ($$$;$$) { #{{{ return undef # success } #}}} +sub rcs_commit_staged ($$$) { + # Commits all staged changes. Changes can be staged using rcs_add, + # rcs_remove, and rcs_rename. + my ($message, $user, $ipaddr)=@_; + + if (defined $user) { + $message="web commit by $user".(length $message ? ": $message" : ""); + } + elsif (defined $ipaddr) { + $message="web commit from $ipaddr".(length $message ? ": $message" : ""); + } + + if (system("svn", "commit", "--quiet", + "--encoding", "UTF-8", "-m", + possibly_foolish_untaint($message), + $config{srcdir}) != 0) { + warn("svn commit failed\n"); + return 1; # failure + } + return undef # success +} + sub rcs_add ($) { #{{{ # filename is relative to the root of the srcdir my $file=shift; @@ -139,18 +161,35 @@ sub rcs_remove ($) { #{{{ my $file=shift; if (-d "$config{srcdir}/.svn") { - my $parent=dirname($file); - while (! -d "$config{srcdir}/$parent/.svn") { - $file=$parent; - $parent=dirname($file); - } - if (system("svn", "rm", "--force", "--quiet", "$config{srcdir}/$file") != 0) { warn("svn rm failed\n"); } } } #}}} +sub rcs_rename ($$) { #{{{ + # filenames relative to the root of the srcdir + my ($src, $dest)=@_; + + if (-d "$config{srcdir}/.svn") { + # Add parent directory for $dest + my $parent=dirname($dest); + if (! -d "$config{srcdir}/$parent/.svn") { + while (! -d "$config{srcdir}/$parent/.svn") { + $parent=dirname($dest); + } + if (system("svn", "add", "--quiet", "$config{srcdir}/$parent") != 0) { + warn("svn add $parent failed\n"); + } + } + + if (system("svn", "mv", "--force", "--quiet", + "$config{srcdir}/$src", "$config{srcdir}/$dest") != 0) { + warn("svn rename failed\n"); + } + } +} #}}} + sub rcs_recentchanges ($) { #{{{ my $num=shift; my @ret; diff --git a/IkiWiki/Rcs/tla.pm b/IkiWiki/Rcs/tla.pm index 29dbd092a..4232e1fe8 100644 --- a/IkiWiki/Rcs/tla.pm +++ b/IkiWiki/Rcs/tla.pm @@ -78,6 +78,14 @@ sub rcs_commit ($$$;$$) { #{{{ return undef # success } #}}} +sub rcs_commit_staged ($$$) { + # Commits all staged changes. Changes can be staged using rcs_add, + # rcs_remove, and rcs_rename. + my ($message, $user, $ipaddr)=@_; + + error("rcs_commit_staged not implemented for tla"); # TODO +} + sub rcs_add ($) { #{{{ my $file=shift; @@ -94,6 +102,12 @@ sub rcs_remove ($) { # {{{ error("rcs_remove not implemented for tla"); # TODO } #}}} +sub rcs_rename ($$) { # {{{a + my ($src, $dest) = @_; + + error("rcs_rename not implemented for tla"); # TODO +} #}}} + sub rcs_recentchanges ($) { my $num=shift; my @ret; |