[rfc][patch] bzr whoami can set your branch identity
Robey Pointer
robey at lag.net
Mon Jan 9 05:55:02 GMT 2006
On 8 Jan 2006, at 20:18, John Arbash Meinel wrote:
> Robey Pointer wrote:
>>
>> * Unless I misunderstood how it works, I think 'whoami' output should
>> be encoded into the user's encoding, so I fixed that.
>
> This might not be bzrlib.user_encoding. It should take
> sys.stdout.encoding if it is present. (Again when I finish my encoding
> branch, this will be done, I'm through about 1/2 of the commands).
Yeah, sys.stdout.encoding is probably better.
>> * I made a decorator '@with_user_encoding' for running a test
>> with the
>> user's encoding temporarily changed to something else. (I wanted to
>> test that both ascii and utf-8 would work.) Is there a better
>> way to
>> do that? I feel like I probably just overlooked some existing
>> mechanism for testing with a temporary encoding.
>
> Again, in my encoding branch, I have a parameter that you can pass to
> run_bzr which sets the encoding.
> Oh, and I generally avoid the Blackbox version of 'runbzr'.
> bzrlib.tests
> has a TestCase which has 'run_bzr' which I think has a much nicer
> interface. 'runbzr' is just a hangover of when we only had a single
> 'testbzr' file.
It looks like runbzr is just a very thin wrapper around run_bzr so
it's all good (though the names did cause me some confusion at first).
Once we're able to set stdin/stdout encoding separately, the run_bzr
interface should accept an option for that too. The "whoami" tests
are actually testing different stdout encodings.
> Just to point you to my branch:
> http://bzr.arbash-meinel.com/branches/bzr/encoding/
Cool, I'm downloading it now, though it's gonna be a while before it
finishes. If it's straightforward, I'll make my patch against that
branch instead.
> By the way, Apple Mail doesn't seem to do a very good job with
> attachments. It attaches your patch as:
> application/octet-stream; x-unix-mode=0644; name="whoami.patch"
I think this is because it's trying to guess the file type via
extension, since I created the file from a shell. I'll try a .txt
extension next time.
> Anyway, to discuss you patch...
> I would like a way to specify that I want to set the global option. In
> fact, I might prefer to have it set the global option, unless I use a
> flag to say I want the local one.
> For people just getting started, who just had bzr not correctly set
> their email. They may have started a branch, and found out that the
> email was wrong. So they go to set their email and everything seems
> fine, but then when they switch to another branch, their email is
> incorrect again.
The reason I did it only as a branch option is that the global option
is stored in bazaar.conf, which I was told shouldn't be changed by
bzr, only read. Otherwise I agree with you that it really should be
setting the global identity.
How do people feel about relaxing that restriction on bazaar.conf, at
least for the "whoami" command?
> + self.log('run bzr: %s', ' '.join(argv).encode('string-
> escape'))
>
> Just do:
> self.log('run bzr: %r', ' '.join(argv))
>
> %r says to use python's repr() function (representation), which for
> strings means it makes them ascii safe.
> Basically %r (repr) is meant something like "give me the form that I
> would put inside a .py file if I wanted to create this".
Yeah, I know. :) My assumption is generally that the original author
wrote the code they wanted, so I try to keep the spirit of it.
Adding encode('string-escape') was my way of trying to make as
minimal change there as possible. %r is a bit heavier (it adds
quotes) but I honestly don't care either way -- I would prefer not to
have to change that code at all. ;) So hopefully this patch made
against your encodings branch will be smaller.
robey
More information about the bazaar
mailing list