updated from pesco's darcs repo, current to Oct 11 version
parent
1f7f5d5e0e
commit
7eb512205f
|
@ -60,38 +60,8 @@ sub import {
|
|||
}
|
||||
|
||||
|
||||
# Which darcs executable to use.
|
||||
my $darcs = ($ENV{DARCS} or 'darcs');
|
||||
|
||||
|
||||
# Internal functions
|
||||
|
||||
our %cache;
|
||||
|
||||
sub loadcache () {
|
||||
my $repodir=$config{srcdir};
|
||||
if (!defined %cache) {
|
||||
my $f = "$repodir/.ikiwiki.ctimes";
|
||||
if (-s "$f") {
|
||||
my $VAR1;
|
||||
my $x = `cat "$f"`;
|
||||
$x =~ /^(.*)$/sm; # untaint
|
||||
eval "$1";
|
||||
%cache = %$VAR1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
END {
|
||||
my $repodir=$config{srcdir};
|
||||
if (defined %cache) {
|
||||
debug("dumping ctime cache to $repodir/.ikiwiki.ctimes");
|
||||
open CACHE, ">$repodir/.ikiwiki.ctimes";
|
||||
print CACHE Dumper(\%cache);
|
||||
close CACHE;
|
||||
}
|
||||
}
|
||||
|
||||
sub silentsystem (@) {
|
||||
open(SAVED_STDOUT, ">&STDOUT");
|
||||
open(STDOUT, ">/dev/null");
|
||||
|
@ -107,7 +77,7 @@ sub darcs_info ($$$) {
|
|||
|
||||
my $child = open(DARCS_CHANGES, "-|");
|
||||
if (! $child) {
|
||||
exec($darcs, 'changes', '--repodir', $repodir, '--xml-output', $file) or
|
||||
exec('darcs', 'changes', '--repodir', $repodir, '--xml-output', $file) or
|
||||
error("failed to run 'darcs changes'");
|
||||
}
|
||||
|
||||
|
@ -129,7 +99,7 @@ sub darcs_rev($) {
|
|||
|
||||
my $child = open(DARCS_MANIFEST, "-|");
|
||||
if (! $child) {
|
||||
exec($darcs, 'query', 'manifest', '--repodir', $repodir) or
|
||||
exec('darcs', 'query', 'manifest', '--repodir', $repodir) or
|
||||
error("failed to run 'darcs query manifest'");
|
||||
}
|
||||
my $found=0;
|
||||
|
@ -192,7 +162,7 @@ sub getsetup() {
|
|||
}
|
||||
|
||||
sub rcs_update () {
|
||||
silentsystem($darcs, "pull", "--repodir", $config{srcdir}, "-qa")
|
||||
silentsystem('darcs', "pull", "--repodir", $config{srcdir}, "-qa")
|
||||
}
|
||||
|
||||
sub rcs_prepedit ($) {
|
||||
|
@ -231,13 +201,13 @@ sub rcs_commit ($$$;$$) {
|
|||
# We need to revert everything as 'darcs obliterate' might choke
|
||||
# otherwise.
|
||||
# TODO: 'yes | ...' needed? Doesn't seem so.
|
||||
silentsystem($darcs, "revert", "--repodir", $config{srcdir}, "--all") and
|
||||
silentsystem('darcs', "revert", "--repodir", $config{srcdir}, "--all") and
|
||||
error("'darcs revert' failed");
|
||||
# Remove all patches starting at $rcstoken.
|
||||
my $child = open(DARCS_OBLITERATE, "|-");
|
||||
if (! $child) {
|
||||
open(STDOUT, ">/dev/null");
|
||||
exec($darcs, "obliterate", "--repodir", $config{srcdir},
|
||||
exec('darcs', "obliterate", "--repodir", $config{srcdir},
|
||||
"--match", "hash " . $rcstoken) and
|
||||
error("'darcs obliterate' failed");
|
||||
}
|
||||
|
@ -246,7 +216,7 @@ sub rcs_commit ($$$;$$) {
|
|||
}
|
||||
close(DARCS_OBLITERATE);
|
||||
# Restore the $rcstoken one.
|
||||
silentsystem($darcs, "pull", "--quiet", "--repodir", $config{srcdir},
|
||||
silentsystem('darcs', "pull", "--quiet", "--repodir", $config{srcdir},
|
||||
"--match", "hash " . $rcstoken, "--all") and
|
||||
error("'darcs pull' failed");
|
||||
|
||||
|
@ -267,13 +237,13 @@ sub rcs_commit ($$$;$$) {
|
|||
if (!defined $message || !length($message)) {
|
||||
$message = "empty message";
|
||||
}
|
||||
silentsystem($darcs, 'record', '--repodir', $config{srcdir}, '--all',
|
||||
silentsystem('darcs', 'record', '--repodir', $config{srcdir}, '--all',
|
||||
'-m', $message, '--author', $author, $file) and
|
||||
error("'darcs record' failed");
|
||||
|
||||
# Update the repository by pulling from the default repository, which is
|
||||
# master repository.
|
||||
silentsystem($darcs, "pull", "--quiet", "--repodir", $config{srcdir},
|
||||
silentsystem('darcs', "pull", "--quiet", "--repodir", $config{srcdir},
|
||||
"--all") and error("'darcs pull' failed");
|
||||
|
||||
# If this updating yields any conflicts, we'll record them now to resolve
|
||||
|
@ -281,7 +251,7 @@ sub rcs_commit ($$$;$$) {
|
|||
$rcstoken = darcs_rev($file);
|
||||
# TODO: Use only the first line here, i.e. only the patch name?
|
||||
writefile("$file.log", $config{srcdir}, 'resolve conflicts: ' . $message);
|
||||
silentsystem($darcs, 'record', '--repodir', $config{srcdir}, '--all',
|
||||
silentsystem('darcs', 'record', '--repodir', $config{srcdir}, '--all',
|
||||
'-m', 'resolve conflicts: ' . $message, '--author', $author, $file) and
|
||||
error("'darcs record' failed");
|
||||
my $conflicts = darcs_rev($file) ne $rcstoken;
|
||||
|
@ -289,7 +259,7 @@ sub rcs_commit ($$$;$$) {
|
|||
error("failed to remove '$file.log'");
|
||||
|
||||
# Push the changes to the main repository.
|
||||
silentsystem($darcs, 'push', '--quiet', '--repodir', $config{srcdir}, '--all')
|
||||
silentsystem('darcs', 'push', '--quiet', '--repodir', $config{srcdir}, '--all')
|
||||
and error("'darcs push' failed");
|
||||
# TODO: darcs send?
|
||||
|
||||
|
@ -297,7 +267,7 @@ sub rcs_commit ($$$;$$) {
|
|||
my $document = readfile("$config{srcdir}/$file");
|
||||
# Try to leave everything in a consistent state.
|
||||
# TODO: 'yes | ...' needed? Doesn't seem so.
|
||||
silentsystem($darcs, "revert", "--repodir", $config{srcdir}, "--all") and
|
||||
silentsystem('darcs', "revert", "--repodir", $config{srcdir}, "--all") and
|
||||
warn("'darcs revert' failed");
|
||||
return $document;
|
||||
} else {
|
||||
|
@ -320,11 +290,11 @@ sub rcs_commit_staged($$$) {
|
|||
$message = "empty message";
|
||||
}
|
||||
|
||||
silentsystem($darcs, "record", "--repodir", $config{srcdir}, "-a", "-A", $author,
|
||||
silentsystem('darcs', "record", "--repodir", $config{srcdir}, "-a", "-A", $author,
|
||||
"-m", $message) and error("'darcs record' failed");
|
||||
|
||||
# Push the changes to the main repository.
|
||||
silentsystem($darcs, 'push', '--quiet', '--repodir', $config{srcdir}, '--all')
|
||||
silentsystem('darcs', 'push', '--quiet', '--repodir', $config{srcdir}, '--all')
|
||||
and error("'darcs push' failed");
|
||||
# TODO: darcs send?
|
||||
|
||||
|
@ -335,22 +305,21 @@ sub rcs_add ($) {
|
|||
my $file = shift; # Relative to the repodir.
|
||||
|
||||
# Intermediate directories will be added automagically.
|
||||
system($darcs, 'add', '--quiet', '--repodir', $config{srcdir},
|
||||
system('darcs', 'add', '--quiet', '--repodir', $config{srcdir},
|
||||
'--boring', $file) and error("'darcs add' failed");
|
||||
}
|
||||
|
||||
sub rcs_remove ($) {
|
||||
my $file = shift; # Relative to the repodir.
|
||||
|
||||
system('rm', $config{srcdir}.'/'.$file)
|
||||
and error("'rm' failed");
|
||||
unlink($config{srcdir}.'/'.$file);
|
||||
}
|
||||
|
||||
sub rcs_rename ($$) {
|
||||
my $a = shift; # Relative to the repodir.
|
||||
my $b = shift; # Relative to the repodir.
|
||||
|
||||
system($darcs, 'mv', '--repodir', $config{srcdir}, $a, $b)
|
||||
system('darcs', 'mv', '--repodir', $config{srcdir}, $a, $b)
|
||||
and error("'darcs mv' failed");
|
||||
}
|
||||
|
||||
|
@ -467,16 +436,9 @@ sub rcs_getctime ($) {
|
|||
# Sigh... doing things the hard way again
|
||||
my $repodir=$config{srcdir};
|
||||
|
||||
&loadcache;
|
||||
|
||||
my $filer=substr($file, length($repodir));
|
||||
$filer =~ s:^[/]+::;
|
||||
|
||||
if (defined $cache{$filer}) {
|
||||
#debug("taking cached ctime ".localtime($cache{$filer})." for $filer");
|
||||
return $cache{$filer};
|
||||
}
|
||||
|
||||
my $child = open(LOG, "-|");
|
||||
if (! $child) {
|
||||
exec("darcs", "changes", "--xml", "--reverse",
|
||||
|
@ -494,7 +456,6 @@ sub rcs_getctime ($) {
|
|||
|
||||
if (! defined $datestr) {
|
||||
warn "failed to get ctime for $filer";
|
||||
$cache{$filer} = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -502,8 +463,9 @@ sub rcs_getctime ($) {
|
|||
|
||||
#debug("found ctime ".localtime($date)." for $filer");
|
||||
|
||||
$cache{$filer} = $date;
|
||||
return $date;
|
||||
}
|
||||
|
||||
1
|
||||
|
||||
# vim: ts=4 sw=4 noet
|
||||
|
|
|
@ -4,9 +4,9 @@ ikiwiki-makerepo - check an ikiwiki srcdir into revision control
|
|||
|
||||
# SYNOPSIS
|
||||
|
||||
ikiwiki-makerepo svn|git|monotone srcdir repository
|
||||
ikiwiki-makerepo svn|git|monotone|darcs srcdir repository
|
||||
|
||||
ikiwiki-makerepo mercurial srcdir
|
||||
ikiwiki-makerepo mercurial|darcs srcdir
|
||||
|
||||
# DESCRIPTION
|
||||
|
||||
|
@ -17,6 +17,13 @@ mercurial repository.
|
|||
Note that for mercurial, the srcdir is converted into a mercurial
|
||||
repository. There is no need to have a separate repository with mercurial.
|
||||
|
||||
For darcs, the second (one-argument) form turns the given srcdir into a
|
||||
darcs master repository with the (new) srcdir inside. Adjust your ikiwiki.setup
|
||||
according to the command output! Also, the master repo's apply hook will be
|
||||
preconfigured to call a (hypothetical) ikiwiki wrapper. The command
|
||||
reports the relevant file. Adjust it as needed or remove it if you don't use
|
||||
the cgi script.
|
||||
|
||||
Note that for monotone, you are assumed to already have run "mtn genkey" to generate
|
||||
key.
|
||||
|
||||
|
|
|
@ -6,8 +6,8 @@ srcdir="$2"
|
|||
repository="$3"
|
||||
|
||||
usage () {
|
||||
echo "usage: ikiwiki-makerepo svn|git|monotone srcdir repository" >&2
|
||||
echo " ikiwiki-makerepo bzr|mercurial srcdir" >&2
|
||||
echo "usage: ikiwiki-makerepo svn|git|monotone|darcs srcdir repository" >&2
|
||||
echo " ikiwiki-makerepo bzr|mercurial|darcs srcdir" >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
@ -20,7 +20,7 @@ if [ ! -d "$srcdir" ]; then
|
|||
exit 1
|
||||
fi
|
||||
|
||||
if [ "$rcs" != mercurial ] && [ "$rcs" != bzr ]; then
|
||||
if [ "$rcs" != mercurial ] && [ "$rcs" != bzr ] && [ "$rcs" != darcs ]; then
|
||||
if [ -z "$repository" ]; then
|
||||
echo "you need to specify both a srcdir and a repository for $rcs" >&2
|
||||
usage
|
||||
|
@ -121,6 +121,40 @@ monotone)
|
|||
echo ' return "passphrasehere"'
|
||||
echo "end"
|
||||
;;
|
||||
darcs)
|
||||
if [ -e "$srcdir/_darcs" ]; then
|
||||
echo "$srcdir already seems to be a darcs repository" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# if only one arg is given, we turn the given srcdir into the darcs
|
||||
# master repo with a hidden srcdir inside its _darcs directory.
|
||||
if [ -z "$repository" ]; then
|
||||
echo "Turning $srcdir into master repo."
|
||||
repository="$srcdir"
|
||||
srcdir="$srcdir/_darcs/srcdir"
|
||||
echo "The new srcdir is $srcdir - adjust ikiwiki.setup accordingly!"
|
||||
fi
|
||||
|
||||
mkdir -p "$repository"
|
||||
cd "$repository"
|
||||
darcs initialize
|
||||
|
||||
mkdir -p "$srcdir"
|
||||
cd "$srcdir"
|
||||
darcs initialize
|
||||
echo .ikiwiki >> _darcs/prefs/boring
|
||||
darcs record -a -l -q -m "initial import"
|
||||
darcs pull -a -q "$repository"
|
||||
darcs push -a -q "$repository"
|
||||
echo "Directory $srcdir is now a branch of darcs repo $repository"
|
||||
|
||||
# set up master repo's apply hook and tell user to adjust it if desired
|
||||
darcsdefaults="$repository/_darcs/prefs/defaults"
|
||||
echo "Preconfiguring apply hook in $darcsdefaults - adjust as desired!"
|
||||
echo "apply posthook $repository/_darcs/ikiwrapper" >> "$darcsdefaults"
|
||||
echo "apply run-posthook" >> "$darcsdefaults"
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported revision control system $rcs" >&2
|
||||
usage
|
||||
|
|
Loading…
Reference in New Issue