comparison tests/test_util.py @ 1255:139a44a63090 stable 1.7

Merge default into stable for a release.
author Augie Fackler <raf@durin42.com>
date Wed, 05 Nov 2014 12:48:59 -0500
parents 260212f056b7
children 0f1f88e71138
comparison
equal deleted inserted replaced
1230:807c443928d4 1255:139a44a63090
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:
106 'project_root_not_repo_root.svndump': '/dummyproj', 106 'project_root_not_repo_root.svndump': '/dummyproj',
107 'project_name_with_space.svndump': '/project name', 107 'project_name_with_space.svndump': '/project name',
108 'non_ascii_path_1.svndump': '/b\xC3\xB8b', 108 'non_ascii_path_1.svndump': '/b\xC3\xB8b',
109 'non_ascii_path_2.svndump': '/b%C3%B8b', 109 'non_ascii_path_2.svndump': '/b%C3%B8b',
110 'subdir_is_file_prefix.svndump': '/flaf', 110 'subdir_is_file_prefix.svndump': '/flaf',
111 'renames_with_prefix.svndump': '/prefix',
111 } 112 }
112 # map defining the layouts of the fixtures we can use with custom layout 113 # map defining the layouts of the fixtures we can use with custom layout
113 # these are really popular layouts, so I gave them names 114 # these are really popular layouts, so I gave them names
114 trunk_only = { 115 trunk_only = {
115 'default': 'trunk', 116 'default': 'trunk',
136 'default': 'trunk', 137 'default': 'trunk',
137 'dev_branch': 'branches/dev_branch', 138 'dev_branch': 'branches/dev_branch',
138 'old_trunk': 'branches/old_trunk', 139 'old_trunk': 'branches/old_trunk',
139 }, 140 },
140 'copies.svndump': trunk_only, 141 'copies.svndump': trunk_only,
142 'copyafterclose.svndump': {
143 'default': 'trunk',
144 'test': 'branches/test'
145 },
141 'copybeforeclose.svndump': { 146 'copybeforeclose.svndump': {
142 'default': 'trunk', 147 'default': 'trunk',
143 'test': 'branches/test' 148 'test': 'branches/test'
144 }, 149 },
145 'delentries.svndump': trunk_only, 150 'delentries.svndump': trunk_only,
154 'renamedproject.svndump': { 159 'renamedproject.svndump': {
155 'default': 'trunk', 160 'default': 'trunk',
156 'branch': 'branches/branch', 161 'branch': 'branches/branch',
157 }, 162 },
158 'renames.svndump': { 163 'renames.svndump': {
164 'default': 'trunk',
165 'branch1': 'branches/branch1',
166 },
167 'renames_with_prefix.svndump': {
159 'default': 'trunk', 168 'default': 'trunk',
160 'branch1': 'branches/branch1', 169 'branch1': 'branches/branch1',
161 }, 170 },
162 'replace_branch_with_branch.svndump': { 171 'replace_branch_with_branch.svndump': {
163 'default': 'trunk', 172 'default': 'trunk',
443 # the Python 2.7 default of 640 is obnoxiously low 452 # the Python 2.7 default of 640 is obnoxiously low
444 self.maxDiff = 4096 453 self.maxDiff = 4096
445 454
446 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
447 ('LANG', 'LC_ALL', 'HGRCPATH',)]) 456 ('LANG', 'LC_ALL', 'HGRCPATH',)])
448 self.oldt = i18n.t 457 try:
449 os.environ['LANG'] = os.environ['LC_ALL'] = 'C' 458 self.oldugettext = i18n._ugettext # Mercurial >= 3.2
450 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)
451 466
452 self.oldwd = os.getcwd() 467 self.oldwd = os.getcwd()
453 self.tmpdir = tempfile.mkdtemp( 468 self.tmpdir = tempfile.mkdtemp(
454 'svnwrap_test', dir=os.environ.get('HGSUBVERSION_TEST_TEMP', None)) 469 'svnwrap_test', dir=os.environ.get('HGSUBVERSION_TEST_TEMP', None))
455 os.chdir(self.tmpdir) 470 os.chdir(self.tmpdir)
492 for var, val in self.oldenv.iteritems(): 507 for var, val in self.oldenv.iteritems():
493 if val is None: 508 if val is None:
494 del os.environ[var] 509 del os.environ[var]
495 else: 510 else:
496 os.environ[var] = val 511 os.environ[var] = val
497 i18n.t = self.oldt 512 try:
513 i18n._ugettext = self.oldugettext # Mercurial >= 3.2
514 except AttributeError:
515 i18n.t = self.oldt
498 rmtree(self.tmpdir) 516 rmtree(self.tmpdir)
499 os.chdir(self.oldwd) 517 os.chdir(self.oldwd)
500 setattr(ui.ui, self.patch[0].func_name, self.patch[0]) 518 setattr(ui.ui, self.patch[0].func_name, self.patch[0])
501 519
502 _verify_our_modules() 520 _verify_our_modules()
656 else: 674 else:
657 changed.append(dest) 675 changed.append(dest)
658 676
659 def filectxfn(repo, memctx, path): 677 def filectxfn(repo, memctx, path):
660 if path in removed: 678 if path in removed:
661 raise IOError(errno.ENOENT, 679 return compathacks.filectxfn_deleted(memctx, path)
662 "File \"%s\" no longer exists" % path)
663 entry = [e for e in changes if path == e[1]][0] 680 entry = [e for e in changes if path == e[1]][0]
664 source, dest, newdata = entry 681 source, dest, newdata = entry
665 if newdata is None: 682 if newdata is None:
666 newdata = parentctx[source].data() 683 newdata = parentctx[source].data()
667 copied = None 684 copied = None