From: Joey Hess Date: Sun, 21 Oct 2007 21:21:22 +0000 (-0400) Subject: * Add ability to reorder repos, if you want mr to act on a given repo first X-Git-Url: https://git.madduck.net/code/myrepos.git/commitdiff_plain/8863dd020e175247f423aed1dc63dbe0269af923?ds=inline * Add ability to reorder repos, if you want mr to act on a given repo first or last. --- diff --git a/debian/changelog b/debian/changelog index 07270a0..22984f3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,8 +5,10 @@ mr (0.6) UNRELEASED; urgency=low * hours_since was broken by design, and fixing it involved changing its calling convention. If you used the old version, the new version will error out. + * Add ability to reorder repos, if you want mr to act on a given repo first + or last. - -- Joey Hess Sun, 21 Oct 2007 13:58:30 -0400 + -- Joey Hess Sun, 21 Oct 2007 16:50:53 -0400 mr (0.5) unstable; urgency=low diff --git a/mr b/mr index 89f3281..0bded23 100755 --- a/mr +++ b/mr @@ -231,6 +231,17 @@ been at least 12 hours since the last update. skip = test $(whoami) != joey skip = [ "$1" = update ] && ! hours_since "$1" 12 +=item order + +The "order" parameter can be used to override the default ordering of +repositories. The default order value is 10. Use smaller values to make +repositories be processed earlier, and larger values to make repositories +be processed later. + +Note that if a repository is located in a subdirectory of another +repository, ordering it to be processed earlier is not recommended, as this +can cause confusion during checkouts. + =item chain If the "chain" parameter is set and its command returns true, then B @@ -400,34 +411,55 @@ elsif ($action eq 'register') { exec($command) || die "exec: $!"; } +# an ordered list of repos +my @list; +foreach my $topdir (sort keys %config) { + foreach my $subdir (sort keys %{$config{$topdir}}) { + push @list, { + topdir => $topdir, + subdir => $subdir, + order => $config{$topdir}{$subdir}{order}, + }; + } +} +@list = sort { + $a->{order} <=> $b->{order} + || + $a->{topdir} cmp $b->{topdir} + || + $a->{subdir} cmp $b->{subdir} + } @list; + # work out what repos to act on my @repos; my $nochdir=0; -foreach my $topdir (sort keys %config) { - foreach my $subdir (sort keys %{$config{$topdir}}) { +foreach my $repo (@list) { + my $topdir=$repo->{topdir}; + my $subdir=$repo->{subdir}; + + next if $subdir eq 'DEFAULT'; + my $dir=($subdir =~/^\//) ? $subdir : $topdir.$subdir; + my $d=$directory; + $dir.="/" unless $dir=~/\/$/; + $d.="/" unless $d=~/\/$/; + next if $no_recurse && $d ne $dir; + next if $dir ne $d && $dir !~ /^\Q$d\E/; + push @repos, [$dir, $topdir, $subdir]; +} +if (! @repos) { + # fallback to find a leaf repo + foreach my $repo (@list) { + my $topdir=$repo->{topdir}; + my $subdir=$repo->{subdir}; + next if $subdir eq 'DEFAULT'; my $dir=($subdir =~/^\//) ? $subdir : $topdir.$subdir; my $d=$directory; $dir.="/" unless $dir=~/\/$/; $d.="/" unless $d=~/\/$/; - next if $no_recurse && $d ne $dir; - next if $dir ne $d && $dir !~ /^\Q$d\E/; - push @repos, [$dir, $topdir, $subdir]; - } -} -if (! @repos) { - # fallback to find a leaf repo - LEAF: foreach my $topdir (reverse sort keys %config) { - foreach my $subdir (reverse sort keys %{$config{$topdir}}) { - next if $subdir eq 'DEFAULT'; - my $dir=($subdir =~/^\//) ? $subdir : $topdir.$subdir; - my $d=$directory; - $dir.="/" unless $dir=~/\/$/; - $d.="/" unless $d=~/\/$/; - if ($d=~/^\Q$dir\E/) { - push @repos, [$dir, $topdir, $subdir]; - last LEAF; - } + if ($d=~/^\Q$dir\E/) { + push @repos, [$dir, $topdir, $subdir]; + last; } } $nochdir=1; @@ -893,6 +925,7 @@ ci = commit ls = list [DEFAULT] +order = 10 lib = error() { echo "mr: $@" >&2 diff --git a/mrconfig.complex b/mrconfig.complex index f8ec25c..e5699d8 100644 --- a/mrconfig.complex +++ b/mrconfig.complex @@ -104,6 +104,16 @@ update = svn update && svnfix checkout = git clone ssh://git.kitenet.net/srv/git/kitenet.net/joey/private/mail skip = ! private +# I don't keep my music in revision control, but mr can be taught to use +# unison to synchronise it. +[sound] +checkout = unison -batch sound +update = unison -batch sound +commit = unison sound +skip = ! wantmedia +# Update this last of all. +order = 100 + # Example of how to remember to delete a repo, when one mrconfig file is # used on multiple systems. If you're feeling brave, use rm -rf $MR_REPO # instead. This approach can also be used for renames.