aboutsummaryrefslogtreecommitdiff
path: root/IkiWiki/Rcs
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-07-22 16:14:33 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-07-22 16:14:33 -0400
commitcbddb5a4b8e0e2fb63886ad9d1cf8a087cdb83b1 (patch)
treefab8316d385e89d959189cc199e79457dcb90486 /IkiWiki/Rcs
parentcf9620074acb1309118f08094229ce21d7352ed0 (diff)
downloadikiwiki-cbddb5a4b8e0e2fb63886ad9d1cf8a087cdb83b1.tar
ikiwiki-cbddb5a4b8e0e2fb63886ad9d1cf8a087cdb83b1.tar.gz
add rcs_commit_staged and rcs_rename
Implemented for git and svn so far. Note that rcs_commit_staged does assume that the rcs has the ability to "stage" multiple changes for a later commit. Support for this varies, but all we really care about is staging removals and renames, which, AFAIK, all modern rcs's support.
Diffstat (limited to 'IkiWiki/Rcs')
-rw-r--r--IkiWiki/Rcs/Stub.pm21
-rw-r--r--IkiWiki/Rcs/bzr.pm14
-rw-r--r--IkiWiki/Rcs/git.pm22
-rw-r--r--IkiWiki/Rcs/mercurial.pm14
-rw-r--r--IkiWiki/Rcs/monotone.pm14
-rw-r--r--IkiWiki/Rcs/svn.pm51
-rw-r--r--IkiWiki/Rcs/tla.pm14
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;