#
# patch "ChangeLog"
# from [e19ffdc561289bda2d3d6bea8525a46505d1cb33]
# to [6a5ad7bb154faff86484fcb01f030f5dd6124051]
#
# patch "commands.cc"
# from [180e64e3feece8d9611ce2ab1eaaf85e44375cca]
# to [580074afb0d90e382e6d0af91258b6d4521888c8]
#
# patch "contrib/monotone-notify.pl"
# from [5f5ac153b2bdd5d80b2e78dc57b1bd7c8b87c008]
# to [59cf5c04e891778a0c5329d4fb0fb1eacd2b22df]
#
--- ChangeLog
+++ ChangeLog
@@ -1,7 +1,10 @@
2005-04-18 Richard Levitte
* contrib/monotone-notify.pl (my_exit): The comment was incorrect,
there are no network connections to close gracefully.
+ Implement --ignore-merges, which is on by default, and changes the
+ behavior to not produce diffs on merges and propagates where the
+ ancestors hve already been shown.
* tests/t_drop_attr.at: New test, similar to t_rename_attr.at.
* testsuite.at: Add it.
--- commands.cc
+++ commands.cc
@@ -1,3 +1,4 @@
+// -*- mode: C++; c-file-style: "gnu"; indent-tabs-mode: nil -*-
// copyright (C) 2002, 2003 graydon hoare
// all rights reserved.
// licensed to the public under the terms of the GNU GPL (>= 2)
@@ -2473,8 +2474,8 @@
app.db.delete_existing_rev_and_certs(ident);
}
-CMD(attr, "working copy", "set FILE ATTR VALUE\nget FILE [ATTR]",
- "get or set file attributes")
+CMD(attr, "working copy", "set FILE ATTR VALUE\nget FILE [ATTR]\ndrop FILE",
+ "set, get or drop file attributes")
{
if (args.size() < 2 || args.size() > 4)
throw usage(name);
@@ -2495,31 +2496,30 @@
file_path path = app.prefix(idx(args,1)());
N(file_exists(path), F("file '%s' not found") % path);
+ bool attrs_modified = false;
+
if (idx(args, 0)() == "set")
{
if (args.size() != 4)
throw usage(name);
attrs[path][idx(args, 2)()] = idx(args, 3)();
- write_attr_map(attr_data, attrs);
- write_data(attr_path, attr_data);
- {
- // check to make sure .mt-attr exists in
- // current manifest.
- manifest_map man;
- calculate_base_manifest(app, man);
- if (man.find(attr_path) == man.end())
- {
- P(F("registering %s file in working copy\n") % attr_path);
- change_set::path_rearrangement work;
- get_path_rearrangement(work);
- vector paths;
- paths.push_back(attr_path);
- build_additions(paths, man, app, work);
- put_path_rearrangement(work);
- }
- }
+ attrs_modified = true;
+ }
+ else if (idx(args, 0)() == "drop")
+ {
+ if (args.size() == 1)
+ {
+ attrs.erase(path);
+ }
+ else if (args.size() == 2)
+ {
+ attrs[path].erase(idx(args, 2)());
+ }
+ else
+ throw usage(name);
+ attrs_modified = true;
}
else if (idx(args, 0)() == "get")
{
@@ -2549,6 +2549,29 @@
}
else
throw usage(name);
+
+ if (attrs_modified)
+ {
+ write_attr_map(attr_data, attrs);
+ write_data(attr_path, attr_data);
+
+ {
+ // check to make sure .mt-attr exists in
+ // current manifest.
+ manifest_map man;
+ calculate_base_manifest(app, man);
+ if (man.find(attr_path) == man.end())
+ {
+ P(F("registering %s file in working copy\n") % attr_path);
+ change_set::path_rearrangement work;
+ get_path_rearrangement(work);
+ vector paths;
+ paths.push_back(attr_path);
+ build_additions(paths, man, app, work);
+ put_path_rearrangement(work);
+ }
+ }
+ }
}
static boost::posix_time::ptime
--- contrib/monotone-notify.pl
+++ contrib/monotone-notify.pl
@@ -38,23 +38,23 @@
######################################################################
# User options
#
-my $user_database = undef;
-my @user_branches = ();
my $help = 0;
my $man = 0;
-my $mail = -1;
-my $debug = 0;
-my $quiet = 0;
+my $user_database = undef;
+my $root = undef;
+my @user_branches = ();
my $update = -1;
+my $mail = -1;
+my $attachments = 1;
+my $ignore_merges = 1;
my $from = undef;
my $difflogs_to = undef;
my $nodifflogs_to = undef;
-my $to = undef;
-my $attachments = 1;
my $before = undef;
my $since = undef;
my $workdir = undef;
-my $root = undef;
+my $quiet = 0;
+my $debug = 0;
GetOptions('help|?' => \$help,
'man' => \$man,
@@ -64,6 +64,7 @@
'update!' => \$update,
'mail!' => \$mail,
'attachments!' => \$attachments,
+ 'ignore-merges!' => \$ignore_merges,
'from=s' => \$from,
'difflogs-to=s' => \$difflogs_to,
'nodifflogs-to=s' => \$nodifflogs_to,
@@ -296,6 +297,34 @@
my $to = $sendinfo->[2];
next if !defined $to;
+ my @ancestors =
+ map { (split ' ')[1] }
+ grep(/^Ancestor:/, @{$revision_data{$revision}});
+
+ # If this revision has more than one ancestor, it's the
+ # result of a merge. If we have already shown the
+ # participating ancestors, let's not show the diffs again.
+ if ($ignore_merges && $diffs && $#ancestors > 0) {
+ my $will_ignore = 1;
+ my %revision_branches =
+ map { (split ' ')[1] => 1 }
+ grep /^Branch:/, @{$revision_data{$revision}};
+ my_debug("Checking if $revision's ancestor have already been shown (probably).");
+ foreach (@ancestors) {
+ if (!revision_is_in_branch($_,
+ { %branches,
+ %revision_branches },
+ { %revision_data })) {
+ my_debug("Not ignoring this one!");
+ $will_ignore = 0;
+ }
+ }
+ if ($will_ignore) {
+ $diffs = 0;
+ my_debug("Not showing diff for revision $revision, because all it's ancestors\nhave already been shown.");
+ }
+ }
+
# If --nodiffs was used, it's silly to use attachments
my $attach = $attachments;
$attach = 0 if $diffs == 0;
@@ -305,9 +334,6 @@
# correctly sorted order.
my %file_info = (); # Hold information about each file.
- my @ancestors =
- map { (split ' ')[1] }
- grep(/^Ancestor:/, @{$revision_data{$revision}});
# Make sure we have a null ancestor if there are none.
# generate_diff will do the right thing with it.
if ($#ancestors < 0) {
@@ -518,6 +544,36 @@
close OUTPUT;
}
+# revision_is_in_branch checks if the given revision is in one of the
+# given branches. The latter is given in form of a hash.
+sub revision_is_in_branch
+{
+ my ($revision, $branches, $revision_data) = @_;
+ my $bool = 0;
+
+ my_debug("Checking if $revision has already been shown in one of
+ these branches:\n ",
+ join("\n ", keys %$branches));
+
+ if (!defined $$revision_data{$revision}) {
+ $$revision_data{$revision} =
+ [ map { chomp; $_ }
+ my_backtick("monotone$database log --depth=1 $revision") ];
+ }
+
+ map {
+ my $branch = (split ' ')[1];
+ if (defined $$branches{$branch}) {
+ $bool = 1;
+ my_debug("Found it in $branch");
+ }
+ } grep /^Branch:/, @{$$revision_data{$revision}};
+
+ my_debug("Didn't find it in any of the branches...") if !$bool;
+
+ return $bool;
+}
+
# my_log will simply output all it's arguments, prefixed with "Notify: ",
# unless $quiet is true.
sub my_log
@@ -643,7 +699,7 @@
monotone-notify.pl [--help] [--man]
[--db=database] [--root=path] [--branch=branch ...]
-[--[no]update] [--[no]mail] [--[no]attachments]
+[--[no]update] [--[no]mail] [--[no]attachments] [--[no]ignore-merges]
[--from=email-sender]
[--difflogs-to=email-recipient] [--nodifflogs-to=email-recipient]
[--workdir=path] [--before=yyyy-mm-ddThh:mm:ss] [--since=yyyy-mm-ddThh:mm:ss]
@@ -715,6 +771,16 @@
Have the change summary and the output of 'monotone diff' in the body
of the email, separated by lines of dashes.
+=item B<--ignore-merges>
+
+Do not create difflogs for merges (revisions with more than one
+ancestor), if the ancestors are in at least one of the branches that
+are monotored. This is the default behavior.
+
+=item B<--noignore-merges>
+
+Always create difflogs, even for merges.
+
=item B<--from>=I
Sets the sender address to be used when creating the emails. There is