Commit does not allow missing email address but whoami says this is allowed
John Arbash Meinel
john at arbash-meinel.com
Wed Nov 1 20:16:21 GMT 2006
Nicholas Allen wrote:
> As we are working on an internal closed source system we probably would
> not want to set our email address. Not inculding one when setting your
> id using whoami says it is not recommended but it is allowed. If you try
> to commit changes though commit complains that it does not have a valid
> email address.
>
> Nick
All we really care about is having "something at other", it doesn't have to
be a valid email address. But even that we shouldn't strictly require. I
tracked down one place that was expecting it, it seems you might be
running into another.
If you can attach the traceback it would make it easier to fix. But I'm
guessing the bug is in bzrlib/repository.py, line 2358
It uses:
s = '%s-%s-' % (self._config.user_email(),
compact_date(self._timestamp))
s += hexlify(rand_bytes(8))
I think the whole thing should be updated to something more like:
unique_chunk = osutils.rand_chars(16)
try:
user = self._config.user_email()
except errors.NoEmailInUsername:
user = sanitize(self._config.username())
s = '-'.join(unique_chunk, compact_date(self._timestamp), user)
In the short term this might be better:
s = '-'.join(user, compact_date(self._timestamp), unique_chunk)
But there are several fixes I'm doing at once.
1) If there is no email, just create something by sanitizing the
username. This should convert to lower case, remove whitespace, possibly
remove things outside of 'a-z0-9'. None of that is strictly necessary,
revision ids are just strings, but it is nice if they are
easy-to-work-with strings. Technically they are Unicode (which allows
easier conversions from other systems), but where possible we try not to
push it. (and we're discussing switching them to be strictly utf-8 strings)
2) It turns out that if you want to auto-complete revision ids, it is
better to have the randomness at the beginning rather than the end.
Because then it takes fewer characters before you've reached something
unique.
3) osutils.rand_chars() has more entropy per byte than
hexlify(osutils.rand_bytes())
Because hexlify uses a set of 16 characters, while rand_chars uses
letters and numbers for 36 possible characters.
(Which means that in 16 chars, hexlify(osutils.rand_bytes(8)) ==> 256^8
= 16^16 = 2^64 => 64 bits of entropy, while osutils.rand_chars(16) ==>
36^16 = 6^32 ~ 2^82.7 => 83 bits of entropy.
Anyway, 'sanitize()' would need to be written, but otherwise the simple
fix is just the try/catch around self._config.user_email()
If you want something that works *now* just put "user at host" in your user
identity. If we can decide on a fix, it would be easy to merge some of
these changes for bzr-0.13
John
=:->
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 254 bytes
Desc: OpenPGP digital signature
Url : https://lists.ubuntu.com/archives/bazaar/attachments/20061101/79f3bc01/attachment.pgp
More information about the bazaar
mailing list