[MERGE] fix non-ascii messages handling in 'missing' command

John Arbash Meinel john at arbash-meinel.com
Wed Jun 28 15:19:30 BST 2006


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

Alexander Belchenko wrote:
> Attached patch provide blackbox test and fix for missing command.
> Writing test first indeed good thing in this particular case because
> fixing sys.stdout => self.outf does not make all things works right.
> 
> I hope John will satisfied by extending tests for non-ascii behaviour.
> 
> -- 
> Alexander
> 
> 
> 
> ------------------------------------------------------------------------
> 
> # Bazaar revision bundle v0.8
> #
> # message:
> #   fix non-ascii messages handling in 'missing' command
> # committer: Alexander Belchenko <bialix at ukr.net>
> # date: Wed 2006-06-28 00:05:22.358999968 +0300
> 
> === modified file bzrlib/builtins.py
> --- bzrlib/builtins.py
> +++ bzrlib/builtins.py
> @@ -2324,7 +2324,9 @@
>                       'show-ids',
>                       'verbose'
>                       ]
> +    encoding_type = 'replace'
>  
> +    @display_command
>      def run(self, other_branch=None, reverse=False, mine_only=False,
>              theirs_only=False, log_format=None, long=False, short=False, line=False, 
>              show_ids=False, verbose=False):
> @@ -2349,7 +2351,8 @@
>                      default = local_branch.get_config().log_format()
>                      log_format = get_log_format(long=long, short=short, 
>                                                  line=line, default=default)
> -                lf = log_formatter(log_format, sys.stdout,
> +                lf = log_formatter(log_format,
> +                                   to_file=self.outf,
>                                     show_ids=show_ids,
>                                     show_timezone='original')
>                  if reverse is False:

So @display_command is meant for commands that shouldn't print 'bzr:
broken-pipe' when piped into 'less' and canceled before they are finished.

I don't really think it is needed for missing. Though it could be argued
either way.

The 'encoding_type = "replace"' + sys.stdout => self.outf is the fix I
was looking for, and looks like what you did.

> 
> === modified file bzrlib/tests/blackbox/test_non_ascii.py // last-changed:biali
> ... x at ukr.net-20060627210508-04a3a55608df664e
> --- bzrlib/tests/blackbox/test_non_ascii.py
> +++ bzrlib/tests/blackbox/test_non_ascii.py
> @@ -494,4 +494,19 @@
>          txt = bzr('unknowns')
>          self.assertEqual('', txt)
>  
> -
> +    def test_missing(self):
> +        bzr = self.run_bzr_decode
> +
> +        # create empty tree as reference for missing
> +        self.run_bzr('init', 'empty-tree')
> +
> +        msg = self.info['message']
> +
> +        txt = bzr('missing', 'empty-tree', retcode=1)
> +        self.assertNotEqual(-1, txt.find(self.info['committer']))
> +        self.assertNotEqual(-1, txt.find(msg))
> +
> +        # Make sure missing doesn't fail even if we can't write out
> +        txt = bzr('missing', 'empty-tree', encoding='ascii', retcode=1)
> +        self.assertEqual(-1, txt.find(msg))
> +        self.assertNotEqual(-1, txt.find(msg.encode('ascii', 'replace')))
> 

The test looks good to me.
So the only debatable point is if we want 'bzr missing' to be a
'display_command' (swallow EPIPE).
It hasn't been so far, so I'm tempted to not add it. But missing is more
of a 'log' style command, so I'm not against it.

John
=:->
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.1 (Cygwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFEoo/yJdeBCYSNAAMRAgDTAJ90rYXy9stbYWcQEiGGaJ+NhX6AawCdEey0
5ErWSdLIr4gGAzJz521Ck9A=
=gvja
-----END PGP SIGNATURE-----




More information about the bazaar mailing list