[PATCH] bzr whoami

Robey Pointer robey at lag.net
Fri Jun 30 00:34:30 BST 2006

On 28 Jun 2006, at 23:44, Martin Pool wrote:

> On 28 Jun 2006, Robey Pointer <robey at lag.net> wrote:
>> +class TestWhoami(ExternalBase):
>> +
>> +    def test_whoami(self):
>> +        # this should always identify something, if only  
>> "john at localhost"
>> +        self.run_bzr("whoami")
>> +        self.run_bzr("whoami", "--email")
> You don't make any assertions about the result, other than that the
> command succeeds.  Is it intentional?

Yeah, this is from the original blackbox test, and I think John is  
right that it's intending just to check that something is returned.   
I changed it to explicitly check that both commands return a non- 
empty string that contains one '@'.

> ...
>> +        if bzr_email is not None:
>> +            os.environ['BZREMAIL'] = bzr_email
> The save/restore as a matter of form should be in a try/finally block,
> if only to help the reader.  (I see this is not your new code but  
> please
> fix it while you're there.)


>>  class cmd_whoami(Command):
> The docstring should probably give examples of how it can be used  
> to set
> the identity.

Okay, I gave that a shot.

> This seems to still print the username when you set it - is that  
> really
> best?  I'd expect either silence, or a confirmation message.

That makes sense.  It now remains silent when setting identity.

> I'm not sure why the decode is necessary - maybe sys.argv is byte
> strings.  But should we perhaps decode them at a higher level?

I think I figured this out.  Arg decoding happens within main(), so  
run_bzr assumes the args are already in unicode.  Hack removed.   
Instead I have the blackbox tests providing unicode strings as if  
they've already been decoded.

> Could you please add a note to NEWS, and please update the user
> documentation to explain that the userid can be set this way.

Okay, I edited NEWS, and a couple of relevant files in doc/  
(including the tutorial).  I edited the "how to set email" wiki page,  
but since the tutorial wiki page seems to be a direct copy of the bzr  
source, I only edited the source.

The bundle is pretty big now, so I'm only attaching the diff.  The  
branch still lives here:


-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: whoami-diff.txt
Url: https://lists.ubuntu.com/archives/bazaar/attachments/20060629/4da35bce/attachment.txt 

More information about the bazaar mailing list