Mercurial > kallithea
comparison rhodecode/lib/utils.py @ 2989:190e2ff4595d beta
fix for issue #602, enforce str when setting mercurial UI object. When this is used together with mercurial internal translation system
it can lead to UnicodeDecodeErrors
author | Marcin Kuzminski <marcin@python-works.com> |
---|---|
date | Wed, 07 Nov 2012 19:38:46 +0100 |
parents | b14850a72bc2 |
children | da3926d9e56e |
comparison
equal
deleted
inserted
replaced
2988:8ca4d9f64ae0 | 2989:190e2ff4595d |
---|---|
305 cfg = config.config() | 305 cfg = config.config() |
306 cfg.read(path) | 306 cfg.read(path) |
307 for section in ui_sections: | 307 for section in ui_sections: |
308 for k, v in cfg.items(section): | 308 for k, v in cfg.items(section): |
309 log.debug('settings ui from file[%s]%s:%s' % (section, k, v)) | 309 log.debug('settings ui from file[%s]%s:%s' % (section, k, v)) |
310 baseui.setconfig(section, k, v) | 310 baseui.setconfig(safe_str(section), safe_str(k), safe_str(v)) |
311 | 311 |
312 elif read_from == 'db': | 312 elif read_from == 'db': |
313 sa = meta.Session() | 313 sa = meta.Session() |
314 ret = sa.query(RhodeCodeUi)\ | 314 ret = sa.query(RhodeCodeUi)\ |
315 .options(FromCache("sql_cache_short", "get_hg_ui_settings"))\ | 315 .options(FromCache("sql_cache_short", "get_hg_ui_settings"))\ |
318 hg_ui = ret | 318 hg_ui = ret |
319 for ui_ in hg_ui: | 319 for ui_ in hg_ui: |
320 if ui_.ui_active: | 320 if ui_.ui_active: |
321 log.debug('settings ui from db[%s]%s:%s', ui_.ui_section, | 321 log.debug('settings ui from db[%s]%s:%s', ui_.ui_section, |
322 ui_.ui_key, ui_.ui_value) | 322 ui_.ui_key, ui_.ui_value) |
323 baseui.setconfig(ui_.ui_section, ui_.ui_key, ui_.ui_value) | 323 baseui.setconfig(safe_str(ui_.ui_section), safe_str(ui_.ui_key), |
324 safe_str(ui_.ui_value)) | |
324 if ui_.ui_key == 'push_ssl': | 325 if ui_.ui_key == 'push_ssl': |
325 # force set push_ssl requirement to False, rhodecode | 326 # force set push_ssl requirement to False, rhodecode |
326 # handles that | 327 # handles that |
327 baseui.setconfig(ui_.ui_section, ui_.ui_key, False) | 328 baseui.setconfig(safe_str(ui_.ui_section), safe_str(ui_.ui_key), |
329 False) | |
328 if clear_session: | 330 if clear_session: |
329 meta.Session.remove() | 331 meta.Session.remove() |
330 return baseui | 332 return baseui |
331 | 333 |
332 | 334 |