# # # patch "lib/perl/Annotate.pm" # from [c794162e7d1732fbd86bfe16d01f742294e415f7] # to [e661d1af425f89cdd8e133a7043ee460e7ab9518] # # patch "lib/perl/History.pm" # from [95eb7fc311fc0497bd10e2a863482922cd8057a4] # to [b5cc885dbd85311e972939ae03c7695885b02744] # # patch "mtn-browse" # from [902f462c637f4e257b8c971939f1d9e968d4b5bf] # to [51d2acb03063ce59f7c3ac22b46d0763d7e53d3b] # ============================================================ --- lib/perl/Annotate.pm c794162e7d1732fbd86bfe16d01f742294e415f7 +++ lib/perl/Annotate.pm e661d1af425f89cdd8e133a7043ee460e7ab9518 @@ -114,7 +114,14 @@ sub display_annotation($$$) # their prefix and text parts. $max_len = 0; - $instance->{prefix_length} = length(($lines[0] =~ m/^([^:]+):.*$/)[0]); + if (scalar(@lines) > 0) + { + $instance->{prefix_length} = length(($lines[0] =~ m/^([^:]+):.*$/)[0]); + } + else + { + $instance->{prefix_length} = 0; + } $template = sprintf("a%da2a*", $instance->{prefix_length}); for ($i = 0; $i < scalar(@lines); ++ $i) { @@ -456,9 +463,12 @@ sub mtn_annotate($$$$) my($list, $mtn_db, $revision_id, $file_name) = @_; my($buffer, - @cmd); + @cmd, + $cwd, + $err); - # Run mtn annotate. + # Run mtn annotate in the root directory so as to avoid any workspace + # conflicts. @$list = (); push(@cmd, "mtn"); @@ -467,7 +477,29 @@ sub mtn_annotate($$$$) push(@cmd, "-r"); push(@cmd, "i:" . $revision_id); push(@cmd, $file_name); - run_command(\$buffer, @cmd) or return; + $cwd = getcwd(); + eval + { + die("chdir failed: " . $!) unless (chdir(File::Spec->rootdir())); + run_command(\$buffer, @cmd) or return; + }; + $err = $@; + chdir($cwd); + if ($err ne "") + { + my $dialog = Gtk2::MessageDialog->new_with_markup + (undef, + ["modal"], + "warning", + "close", + __x("Problem running mtn annotate, got:\n" + . "{error_message}\n" + . "This should not be happening!", + error_message => Glib::Markup::escape_text($err))); + WindowManager->instance()->allow_input(sub { $dialog->run(); }); + $dialog->destroy(); + return; + } # Break up the input into a list of lines. ============================================================ --- lib/perl/History.pm 95eb7fc311fc0497bd10e2a863482922cd8057a4 +++ lib/perl/History.pm b5cc885dbd85311e972939ae03c7695885b02744 @@ -1937,9 +1937,12 @@ sub mtn_diff($$$$;$) my($list, $mtn_db, $revision_id_1, $revision_id_2, $file_name) = @_; my($buffer, - @cmd); + @cmd, + $cwd, + $err); - # Run mtn diff. + # Run mtn diff in the root directory so as to avoid any workspace + # conflicts. @$list = (); push(@cmd, "mtn"); @@ -1950,7 +1953,29 @@ sub mtn_diff($$$$;$) push(@cmd, "-r"); push(@cmd, "i:" . $revision_id_2); push(@cmd, $file_name) if (defined($file_name)); - run_command(\$buffer, @cmd) or return; + $cwd = getcwd(); + eval + { + die("chdir failed: " . $!) unless (chdir(File::Spec->rootdir())); + run_command(\$buffer, @cmd) or return; + }; + $err = $@; + chdir($cwd); + if ($err ne "") + { + my $dialog = Gtk2::MessageDialog->new_with_markup + (undef, + ["modal"], + "warning", + "close", + __x("Problem running mtn diff, got:\n" + . "{error_message}\n" + . "This should not be happening!", + error_message => Glib::Markup::escape_text($err))); + WindowManager->instance()->allow_input(sub { $dialog->run(); }); + $dialog->destroy(); + return; + } # Break up the input into a list of lines. ============================================================ --- mtn-browse 902f462c637f4e257b8c971939f1d9e968d4b5bf +++ mtn-browse 51d2acb03063ce59f7c3ac22b46d0763d7e53d3b @@ -57,6 +57,7 @@ use warnings; # Standard Perl and CPAN modules. +use Cwd qw(getcwd); use Data::Dumper; use File::Basename; use File::Spec; @@ -237,26 +238,46 @@ sub view_button_clicked_cb($$); exit(1); } - # Open a Monotone database. First attempt to open the current Monotone - # workspace's database. If this doesn't work or the default database is to - # be used anyway then attempt to open that database instead. + # Open a Monotone database. First attempt to open the current workspace's + # database. If this doesn't work or the database listed in the user's + # preferences file is to be used anyway then attempt to open that database + # instead. if ($user_preferences->{workspace}->{takes_precedence}) { + + # Attempt to open the current workspace's database. If this works then + # get the workspace's details and then re-open the database but this + # time explicitly specifying the database itself. When given a database + # name, Monotone::AutomateStdio will make sure any current workspace + # will not `interfere' the with the mtn subprocess. One could use the + # "--no-workspace" option but this is only supported on later versions. + eval { + my $db; $mtn = Monotone::AutomateStdio->new(); if ($user_preferences->{workspace}->{auto_select}) { + $mtn->get_option(\$db, "database"); $mtn->get_option(\$branch, "branch"); $mtn->get_base_revision_id(\$revision_id); + + # Unset the branch name if there is no revision associated with + # it (this can happen if we are in a new workspace on a new + # branch that doesn't exist in the database yet). + + $branch = undef if (! defined($revision_id)); } + $mtn = undef; + $mtn = Monotone::AutomateStdio->new($db); }; + } if (! defined($mtn) && $user_preferences->{default_mtn_db} ne "") { - # Attempt to open the default database. + # Attempt to open the database specified in the user's preferences. eval { @@ -2586,7 +2607,6 @@ sub setup_mtn_object($$) my($mtn, $parent) = @_; - $mtn->register_db_locked_handler(\&mtn_db_locked_handler, $parent); if ($user_preferences->{show_suspended}) { if ($mtn->can(MTN_IGNORE_SUSPEND_CERTS))