New submission from Nathan Gray <[EMAIL PROTECTED]>:
There has been discussion from time-to-time about how to pass patch
and/or file information to a posthook command. If I recall correctly,
the dominant opinion is that this information could be supplied in an
environment variable.
My workaround is currently to run a perl script to find patches with a
recent update time, and write those to a file:
apply posthook /usr/local/bin/applied_patches.pl 15 >
_darcs/prefs/applied_patches; /usr/local/bin/applied_patches.pl --files 15 >
_darcs/prefs/applied_files
apply run-posthook
I would love to have the hashes of each affected patch in one
environment variable, and the names of each affected file in another
environment variable. They could be called something simple like:
DARCS_PATCHES and DARCS_FILES, or have HOOK or POSTHOOK in there
somewhere if we want to get fancy.
I am attaching my perl script 'applied_patches.pl' as an example of
what I am doing. It is barely sufficient for what I am currently
doing, but can very easily give incorrect results.
-kolibrie
----------
files: applied_patches.pl
messages: 2094
nosy: beschmi, droundy, kolibrie, kowey, tommy
status: unread
title: posthook should be aware of which patches are affected
__________________________________
Darcs bug tracker <[EMAIL PROTECTED]>
<http://bugs.darcs.net/issue524>
__________________________________
#!/usr/bin/perl
use Getopt::Long;
my %param = ();
GetOptions(\%param, 'files!', 'h|help!');
usage() if $param{h};
sub usage {
print qq{Usage: $0 [--files] [AGE]
--files list files affected instead of patch ids
AGE only list patches applied within the last AGE seconds\n\n};
exit;
}
my $age = shift(@ARGV) || 0;
my $time = time - $age;
my %shown = ();
my $recent_patches = interesting_files(sub { $_[0] =~ /\.gz$/ and (stat($_[0]))[9] >= $time }, '_darcs/patches');
while (my $patch_file = $recent_patches->()) {
#print $patch_file . "\n";
(my $patch_id = $patch_file) =~ s/^.*\///;
if ($param{files}) {
my $summary = `darcs changes -s --matches "hash $patch_id"`;
my @files = $summary =~ m/\s+[AM]\s(\S+)/g;
foreach my $file (@files) {
print "$file\n" unless ($shown{$file}++);
}
} else {
print $patch_id . "\n";
}
}
sub interesting_files {
my $is_interesting = shift;
my @queue = @_;
return sub {
while (@queue) {
my $file = shift(@queue);
if (-d $file) {
opendir my $dh, $file or next;
my @newfiles = grep { $_ ne '.' and $_ ne '..' } readdir $dh;
push @queue, map { "$file/$_" } @newfiles;
}
return $file if $is_interesting->($file);
}
return;
};
}
_______________________________________________
darcs-devel mailing list
[email protected]
http://lists.osuosl.org/mailman/listinfo/darcs-devel