aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-03-19 19:09:57 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-03-19 19:09:57 +0000
commit3c239b14bc84e33535cb8980fcdcf8ab5d1022eb (patch)
treebd46644a5b284d567f403ba83de1a8b2e013cdb1
parentc7e9c3692622d8f568cf300189dfe15ff5113717 (diff)
downloadikiwiki-3c239b14bc84e33535cb8980fcdcf8ab5d1022eb.tar
ikiwiki-3c239b14bc84e33535cb8980fcdcf8ab5d1022eb.tar.gz
first cut at svn merge and conflict
-rwxr-xr-xikiwiki33
-rw-r--r--templates/editpage.tmpl7
2 files changed, 36 insertions, 4 deletions
diff --git a/ikiwiki b/ikiwiki
index c2310cb37..db0056aa4 100755
--- a/ikiwiki
+++ b/ikiwiki
@@ -461,19 +461,34 @@ sub rcs_update () { #{{{
}
} #}}}
-sub rcs_commit ($) { #{{{
+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 $message=shift;
+ my $file=shift;
if (-d "$config{srcdir}/.svn") {
+ # svn up to let svn merge in other changes
+ if (system("svn", "update", "$config{srcdir}/$file") != 0) {
+ warn("svn update failed\n");
+ }
if (system("svn", "commit", "--quiet", "-m",
possibly_foolish_untaint($message),
- $config{srcdir}) != 0) {
+ "$config{srcdir}/$file") != 0) {
warn("svn commit failed\n");
+ my $conflict=readfile("$config{srcdir}/$file");
+ if (system("svn", "revert", "$config{srcdir}/$file") != 0) {
+ warn("svn revert failed\n");
+ }
+ return $conflict;
}
}
+ return undef # success
} #}}}
sub rcs_add ($) { #{{{
+ # filename is relative to the root of the srcdir
my $file=shift;
if (-d "$config{srcdir}/.svn") {
@@ -1016,6 +1031,7 @@ sub cgi_editpage ($$) { #{{{
table => 0,
template => "$config{templatedir}/editpage.tmpl"
);
+ my @buttons=("Save Page", "Preview", "Cancel");
my ($page)=$form->param('page')=~/$config{wiki_file_regexp}/;
if (! defined $page || ! length $page || $page ne $q->param('page') ||
@@ -1043,6 +1059,7 @@ sub cgi_editpage ($$) { #{{{
else {
$form->tmpl_param("page_preview", "");
}
+ $form->tmpl_param("page_conflict", "");
if (! $form->submitted || $form->submitted eq "Preview" ||
! $form->validate) {
@@ -1099,7 +1116,7 @@ sub cgi_editpage ($$) { #{{{
$form->tmpl_param("can_commit", $config{svn});
$form->tmpl_param("indexlink", indexlink());
- print $form->render(submit => ["Save Page", "Preview", "Cancel"]);
+ print $form->render(submit => \@buttons);
}
else {
# save page
@@ -1135,7 +1152,15 @@ sub cgi_editpage ($$) { #{{{
unlockwiki();
# presumably the commit will trigger an update
# of the wiki
- rcs_commit($message);
+ my $conflict=rcs_commit($file, $message);
+
+ if (defined $conflict) {
+ $form->tmpl_param("page_conflict", 1);
+ $form->field("content", $conflict);
+ $form->field("do", "edit)");
+ print $form->render(submit => \@buttons);
+ return;
+ }
}
else {
loadindex();
diff --git a/templates/editpage.tmpl b/templates/editpage.tmpl
index d02eaad70..6aa9ecd1c 100644
--- a/templates/editpage.tmpl
+++ b/templates/editpage.tmpl
@@ -1,6 +1,13 @@
<html>
<head><title><TMPL_VAR FORM-TITLE></title></head>
<body>
+<TMPL_IF NAME="PAGE_CONFLICT">
+<p>
+<b>Your changes confict with other changes made to the page.</b>
+Conflict markers have been inserted into the page content. Reconcile the
+confict and commit again to save your changes.
+</p>
+</TMPL_IF>
<TMPL_VAR FORM-START>
<h1><TMPL_VAR INDEXLINK>/ <TMPL_VAR FORM-TITLE></h1>
<TMPL_VAR FIELD-DO>