From: Don Armstrong Date: Fri, 17 Feb 2006 08:12:43 +0000 (+0000) Subject: add svnmerge and update stodo to work remotely X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;ds=sidebyside;h=2a366e45ef408fde4b18f28f6520293fc632184c;p=bin.git add svnmerge and update stodo to work remotely --- diff --git a/stodo b/stodo index e987c3a..0b133ca 100755 --- a/stodo +++ b/stodo @@ -54,6 +54,20 @@ Display this manual. =back +=head1 ENVIRONMENTAL VARIABLES + +=over + +=item B + +Todo databse location, set by devtodo + +=item B + +If set, stodo assumes that there is no network, and doesn't commit + +=back + =head1 EXAMPLES on save { @@ -116,7 +130,10 @@ while (<$svn_entries_fh>) { $svn_host = $2; last; } - +if ($ENV{STODO_NO_COMMIT}) { + print "Exiting because of STODO_NO_COMMIT env variable\n" unless $options{quiet}; + exit 0; +} if (not defined $svn_host and $url_type ne 'file') { die "Was unable to find which host the svn repository is located on"; } diff --git a/svnmerge b/svnmerge new file mode 100755 index 0000000..bc39922 --- /dev/null +++ b/svnmerge @@ -0,0 +1,62 @@ +#!/usr/bin/perl +# Uses symlinks to merge the files contained in a set of subversion +# checkouts to into a single directory. Keeps track of when files are +# removed from the merged directories and removes the symlinks. +# +# Only merges files that match the specified pattern. +# +# Note that the directories given to merge should be paths that will work +# for symlink targets from the destination directory (so either full paths, +# or they should be right inside the destination directory). +# +# Note that other files in the destination directory will be left as-is. +# +# Copyright 2006 by Joey Hess, licensed under the GPL. + +if (! @ARGV) { + die "usage: svnmerge include-pattern dest dir1 [dir2 ...]\n"; +} + +my $pattern=shift; +my $dest=shift; + +foreach my $dir (@ARGV) { + my %known; + + # Link in each thing from the dir. + opendir(DIR, $dir) || die "opendir: $!"; + while ($_=readdir(DIR)) { + next if $_ eq '.' || $_ eq '..' || $_ eq 'known' || $_ eq '.svn'; + next unless /$pattern/; + + $known{$_}=1; + + if (! -l "$dest/$_" && -e "$dest/$_") { + print STDERR "$_ in $dir is also in $dest\n"; + } + elsif (! -l "$dest/$_") { + system("ln", "-svf", "$dir/$_", $dest); + } + } + closedir(DIR); + + # Remove anything that was previously linked in but is not in the + # dir anymore. + if (-e "$dir/known") { + open(KNOWN, "$dir/known") || die "open $dir/known: $!"; + while () { + chomp; + if (! $known{$_}) { + system("rm", "-vf", "$dest/$_"); + } + } + close KNOWN; + } + + # Save state for next time. + open(KNOWN, ">$dir/known") || die "write $dir/known: $!"; + foreach my $file (sort keys %known) { + print KNOWN "$file\n"; + } + close KNOWN; +}