Mercurial > hgsubversion
comparison tests/test_util.py @ 1245:260212f056b7
test_util: fix up i18n monkeypatch for Mercurial 3.2
Mercurial rev 0d0350cfc7ab changed the API a bit.
author | Siddharth Agarwal <sid0@fb.com> |
---|---|
date | Tue, 14 Oct 2014 18:12:24 -0400 |
parents | 339b5703000c |
children | 0f1f88e71138 |
comparison
equal
deleted
inserted
replaced
1244:012965ab3bf7 | 1245:260212f056b7 |
---|---|
22 from mercurial import hg | 22 from mercurial import hg |
23 from mercurial import i18n | 23 from mercurial import i18n |
24 from mercurial import node | 24 from mercurial import node |
25 from mercurial import scmutil | 25 from mercurial import scmutil |
26 from mercurial import ui | 26 from mercurial import ui |
27 from mercurial import util | 27 from mercurial import util as hgutil |
28 from mercurial import extensions | 28 from mercurial import extensions |
29 | 29 |
30 from hgsubversion import compathacks | 30 from hgsubversion import compathacks |
31 | 31 |
32 try: | 32 try: |
452 # the Python 2.7 default of 640 is obnoxiously low | 452 # the Python 2.7 default of 640 is obnoxiously low |
453 self.maxDiff = 4096 | 453 self.maxDiff = 4096 |
454 | 454 |
455 self.oldenv = dict([(k, os.environ.get(k, None),) for k in | 455 self.oldenv = dict([(k, os.environ.get(k, None),) for k in |
456 ('LANG', 'LC_ALL', 'HGRCPATH',)]) | 456 ('LANG', 'LC_ALL', 'HGRCPATH',)]) |
457 self.oldt = i18n.t | 457 try: |
458 os.environ['LANG'] = os.environ['LC_ALL'] = 'C' | 458 self.oldugettext = i18n._ugettext # Mercurial >= 3.2 |
459 i18n.t = gettext.translation('hg', i18n.localedir, fallback=True) | 459 except AttributeError: |
460 self.oldt = i18n.t | |
461 os.environ['LANG'] = os.environ['LC_ALL'] = 'C' | |
462 i18n.t = gettext.translation('hg', i18n.localedir, fallback=True) | |
463 else: | |
464 os.environ['LANG'] = os.environ['LC_ALL'] = 'C' | |
465 i18n.setdatapath(hgutil.datapath) | |
460 | 466 |
461 self.oldwd = os.getcwd() | 467 self.oldwd = os.getcwd() |
462 self.tmpdir = tempfile.mkdtemp( | 468 self.tmpdir = tempfile.mkdtemp( |
463 'svnwrap_test', dir=os.environ.get('HGSUBVERSION_TEST_TEMP', None)) | 469 'svnwrap_test', dir=os.environ.get('HGSUBVERSION_TEST_TEMP', None)) |
464 os.chdir(self.tmpdir) | 470 os.chdir(self.tmpdir) |
501 for var, val in self.oldenv.iteritems(): | 507 for var, val in self.oldenv.iteritems(): |
502 if val is None: | 508 if val is None: |
503 del os.environ[var] | 509 del os.environ[var] |
504 else: | 510 else: |
505 os.environ[var] = val | 511 os.environ[var] = val |
506 i18n.t = self.oldt | 512 try: |
513 i18n._ugettext = self.oldugettext # Mercurial >= 3.2 | |
514 except AttributeError: | |
515 i18n.t = self.oldt | |
507 rmtree(self.tmpdir) | 516 rmtree(self.tmpdir) |
508 os.chdir(self.oldwd) | 517 os.chdir(self.oldwd) |
509 setattr(ui.ui, self.patch[0].func_name, self.patch[0]) | 518 setattr(ui.ui, self.patch[0].func_name, self.patch[0]) |
510 | 519 |
511 _verify_our_modules() | 520 _verify_our_modules() |