From be8e213dd0edc7efbd5305ce0e735b224c5a46a0 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 15 Aug 2010 12:34:55 -0400 Subject: [PATCH 01/16] typo --- mr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mr b/mr index 4350dad..839401f 100755 --- a/mr +++ b/mr @@ -1594,7 +1594,7 @@ git_record = git commit -a "$@" bzr_record = bzr commit "$@" hg_record = hg commit -m "$@" darcs_record = darcs record -a -m "$@" -fossil_record = git commit "$@" +fossil_record = fossil commit "$@" svn_push = : git_push = git push "$@" -- 2.39.5 From 9c3234f5d553312f47d934f70bd1481bed58df9e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 15 Aug 2010 12:35:18 -0400 Subject: [PATCH 02/16] revert unnecessary line move --- mr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mr b/mr index 839401f..42ae961 100755 --- a/mr +++ b/mr @@ -1559,12 +1559,12 @@ git_test = test -d "$MR_REPO"/.git bzr_test = test -d "$MR_REPO"/.bzr cvs_test = test -d "$MR_REPO"/CVS hg_test = test -d "$MR_REPO"/.hg +darcs_test = test -d "$MR_REPO"/_darcs fossil_test = test -f "$MR_REPO"/_FOSSIL_ git_bare_test = test -d "$MR_REPO"/refs/heads && test -d "$MR_REPO"/refs/tags && test -d "$MR_REPO"/objects && test -f "$MR_REPO"/config && test "`GIT_CONFIG="$MR_REPO"/config git config --get core.bare`" = true -darcs_test = test -d "$MR_REPO"/_darcs svn_update = svn update "$@" git_update = git pull "$@" -- 2.39.5 From 07489a34afa768aee3bc9f23860c8a3f0e55a1db Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 15 Aug 2010 12:36:28 -0400 Subject: [PATCH 03/16] fix quoting --- mr | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mr b/mr index 42ae961..6df8cd7 100755 --- a/mr +++ b/mr @@ -1667,7 +1667,7 @@ git_bare_register = mr -c "$MR_CONFIG" config "`pwd`" checkout="git clone --bare '$url' '$MR_REPO'" fossil_register = url=`fossil remote-url` - repo=`fossil info | grep repository | sed -e s/repository:*.//g -e s/\ //g` + repo=`fossil info | grep repository | sed -e 's/repository:*.//g' -e 's/ //g'` echo "Registering fossil repository $url in $MR_CONFIG" mr -c "$MR_CONFIG" config "`pwd`" checkout="mkdir -p '$MR_REPO' && cd '$MR_REPO' && fossil open '$repo'" -- 2.39.5 From 550d5f602c692e8883e3b39c05a2e17df8a3e9fe Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 15 Aug 2010 12:38:36 -0400 Subject: [PATCH 04/16] update --- TODO | 2 -- debian/changelog | 6 ++++++ debian/control | 11 ++++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/TODO b/TODO index 6358728..bc5d00b 100644 --- a/TODO +++ b/TODO @@ -10,8 +10,6 @@ ~/.mrconfig (and files it chains). This allows a user to globally configure mr with aliases, etc. (Closes: #557963) -* more revision control systems - * a way to detect repos in a tree that are not registered, and warn about or even auto-register them. (svn externals make this quite difficult!) diff --git a/debian/changelog b/debian/changelog index 19936bb..a5a24d0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +mr (0.50) UNRELEASED; urgency=low + + * Now supports the Fossil VCS. (Thanks, Jimmy Tang) + + -- Joey Hess Sun, 15 Aug 2010 12:36:34 -0400 + mr (0.49) unstable; urgency=low * Update suggests for git-core to git transition. diff --git a/debian/control b/debian/control index 59540e0..2964afe 100644 --- a/debian/control +++ b/debian/control @@ -11,14 +11,15 @@ Package: mr Architecture: all Section: vcs Depends: ${misc:Depends} -Suggests: subversion, git-core | git (>= 1:1.7), cvs, bzr, mercurial, darcs, liburi-perl, curl +Suggests: subversion, git-core | git (>= 1:1.7), cvs, bzr, mercurial, darcs, liburi-perl, curl, fossil Recommends: libwww-perl, libhtml-parser-perl, perl Description: a Multiple Repository management tool The mr(1) command can checkout, update, or perform other actions on a set of repositories as if they were one combined respository. It - supports any combination of git, svn, mercurial, bzr, darcs, and cvs - repositories, and support for other revision control systems can easily - be added. (There are extensions adding support for unison and git-svn.) + supports any combination of git, svn, mercurial, bzr, darcs, cvs, and + fossil repositories, and support for other revision control systems + can easily be added. (There are extensions adding support for unison + and git-svn.) . It is extremely configurable via simple shell scripting. Some examples of things it can do include: @@ -32,4 +33,4 @@ Description: a Multiple Repository management tool * Remember actions that failed due to a laptop being offline, so they can be retried when it comes back online. . - This package also includes webcheckout. + This package also includes the webcheckout command. -- 2.39.5 From 099544fdb010d083124839e3bde9c3c1e39d89a5 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 29 Aug 2010 14:44:18 -0400 Subject: [PATCH 05/16] Added fixups hook, which can be used to run a command after a repository is checked out or updated. Closes: #590868 --- debian/changelog | 2 ++ mr | 42 ++++++++++++++++++++++++++++++++++++++++-- mrconfig.complex | 4 ++-- 3 files changed, 44 insertions(+), 4 deletions(-) diff --git a/debian/changelog b/debian/changelog index a5a24d0..52249ed 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ mr (0.50) UNRELEASED; urgency=low * Now supports the Fossil VCS. (Thanks, Jimmy Tang) + * Added fixups hook, which can be used to run a command after + a repository is checked out or updated. Closes: #590868 -- Joey Hess Sun, 15 Aug 2010 12:36:34 -0400 diff --git a/mr b/mr index 6df8cd7..03cfdf3 100755 --- a/mr +++ b/mr @@ -370,6 +370,13 @@ The "lib" parameter can specify some shell code that will be run before each command, this can be a useful way to define shell functions for other commands to use. +=item fixups + +If the "fixups" parameter is set, its command is run whenever a repository +is checked out, or updated. This provides an easy way to do things +like permissions fixups, or other tweaks to the repository content, +whenever the repository is changed. + =back When looking for a command to run for a given action, mr first looks for @@ -524,6 +531,7 @@ sub action { my $lib=exists $config{$topdir}{$subdir}{lib} ? $config{$topdir}{$subdir}{lib}."\n" : ""; my $is_checkout=($action eq 'checkout'); + my $is_update=($action =~ /update/); $ENV{MR_REPO}=$dir; @@ -537,7 +545,7 @@ sub action { $dir=~s/^(.*)\/[^\/]+\/?$/$1/; } } - elsif ($action =~ /update/) { + elsif ($is_update) { if (! -d $dir) { return action("checkout", $dir, $topdir, $subdir); } @@ -628,16 +636,46 @@ sub action { return FAILED; } else { - if ($action eq 'checkout' && ! -d $dir) { + if ($is_checkout && ! -d $dir) { print STDERR "mr $action: $dir missing after checkout\n";; return FAILED; } + if (($is_checkout || $is_update)) { + my $ret=hook("fixups", $topdir, $subdir); + return $ret if $ret != OK; + } + return OK; } } } +sub hook { + my ($hook, $topdir, $subdir) = @_; + + my $command=$config{$topdir}{$subdir}{$hook}; + return OK unless defined $command; + my $lib=exists $config{$topdir}{$subdir}{lib} ? + $config{$topdir}{$subdir}{lib}."\n" : ""; + my $shell="set -e;".$lib. + "my_hook(){ $command\n }; my_hook"; + print "mr $hook: running >>$shell<<\n" if $verbose; + my $ret=system($shell); + if ($ret != 0) { + if (($? & 127) == 2) { + print STDERR "mr $hook: interrupted\n"; + return ABORT; + } + elsif ($? & 127) { + print STDERR "mr $hook: received signal ".($? & 127)."\n"; + return ABORT; + } + } + + return OK; +} + # run actions on multiple repos, in parallel sub mrs { my $action=shift; diff --git a/mrconfig.complex b/mrconfig.complex index 5924de1..a80e981 100644 --- a/mrconfig.complex +++ b/mrconfig.complex @@ -79,8 +79,8 @@ skip = ! mylaptop [tmp] # This is a dummy target, all it does is run fixups at the end of # an update. -update = $HOME/bin/fixups -checkout = $HOME/bin/fixups +fixups = $HOME/bin/fixups +checkout = mkdir -p $HOME/tmp status = : order = 25 -- 2.39.5 From 4f4322be5574dcbb4f9e975b35300b34dd232368 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 29 Aug 2010 14:53:57 -0400 Subject: [PATCH 06/16] Added support for arbitrary pre and post hooks for all defined mr commands. For example, pre_commit is run before all commits; post_update is run after all updates. Closes: #481341 --- debian/changelog | 3 +++ mr | 16 +++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 52249ed..d6dffc7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,9 @@ mr (0.50) UNRELEASED; urgency=low * Now supports the Fossil VCS. (Thanks, Jimmy Tang) * Added fixups hook, which can be used to run a command after a repository is checked out or updated. Closes: #590868 + * Added support for arbitrary pre and post hooks for all defined mr + commands. For example, pre_commit is run before all commits; post_update + is run after all updates. Closes: #481341 -- Joey Hess Sun, 15 Aug 2010 12:36:34 -0400 diff --git a/mr b/mr index 03cfdf3..e73f3c8 100755 --- a/mr +++ b/mr @@ -377,6 +377,13 @@ is checked out, or updated. This provides an easy way to do things like permissions fixups, or other tweaks to the repository content, whenever the repository is changed. +=item pre_ and post_ + +If a "pre_action" parameter is set, its command is run before mr performs the +specified action. Similarly, "post_action" parameters are run after mr +successfully performs the specified action. For example, "pre_commit" is +run before committing; "post_update" is run after updating. + =back When looking for a command to run for a given action, mr first looks for @@ -604,6 +611,10 @@ sub action { $s=~s/^\Q$topdir$subdir\E\/?//; print "mr $action: $topdir$subdir (in subdir $s)\n" unless $quiet; } + + my $hookret=hook("pre_$action", $topdir, $subdir); + return $hookret if $hookret != OK; + $command="set -e; ".$lib. "my_action(){ $command\n }; my_action ". join(" ", map { s/\//\/\//g; s/"/\"/g; '"'.$_.'"' } @ARGV); @@ -641,11 +652,14 @@ sub action { return FAILED; } + my $ret=hook("post_$action", $topdir, $subdir); + return $ret if $ret != OK; + if (($is_checkout || $is_update)) { my $ret=hook("fixups", $topdir, $subdir); return $ret if $ret != OK; } - + return OK; } } -- 2.39.5 From 47e02526e5c54c0723d4d0e1fe28368cd4a697f6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 29 Aug 2010 15:01:20 -0400 Subject: [PATCH 07/16] releasing version 0.50 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index d6dffc7..6108b58 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -mr (0.50) UNRELEASED; urgency=low +mr (0.50) unstable; urgency=low * Now supports the Fossil VCS. (Thanks, Jimmy Tang) * Added fixups hook, which can be used to run a command after @@ -7,7 +7,7 @@ mr (0.50) UNRELEASED; urgency=low commands. For example, pre_commit is run before all commits; post_update is run after all updates. Closes: #481341 - -- Joey Hess Sun, 15 Aug 2010 12:36:34 -0400 + -- Joey Hess Sun, 29 Aug 2010 15:00:01 -0400 mr (0.49) unstable; urgency=low -- 2.39.5 From 4c3dcb350066802311b52151f0f73c5bbe2603e0 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 29 Aug 2010 15:04:48 -0400 Subject: [PATCH 08/16] another example of fixups hook --- mrconfig.complex | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mrconfig.complex b/mrconfig.complex index a80e981..a7d8551 100644 --- a/mrconfig.complex +++ b/mrconfig.complex @@ -71,9 +71,9 @@ checkout = mkdir Maildir Maildir/cur Maildir/new Maildir/tmp; chmod 700 Maildir status = : [mail] -# I use mairix to index my mail archive; run it after each update. checkout = git clone ssh://joey@git.kitenet.net/srv/git/joey/private/mail -update = git pull "$@"; if [ "$(which mairix)" ]; then mairix -Q; fi +# I use mairix to index my mail archive; keep its index up-to-date. +fixups = if [ "$(which mairix)" ]; then ionice -c 3 mairix -Q; fi skip = ! mylaptop [tmp] -- 2.39.5 From 832fadc6fc84658766e966137633bcfff6aa35c2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 28 Oct 2010 18:02:21 -0400 Subject: [PATCH 09/16] Fix display when absolute directories are configured in mrconfig. --- debian/changelog | 6 ++++++ mr | 20 +++++++++++++------- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/debian/changelog b/debian/changelog index 6108b58..2a976fd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +mr (0.51) UNRELEASED; urgency=low + + * Fix display when absolute directories are configured in mrconfig. + + -- Joey Hess Thu, 28 Oct 2010 18:01:27 -0400 + mr (0.50) unstable; urgency=low * Now supports the Fossil VCS. (Thanks, Jimmy Tang) diff --git a/mr b/mr index e73f3c8..2bb3efa 100755 --- a/mr +++ b/mr @@ -498,7 +498,7 @@ sub rcs_test { chomp $rcs; if ($rcs=~/\n/s) { $rcs=~s/\n/, /g; - print STDERR "mr $action: found multiple possible repository types ($rcs) for $topdir$subdir\n"; + print STDERR "mr $action: found multiple possible repository types ($rcs) for ".fulldir($topdir, $subdir)."\n"; return undef; } if (! length $rcs) { @@ -531,9 +531,15 @@ sub findcommand { } } +sub fulldir { + my ($topdir, $subdir) = @_; + return $subdir =~ /^\// ? $subdir : $topdir.$subdir; +} + sub action { my ($action, $dir, $topdir, $subdir, $force_checkout) = @_; - + my $fulldir=fulldir($topdir, $subdir); + $ENV{MR_CONFIG}=$configfiles{$topdir}; my $lib=exists $config{$topdir}{$subdir}{lib} ? $config{$topdir}{$subdir}{lib}."\n" : ""; @@ -594,22 +600,22 @@ sub action { elsif (! defined $command) { my $rcs=rcs_test(@_); if (! defined $rcs) { - print STDERR "mr $action: unknown repository type and no defined $action command for $topdir$subdir\n"; + print STDERR "mr $action: unknown repository type and no defined $action command for $fulldir\n"; return FAILED; } else { - print STDERR "mr $action: no defined action for $rcs repository $topdir$subdir, skipping\n"; + print STDERR "mr $action: no defined action for $rcs repository $fulldir, skipping\n"; return SKIPPED; } } else { if (! $no_chdir) { - print "mr $action: $topdir$subdir\n" unless $quiet; + print "mr $action: $fulldir\n" unless $quiet; } else { my $s=$directory; - $s=~s/^\Q$topdir$subdir\E\/?//; - print "mr $action: $topdir$subdir (in subdir $s)\n" unless $quiet; + $s=~s/^\Q$fulldir\E\/?//; + print "mr $action: $fulldir (in subdir $s)\n" unless $quiet; } my $hookret=hook("pre_$action", $topdir, $subdir); -- 2.39.5 From 5097a496c82a645c0afdfff2f2835395b108365c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 10 Nov 2010 11:03:02 -0400 Subject: [PATCH 10/16] Add push to manpage synopsis. Closes: #603029 --- debian/changelog | 1 + mr | 2 ++ 2 files changed, 3 insertions(+) diff --git a/debian/changelog b/debian/changelog index 2a976fd..19edc74 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ mr (0.51) UNRELEASED; urgency=low * Fix display when absolute directories are configured in mrconfig. + * Add push to manpage synopsis. Closes: #603029 -- Joey Hess Thu, 28 Oct 2010 18:01:27 -0400 diff --git a/mr b/mr index 2bb3efa..642aa6f 100755 --- a/mr +++ b/mr @@ -16,6 +16,8 @@ B [options] commit [-m "message"] B [options] record [-m "message"] +B [options] push + B [options] diff B [options] log -- 2.39.5 From 92d07e8691d464a3676ac6289c578d6217776633 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 16 Dec 2010 12:53:30 -0400 Subject: [PATCH 11/16] Do not return a nonzero exit status when all repositories were skipped. Closes: #607287 --- debian/changelog | 2 ++ mr | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index 19edc74..1e1f549 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ mr (0.51) UNRELEASED; urgency=low * Fix display when absolute directories are configured in mrconfig. * Add push to manpage synopsis. Closes: #603029 + * Do not return a nonzero exit status when all repositories were skipped. + Closes: #607287 -- Joey Hess Thu, 28 Oct 2010 18:01:27 -0400 diff --git a/mr b/mr index 642aa6f..5a877fe 100755 --- a/mr +++ b/mr @@ -427,6 +427,10 @@ mr can be extended to support things such as unison and git-svn. Some files providing such extensions are available in /usr/share/mr/. See the documentation in the files for details about using them. +=head1 EXIT STATUS + +mr returns nonzero if a command failed in any of the repositories. + =head1 AUTHOR Copyright 2007-2010 Joey Hess @@ -1548,9 +1552,6 @@ sub exitstats { if (@failed) { exit 1; } - elsif (! @ok && @skipped) { - exit 1; - } else { exit 0; } -- 2.39.5 From c69aee37575bf361db74d8bff3753e346ba7d53a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 16 Dec 2010 13:15:05 -0400 Subject: [PATCH 12/16] releasing version 0.51 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 1e1f549..5d7c406 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,11 +1,11 @@ -mr (0.51) UNRELEASED; urgency=low +mr (0.51) unstable; urgency=low * Fix display when absolute directories are configured in mrconfig. * Add push to manpage synopsis. Closes: #603029 * Do not return a nonzero exit status when all repositories were skipped. Closes: #607287 - -- Joey Hess Thu, 28 Oct 2010 18:01:27 -0400 + -- Joey Hess Thu, 16 Dec 2010 12:53:32 -0400 mr (0.50) unstable; urgency=low -- 2.39.5 From 03307549be2f8d1152e216550712c9d49569e553 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 13 Jan 2011 18:54:48 -0400 Subject: [PATCH 13/16] DEP5 --- debian/copyright | 3 +++ 1 file changed, 3 insertions(+) diff --git a/debian/copyright b/debian/copyright index eb32185..b3bbadd 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,3 +1,6 @@ +Format: http://dep.debian.net/deps/dep5/ +Source: native package + Files: * Copyright: (c) 2007-2010 Joey Hess License: GPL-2+ -- 2.39.5 From b7a3b1615f17991e400b5fa93c7e8a8cfffd348c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 19 Jan 2011 14:09:53 -0400 Subject: [PATCH 14/16] Trust flag day. All mrconfig files except the main ~/.mrconfig are now untrusted by default, until listed in ~/.mrtrust. --- TODO | 3 --- debian/changelog | 7 ++++++ debian/copyright | 3 +-- mr | 63 ++++++++++++++++++++++++------------------------ 4 files changed, 40 insertions(+), 36 deletions(-) diff --git a/TODO b/TODO index bc5d00b..43eae03 100644 --- a/TODO +++ b/TODO @@ -1,6 +1,3 @@ -* For compatability, ~/.mrtrust has to exist before trust checks are - enabled. Change this in a flag day. - * After the mtrust flag day, consider making something similar to -p be enabled by default. diff --git a/debian/changelog b/debian/changelog index 5d7c406..29dd877 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +mr (1.00) UNRELEASED; urgency=low + + * Trust flag day. All mrconfig files except the main ~/.mrconfig are + now untrusted by default, until listed in ~/.mrtrust. + + -- Joey Hess Wed, 19 Jan 2011 13:39:43 -0400 + mr (0.51) unstable; urgency=low * Fix display when absolute directories are configured in mrconfig. diff --git a/debian/copyright b/debian/copyright index b3bbadd..5e8c312 100644 --- a/debian/copyright +++ b/debian/copyright @@ -1,8 +1,7 @@ Format: http://dep.debian.net/deps/dep5/ -Source: native package Files: * -Copyright: (c) 2007-2010 Joey Hess +Copyright: (c) 2007-2011 Joey Hess License: GPL-2+ On Debian systems, the complete text of the GPL can be found in /usr/share/common-licenses/GPL. diff --git a/mr b/mr index 5a877fe..41a5362 100755 --- a/mr +++ b/mr @@ -400,26 +400,28 @@ the action that is performed for a given revision control system, you can override these rcs specific actions. To add a new revision control system, you can just add rcs specific actions for it. -The ~/.mrlog file contains commands that mr has remembered to run later, -due to being offline. You can delete or edit this file to remove commands, -or even to add other commands for 'mr online' to run. If the file is -present, mr assumes it is in offline mode. - =head1 UNTRUSTED MRCONFIG FILES Since mrconfig files can contain arbitrary shell commands, they can do anything. This flexibility is good, but it also allows a malicious mrconfig file to delete your whole home directory. Such a file might be contained -inside a repository that your main ~/.mrconfig checks out and chains to. To -avoid worries about evil commands in a mrconfig file, mr -has the ability to read mrconfig files in untrusted mode. Such files are -limited to running only known safe commands (like "git clone") in a -carefully checked manner. +inside a repository that your main ~/.mrconfig checks out. To +avoid worries about evil commands in a mrconfig file, mr defaults to +reading all mrconfig files other than the main ~/.mrconfig in untrusted +mode. In untrusted mode, mrconfig files are limited to running only known +safe commands (like "git clone") in a carefully checked manner. + +To configure mr to trust other mrconfig files, list them in ~/.mrtrust. +One mrconfig file should be listed per line. Either the full pathname +should be listed, or the pathname can start with "~/" to specify a file +relative to your home directory. -By default, mr trusts all mrconfig files. (This default will change in a -future release!) But if you have a ~/.mrtrust file, mr will only trust -mrconfig files that are listed within it. (One file per line.) All other -files will be treated as untrusted. +=head1 OFFLINE LOG FILE + +The ~/.mrlog file contains commands that mr has remembered to run later, +due to being offline. You can delete or edit this file to remove commands, +or even to add other commands for 'mr online' to run. If the file is +present, mr assumes it is in offline mode. =head1 EXTENSIONS @@ -433,7 +435,7 @@ mr returns nonzero if a command failed in any of the repositories. =head1 AUTHOR -Copyright 2007-2010 Joey Hess +Copyright 2007-2011 Joey Hess Licensed under the GNU GPL version 2 or higher. @@ -925,22 +927,16 @@ sub is_trusted_config { my $trustfile=$ENV{HOME}."/.mrtrust"; - if (! -e $trustfile) { - print "mr: Assuming $config is trusted.\n"; - print "mr: For better security, you are encouraged to create ~/.mrtrust\n"; - print "mr: and list all trusted mrconfig files in it.\n"; - return 1; - } - if (! %trusted) { $trusted{"$ENV{HOME}/.mrconfig"}=1; - open (TRUST, "<", $trustfile) || die "$trustfile: $!"; - while () { - chomp; - s/^~\//$ENV{HOME}\//; - $trusted{abs_path($_)}=1; + if (open (TRUST, "<", $trustfile)) { + while () { + chomp; + s/^~\//$ENV{HOME}\//; + $trusted{abs_path($_)}=1; + } + close TRUST; } - close TRUST; } return $trusted{$config}; @@ -1024,6 +1020,11 @@ sub is_trusted_checkout { return 0; } +sub trusterror { + die shift()."\n". + "(To trust this file, list it in ~/.mrtrust.)\n"; +} + my %loaded; sub loadconfig { my $f=shift; @@ -1097,7 +1098,7 @@ sub loadconfig { if (! is_trusted_repo($section) || $section eq 'ALIAS' || $section eq 'DEFAULT') { - die "mr: illegal section \"[$section]\" in untrusted $f line $line\n"; + trusterror "mr: illegal section \"[$section]\" in untrusted $f line $line"; } } $section=expandenv($section) if $trusted; @@ -1124,10 +1125,10 @@ sub loadconfig { # Untrusted files can only contain checkout # parameters. if ($parameter ne 'checkout') { - die "mr: illegal setting \"$parameter=$value\" in untrusted $f line $line\n"; + trusterror "mr: illegal setting \"$parameter=$value\" in untrusted $f line $line"; } if (! is_trusted_checkout($value)) { - die "mr: illegal checkout command \"$value\" in untrusted $f line $line\n"; + trusterror "mr: illegal checkout command \"$value\" in untrusted $f line $line"; } } -- 2.39.5 From 69a60fb0a34b214c9ff6d55350b4663b4452c397 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 19 Jan 2011 14:28:06 -0400 Subject: [PATCH 15/16] The -p flag is now enabled by default. mr first reads ~/.mrconfig, and then looks for an additional .mrconfig file in the current directory or one of its parent directories. Closes: #557963 --- TODO | 9 --------- debian/changelog | 3 +++ mr | 37 +++++++++++++++++++++---------------- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/TODO b/TODO index 43eae03..34ba317 100644 --- a/TODO +++ b/TODO @@ -1,12 +1,3 @@ -* After the mtrust flag day, consider making something similar to -p - be enabled by default. - - It should not be identical to -p, for the following reason: -p causes - mr to only look at the mrconfig it finds in the path (like -c only looks - at the specified file). But by default, mr should certianly load the - ~/.mrconfig (and files it chains). This allows a user to globally - configure mr with aliases, etc. (Closes: #557963) - * a way to detect repos in a tree that are not registered, and warn about or even auto-register them. (svn externals make this quite difficult!) diff --git a/debian/changelog b/debian/changelog index 29dd877..0a44ad2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,9 @@ mr (1.00) UNRELEASED; urgency=low * Trust flag day. All mrconfig files except the main ~/.mrconfig are now untrusted by default, until listed in ~/.mrtrust. + * The -p flag is now enabled by default. mr first reads ~/.mrconfig, + and then looks for an additional .mrconfig file in the current + directory or one of its parent directories. Closes: #557963 -- Joey Hess Wed, 19 Jan 2011 13:39:43 -0400 diff --git a/mr b/mr index 41a5362..3f04b5b 100755 --- a/mr +++ b/mr @@ -49,7 +49,9 @@ and work on only that repository, B is configured by .mrconfig files, which list the repositories. It starts by reading the .mrconfig file in your home directory, and this can -in turn chain load .mrconfig files from repositories. +in turn chain load .mrconfig files from repositories. It also automatically +looks for a .mrconfig file in the current directory, or in one of its +parent directories. These predefined commands should be fairly familiar to users of any revision control system: @@ -128,7 +130,7 @@ repository in the current directory is registered, or you can specify a directory to register. The mrconfig file that is modified is chosen by either the -c option, or by -looking for the closest known one at or below the current directory. +looking for the closest known one at or in a parent of the current directory. =item config @@ -149,8 +151,8 @@ To see the built-in library of shell functions contained in mr: mr config DEFAULT lib -The ~/.mrconfig file is used by default. To use a different config file, -use the -c option. +The mrconfig file that is used is chosen by either the -c option, or by +looking for the closest known one at or in a parent of the current directory. =item offline @@ -200,14 +202,9 @@ the current working directory. =item --config mrconfig -Use the specified mrconfig file. The default is B<~/.mrconfig> - -=item -p - -=item --path - -Search in the current directory, and its parent directories and use -the first B<.mrconfig> found, instead of the default B<~/.mrconfig>. +Use the specified mrconfig file. The default is to use both B<~/.mrconfig> +as well as look for a .mrconfig file in the current directory, or in one +of its parent directories. =item -v @@ -272,6 +269,12 @@ a good speedup in updates without loading the machine too much. Trust all mrconfig files even if they are not listed in ~/.mrtrust. Use with caution. +=item -p + +=item --path + +This obsolete flag is ignored. + =back =head1 MRCONFIG FILES @@ -468,7 +471,8 @@ my $no_chdir=0; my $jobs=1; my $trust_all=0; my $directory=getcwd(); -$ENV{MR_CONFIG}="$ENV{HOME}/.mrconfig"; + +$ENV{MR_CONFIG}=find_mrconfig(); # globals :-( my %config; @@ -1486,7 +1490,7 @@ sub expandaction { return $action; } -sub find_nearest_mrconfig { +sub find_mrconfig { my $dir=getcwd(); while (length $dir) { if (-e "$dir/.mrconfig") { @@ -1494,7 +1498,7 @@ sub find_nearest_mrconfig { } $dir=~s/\/[^\/]*$//; } - die "no .mrconfig found in path\n"; + return "$ENV{HOME}/.mrconfig"; } sub getopts { @@ -1503,7 +1507,7 @@ sub getopts { my $result=GetOptions( "d|directory=s" => sub { $directory=abs_path($_[1]) }, "c|config=s" => sub { $ENV{MR_CONFIG}=$_[1]; $config_overridden=1 }, - "p|path" => sub { $ENV{MR_CONFIG}=find_nearest_mrconfig(); $config_overridden=1 }, + "p|path" => sub { }, # now default, ignore "v|verbose" => \$verbose, "q|quiet" => \$quiet, "s|stats" => \$stats, @@ -1563,6 +1567,7 @@ sub main { init(); startingconfig(); + loadconfig("$ENV{HOME}/.mrconfig"); loadconfig($ENV{MR_CONFIG}); #use Data::Dumper; print Dumper(\%config); -- 2.39.5 From ff5c36782f4c2dc1cf08b9501f3fd479f3889a28 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 19 Jan 2011 14:29:26 -0400 Subject: [PATCH 16/16] releasing version 1.00 --- debian/changelog | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 0a44ad2..ee25f41 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -mr (1.00) UNRELEASED; urgency=low +mr (1.00) unstable; urgency=low * Trust flag day. All mrconfig files except the main ~/.mrconfig are now untrusted by default, until listed in ~/.mrtrust. @@ -6,7 +6,7 @@ mr (1.00) UNRELEASED; urgency=low and then looks for an additional .mrconfig file in the current directory or one of its parent directories. Closes: #557963 - -- Joey Hess Wed, 19 Jan 2011 13:39:43 -0400 + -- Joey Hess Wed, 19 Jan 2011 14:28:38 -0400 mr (0.51) unstable; urgency=low -- 2.39.5