comparison tests/test_util.py @ 499:1fd3cfa47c5e

Support for single-directory clones.
author Augie Fackler <durin42@gmail.com>
date Fri, 16 Oct 2009 23:33:41 -0400
parents 50d77547c218
children 0e2564d4257d
comparison
equal deleted inserted replaced
498:990e07054f29 499:1fd3cfa47c5e
80 } 80 }
81 81
82 FIXTURES = os.path.join(os.path.abspath(os.path.dirname(__file__)), 82 FIXTURES = os.path.join(os.path.abspath(os.path.dirname(__file__)),
83 'fixtures') 83 'fixtures')
84 84
85 def filtermanifest(manifest):
86 return filter(lambda x: x not in ('.hgtags', '.hgsvnexternals', ),
87 manifest)
88
85 def fileurl(path): 89 def fileurl(path):
86 path = os.path.abspath(path) 90 path = os.path.abspath(path)
87 drive, path = os.path.splitdrive(path) 91 drive, path = os.path.splitdrive(path)
88 path = urllib.pathname2url(path) 92 path = urllib.pathname2url(path)
89 if drive: 93 if drive:
101 inp = open(os.path.join(FIXTURES, fixture_name)) 105 inp = open(os.path.join(FIXTURES, fixture_name))
102 proc = subprocess.Popen(['svnadmin', 'load', path,], stdin=inp, 106 proc = subprocess.Popen(['svnadmin', 'load', path,], stdin=inp,
103 stdout=subprocess.PIPE, stderr=subprocess.STDOUT) 107 stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
104 proc.communicate() 108 proc.communicate()
105 109
106 def load_fixture_and_fetch(fixture_name, repo_path, wc_path, stupid=False, subdir='', noupdate=True): 110 def load_fixture_and_fetch(fixture_name, repo_path, wc_path, stupid=False, subdir='',
111 noupdate=True, layout='auto'):
107 load_svndump_fixture(repo_path, fixture_name) 112 load_svndump_fixture(repo_path, fixture_name)
108 if subdir: 113 if subdir:
109 repo_path += '/' + subdir 114 repo_path += '/' + subdir
110 115
111 _ui = ui.ui() 116 confvars = locals()
112 _ui.setconfig('hgsubversion', 'stupid', str(stupid)) 117 def conf():
118 for var in ('stupid', 'layout'):
119 _ui = ui.ui()
120 _ui.setconfig('hgsubversion', var, confvars[var])
121 return _ui
122 _ui = conf()
113 commands.clone(_ui, fileurl(repo_path), wc_path, noupdate=noupdate) 123 commands.clone(_ui, fileurl(repo_path), wc_path, noupdate=noupdate)
114 _ui = ui.ui() 124 _ui = conf()
115 _ui.setconfig('hgsubversion', 'stupid', str(stupid))
116 return hg.repository(_ui, wc_path) 125 return hg.repository(_ui, wc_path)
117 126
118 def rmtree(path): 127 def rmtree(path):
119 # Read-only files cannot be removed under Windows 128 # Read-only files cannot be removed under Windows
120 for root, dirs, files in os.walk(path): 129 for root, dirs, files in os.walk(path):
168 i18n.t = self.oldt 177 i18n.t = self.oldt
169 rmtree(self.tmpdir) 178 rmtree(self.tmpdir)
170 os.chdir(self.oldwd) 179 os.chdir(self.oldwd)
171 setattr(ui.ui, self.patch[0].func_name, self.patch[0]) 180 setattr(ui.ui, self.patch[0].func_name, self.patch[0])
172 181
173 def _load_fixture_and_fetch(self, fixture_name, subdir='', stupid=False): 182 def _load_fixture_and_fetch(self, fixture_name, subdir=None, stupid=False, layout='auto'):
183 if layout == 'single':
184 if subdir is None:
185 subdir = 'trunk'
186 elif subdir is None:
187 subdir = ''
174 return load_fixture_and_fetch(fixture_name, self.repo_path, 188 return load_fixture_and_fetch(fixture_name, self.repo_path,
175 self.wc_path, subdir=subdir, 189 self.wc_path, subdir=subdir,
176 stupid=stupid) 190 stupid=stupid, layout=layout)
177 191
178 # define this as a property so that it reloads anytime we need it 192 # define this as a property so that it reloads anytime we need it
179 @property 193 @property
180 def repo(self): 194 def repo(self):
181 return hg.repository(ui.ui(), self.wc_path) 195 return hg.repository(ui.ui(), self.wc_path)