[MERGE] (fixes 239523) bzr tag and other builtins respect --quiet

Aaron Bentley aaron at aaronbentley.com
Mon Jun 23 13:15:36 BST 2008


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Neil Martinsen-Burrell wrote:
> Aaron Bentley <aaron <at> aaronbentley.com> writes:
> 
>> Aaron Bentley has voted resubmit.
>> Status is now: Resubmit
>> Comment:
>> Optional/informational output should be written with bzrlib.trace.note, 
>> not by disabling it when is_quiet is true.
> 
> Duly note()'d.

This is quite nice. Only one remaining quibble:

> === modified file 'bzrlib/branch.py'
> --- bzrlib/branch.py	2008-06-18 05:14:28 +0000
> +++ bzrlib/branch.py	2008-06-21 20:55:07 +0000
> @@ -2187,10 +2187,11 @@
>  
>      def report(self, to_file):
>          """Write a human-readable description of the result."""
> -        if self.old_revid == self.new_revid:
> -            to_file.write('No new revisions to push.\n')
> -        else:
> -            to_file.write('Pushed up to revision %d.\n' % self.new_revno)
> +        if not is_quiet():
> +            if self.old_revid == self.new_revid:
> +                to_file.write('No new revisions to push.\n')
> +            else:
> +                to_file.write('Pushed up to revision %d.\n' % self.new_revno)
>          self._show_tag_conficts(to_file)

Generally, library functionality should not be affected by global
settings like this.  The library should ideally continue to behave the
same way when used the same way.

One solution would be to accept an optional callable for informational
messages.  e.g.:

def report(self, to_file, note_callable=None):
    if not_callable is None:
        note_callable=to_file.write
    if self.old_revid == self.new_revid:
        note_callable('No new revisions to push.\n')
    else:
        note_callable('Pushed up to revision %d.\n' % self.new_revno)

And then update the callsites to supply trace.note as note_callable.

Aaron
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFIX5Po0F+nu1YWqI0RAt/mAJ9RqNAZU4dE5I0gprFFkiGG5+ic/QCfRecu
1UoYvSZK8IlICSdBuQNTLtM=
=s/lW
-----END PGP SIGNATURE-----



More information about the bazaar mailing list