comparison tests/test_util.py @ 355:256863a65141

test_util: make it easier to test odd push cases
author Augie Fackler <durin42@gmail.com>
date Wed, 27 May 2009 15:51:04 -0500
parents 3d5c4352a6c8
children 83fcb1cf6d8f
comparison
equal deleted inserted replaced
354:36d26e158748 355:256863a65141
112 # define this as a property so that it reloads anytime we need it 112 # define this as a property so that it reloads anytime we need it
113 @property 113 @property
114 def repo(self): 114 def repo(self):
115 return hg.repository(ui.ui(), self.wc_path) 115 return hg.repository(ui.ui(), self.wc_path)
116 116
117 def pushrevisions(self, stupid=False): 117 def pushrevisions(self, stupid=False, expected_extra_back=0):
118 before = len(self.repo) 118 before = len(self.repo)
119 self.repo.ui.setconfig('hgsubversion', 'stupid', str(stupid)) 119 self.repo.ui.setconfig('hgsubversion', 'stupid', str(stupid))
120 commands.push(self.repo.ui, self.repo) 120 commands.push(self.repo.ui, self.repo)
121 after = len(self.repo) 121 after = len(self.repo)
122 self.assertEqual(0, after - before) 122 self.assertEqual(expected_extra_back, after - before)
123 123
124 def svnls(self, path, rev='HEAD'): 124 def svnls(self, path, rev='HEAD'):
125 path = self.repo_path + '/' + path 125 path = self.repo_path + '/' + path
126 path = util.normalize_url(fileurl(path)) 126 path = util.normalize_url(fileurl(path))
127 args = ['svn', 'ls', '-r', rev, '-R', path] 127 args = ['svn', 'ls', '-r', rev, '-R', path]
133 raise Exception('svn ls failed on %s: %r' % (path, stderr)) 133 raise Exception('svn ls failed on %s: %r' % (path, stderr))
134 entries = [e.strip('/') for e in stdout.splitlines()] 134 entries = [e.strip('/') for e in stdout.splitlines()]
135 entries.sort() 135 entries.sort()
136 return entries 136 return entries
137 137
138 def commitchanges(self, changes, parent='tip'): 138 def commitchanges(self, changes, parent='tip', message='automated test'):
139 """Commit changes to mercurial directory 139 """Commit changes to mercurial directory
140 140
141 'changes' is a sequence of tuples (source, dest, data). It can look 141 'changes' is a sequence of tuples (source, dest, data). It can look
142 like: 142 like:
143 - (source, source, data) to set source content to data 143 - (source, source, data) to set source content to data
173 isexec=False, 173 isexec=False,
174 copied=copied) 174 copied=copied)
175 175
176 ctx = context.memctx(repo, 176 ctx = context.memctx(repo,
177 (parentctx.node(), node.nullid), 177 (parentctx.node(), node.nullid),
178 'automated test', 178 message,
179 changed + removed, 179 changed + removed,
180 filectxfn, 180 filectxfn,
181 'an_author', 181 'an_author',
182 '2008-10-07 20:59:48 -0500') 182 '2008-10-07 20:59:48 -0500')
183 nodeid = repo.commitctx(ctx) 183 nodeid = repo.commitctx(ctx)