only darcs add files not yet in version control

master
Joey Hess 2008-10-16 17:20:17 -04:00
parent 7eb512205f
commit 78a69e5bd6
1 changed files with 18 additions and 9 deletions

View File

@ -88,14 +88,14 @@ sub darcs_info ($$$) {
($_) = <DARCS_CHANGES> =~ /$field=\'([^\']+)/; ($_) = <DARCS_CHANGES> =~ /$field=\'([^\']+)/;
$field eq 'hash' and s/\.gz//; # Strip away the '.gz' from 'hash'es. $field eq 'hash' and s/\.gz//; # Strip away the '.gz' from 'hash'es.
close(DARCS_CHANGES) or error("'darcs changes' exited " . $?); close(DARCS_CHANGES);
return $_; return $_;
} }
sub darcs_rev($) { sub file_in_vc($$) {
my $file = shift; # Relative to the repodir. my $repodir = shift;
my $repodir = $config{srcdir}; my $file = shift;
my $child = open(DARCS_MANIFEST, "-|"); my $child = open(DARCS_MANIFEST, "-|");
if (! $child) { if (! $child) {
@ -104,11 +104,18 @@ sub darcs_rev($) {
} }
my $found=0; my $found=0;
while (<DARCS_MANIFEST>) { while (<DARCS_MANIFEST>) {
$found = 1, last if /^$file$/; $found = 1, last if /^(\.\/)?$file$/;
} }
return "" if (! $found);
close(DARCS_MANIFEST) or error("'darcs query manifest' exited " . $?); close(DARCS_MANIFEST) or error("'darcs query manifest' exited " . $?);
return $found;
}
sub darcs_rev($) {
my $file = shift; # Relative to the repodir.
my $repodir = $config{srcdir};
return "" if (! file_in_vc($repodir, $file));
my $hash = darcs_info('hash', $repodir, $file); my $hash = darcs_info('hash', $repodir, $file);
return defined $hash ? $hash : ""; return defined $hash ? $hash : "";
} }
@ -304,10 +311,12 @@ sub rcs_commit_staged($$$) {
sub rcs_add ($) { sub rcs_add ($) {
my $file = shift; # Relative to the repodir. my $file = shift; # Relative to the repodir.
if(! file_in_vc($config{srcdir}, $file)) {
# Intermediate directories will be added automagically. # 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"); '--boring', $file) and error("'darcs add' failed");
} }
}
sub rcs_remove ($) { sub rcs_remove ($) {
my $file = shift; # Relative to the repodir. my $file = shift; # Relative to the repodir.