Rev 15: Merge two patches from Andew Tridgell: in file:///home/robertc/source/baz/plugins/email/trunk/

Robert Collins robertc at robertcollins.net
Fri Dec 1 04:59:37 GMT 2006


------------------------------------------------------------
revno: 15
revision-id: robertc at robertcollins.net-20061201045937-16d9addeac6c446c
parent: robertc at robertcollins.net-20060925054635-a85c916fa45b9550
parent: tridge at samba.org-20061201004342-whvaqhq5bicbby29
committer: Robert Collins <robertc at robertcollins.net>
branch nick: trunk
timestamp: Fri 2006-12-01 15:59:37 +1100
message:
  Merge two patches from Andew Tridgell:
   * post_commit_mailer option, to change the mail program used.
   * post_commit_difflimit option. email will now send the diff from the
     commit by default, unless the post_commit_difflimit option is set to 0.
modified:
  README                         README-20051018071212-c081f89570802202
  __init__.py                    __init__.py-20051018071212-f1765ec4521cab0b
    ------------------------------------------------------------
    revno: 14.1.4
    merged: tridge at samba.org-20061201004342-whvaqhq5bicbby29
    parent: tridge at samba.org-20061201004212-n11gl6edozpx559v
    committer: Andrew Tridgell <tridge at samba.org>
    branch nick: email
    timestamp: Fri 2006-12-01 11:43:42 +1100
    message:
      no message when difflimit not set
    ------------------------------------------------------------
    revno: 14.1.3
    merged: tridge at samba.org-20061201004212-n11gl6edozpx559v
    parent: tridge at samba.org-20061201003847-qw7wz8ondojifiit
    committer: Andrew Tridgell <tridge at samba.org>
    branch nick: email
    timestamp: Fri 2006-12-01 11:42:12 +1100
    message:
      split on newlines
    ------------------------------------------------------------
    revno: 14.1.2
    merged: tridge at samba.org-20061201003847-qw7wz8ondojifiit
    parent: tridge at samba.org-20061130233032-9yvmibcfekbblj05
    committer: Andrew Tridgell <tridge at samba.org>
    branch nick: email
    timestamp: Fri 2006-12-01 11:38:47 +1100
    message:
      added post_commit_difflimit option
    ------------------------------------------------------------
    revno: 14.1.1
    merged: tridge at samba.org-20061130233032-9yvmibcfekbblj05
    parent: robertc at robertcollins.net-20060925054635-a85c916fa45b9550
    committer: Andrew Tridgell <tridge at samba.org>
    branch nick: email
    timestamp: Fri 2006-12-01 10:30:32 +1100
    message:
      added post_commit_mailer option
=== modified file 'README'
--- a/README	2006-12-01 04:59:37 +0000
+++ b/README	2006-07-06 14:44:25 +0000
@@ -12,12 +12,3 @@
 If 'post_commit_url' is set, it is used instead of the branch URL
 (useful since in most cases, you commit to a private url, and you want
 the public HTTP url in the commit message).
-
-The option 'post_commit_mailer' can be used to override the name of
-the mail program to use. It should behave like /bin/mail, at minimum
-supporting the -s and -a options.
-
-By default, the diff for the commit will be included in the email, if the
-length is less than 1000 lines. This limit can be changed (for instance, to 0
-to disable the feature) by setting the option 'post_commit_difflimit' to the
-number of lines you wish it to be limited to.

=== modified file '__init__.py'
--- a/__init__.py	2006-12-01 04:59:37 +0000
+++ b/__init__.py	2006-07-06 14:57:53 +0000
@@ -54,53 +54,11 @@
                  end_revision=rev2,
                  verbose=True
                  )
-
-        if self.difflimit():
-            self.add_diff(outf, self.difflimit())
         return outf.getvalue()
 
-    def add_diff(self, outf, difflimit):
-        """Add the diff from the commit to the output.
-
-        If the diff has more than difflimit lines, it will be skipped.
-        """
-        from bzrlib.diff import show_diff_trees
-        # optionally show the diff if its smaller than the post_commit_difflimit option
-        revid1 = self.revision.revision_id
-        if self.revision.parent_ids:
-            revid2 = self.revision.parent_ids[0]
-        else:
-            revid2 = None
-        tree1, tree2 = self.branch.repository.revision_trees((revid1, revid2))
-        diff_content = StringIO()
-        show_diff_trees(tree1, tree2, diff_content)
-        lines = diff_content.getvalue().split("\n")
-        numlines = len(lines)
-        difflimit = self.difflimit()
-        if difflimit:
-            if numlines <= difflimit:
-                outf.write(diff_content.getvalue())
-            else:
-                outf.write("\nDiff too large for email (%d, the limit is %d).\n"
-                    % (numlines, difflimit))
-
-    def difflimit(self):
-        """maximum number of lines of diff to show."""
-        result = self.config.get_user_option('post_commit_difflimit')
-        if result is None:
-            result = 1000
-        return int(result)
-
-    def mailer(self):
-        """What mail program to use."""
-        result = self.config.get_user_option('post_commit_mailer')
-        if result is None:
-            result = "mail"
-        return result
-
     def _command_line(self):
-        return [self.mailer(), '-s', self.subject(), '-a',
-                "From: " + self.from_address(), self.to()]
+        return ['mail', '-s', self.subject(), '-a', "From: " + self.from_address(),
+                self.to()]
 
     def to(self):
         """What is the address the mail should go to."""



More information about the bazaar-commits mailing list