]> git.madduck.net Git - code/myrepos.git/blobdiff - mr

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

bzr support for register
[code/myrepos.git] / mr
diff --git a/mr b/mr
index 8eb0374babbca924fb65e2191f9c7a7ed64a707b..e15019e3b8092e74a250b9f902cd02a61d2b922c 100755 (executable)
--- a/mr
+++ b/mr
@@ -346,7 +346,7 @@ sub action {
 
        if (exists $config{$topdir}{$subdir}{deleted}) {
                if (! -d $dir) {
 
        if (exists $config{$topdir}{$subdir}{deleted}) {
                if (! -d $dir) {
-                       next;
+                       return;
                }
                else {
                        my $test="set -e;".$lib.$config{$topdir}{$subdir}{deleted};
                }
                else {
                        my $test="set -e;".$lib.$config{$topdir}{$subdir}{deleted};
@@ -463,6 +463,10 @@ sub loadconfig {
                $dir="";
        }
        else {
                $dir="";
        }
        else {
+               if (! -e $f) {
+                       return;
+               }
+
                my $absf=abs_path($f);
                if ($loaded{$absf}) {
                        return;
                my $absf=abs_path($f);
                if ($loaded{$absf}) {
                        return;
@@ -551,14 +555,28 @@ sub modifyconfig {
        my %changefields=@_;
 
        my @lines;
        my %changefields=@_;
 
        my @lines;
+       my @out;
+
        if (-e $f) {
                open(my $in, "<", $f) || die "mr: open $f: $!\n";
                @lines=<$in>;
                close $in;
        }
 
        if (-e $f) {
                open(my $in, "<", $f) || die "mr: open $f: $!\n";
                @lines=<$in>;
                close $in;
        }
 
+       my $addfields=sub {
+               my @blanks;
+               while ($out[$#out] =~ /^\s*$/) {
+                       unshift @blanks, pop @out;
+               }
+               foreach my $field (sort keys %changefields) {
+                       if (length $changefields{$field}) {
+                               push @out, "$field = $changefields{$field}\n";
+                       }
+               }
+               push @out, @blanks;
+       };
+
        my $section;
        my $section;
-       my @out;
        while (@lines) {
                $_=shift(@lines);
 
        while (@lines) {
                $_=shift(@lines);
 
@@ -568,16 +586,7 @@ sub modifyconfig {
                elsif (/^\s*\[([^\]]*)\]\s*$/) {
                        if (defined $section && 
                            $section eq $targetsection) {
                elsif (/^\s*\[([^\]]*)\]\s*$/) {
                        if (defined $section && 
                            $section eq $targetsection) {
-                               my @blanks;
-                               while ($out[$#out] =~ /^\s*$/) {
-                                       unshift @blanks, pop @out;
-                               }
-                               foreach my $field (sort keys %changefields) {
-                                       if (length $changefields{$field}) {
-                                               push @out, "$field = $changefields{$field}\n";
-                                       }
-                               }
-                               push @out, @blanks;
+                               $addfields->();
                        }
 
                        $section=$1;
                        }
 
                        $section=$1;
@@ -607,7 +616,11 @@ sub modifyconfig {
                }
        }
 
                }
        }
 
-       if (%changefields) {
+       if (defined $section && 
+           $section eq $targetsection) {
+                       $addfields->();
+       }
+       elsif (%changefields) {
                push @out, "\n[$targetsection]\n";
                foreach my $field (sort keys %changefields) {
                        if (length $changefields{$field}) {
                push @out, "\n[$targetsection]\n";
                foreach my $field (sort keys %changefields) {
                        if (length $changefields{$field}) {
@@ -717,6 +730,13 @@ register =                                                         \
                fi                                                      \
                echo "Registering git url: $url"                        \
                mr config "$(pwd)" checkout="git clone $url $basedir"   \
                fi                                                      \
                echo "Registering git url: $url"                        \
                mr config "$(pwd)" checkout="git clone $url $basedir"   \
+       elif [ -d .bzr ]; then                                          \
+               url=$(cat .bzr/branch/parent)                           \
+               if [ -z "$url" ]; then                                  \
+                       error "cannot determine bzr url"                \
+               fi                                                      \
+               echo "Registering bzr url: $url"                        \
+               mr config "$(pwd)" checkout="bzr clone $url $basedir"   \
        else                                                            \
                error "unable to register this repo type"               \
        fi
        else                                                            \
                error "unable to register this repo type"               \
        fi