Mercurial > hgsubversion
comparison tests/fixtures/rsvn.py @ 851:9ce00cb1d676
Merge alternate tunnel schemes.
author | Augie Fackler <durin42@gmail.com> |
---|---|
date | Sat, 25 Feb 2012 14:51:22 -0600 |
parents | e9af7eba88db |
children |
comparison
equal
deleted
inserted
replaced
850:d3bc067c0f72 | 851:9ce00cb1d676 |
---|---|
167 ["help", "username=", "message=", "version"]) | 167 ["help", "username=", "message=", "version"]) |
168 except getopt.GetoptError, e: | 168 except getopt.GetoptError, e: |
169 sys.stderr.write(str(e) + '\n\n') | 169 sys.stderr.write(str(e) + '\n\n') |
170 usage() | 170 usage() |
171 sys.exit(1) | 171 sys.exit(1) |
172 | 172 |
173 for opt, value in opts: | 173 for opt, value in opts: |
174 if opt == '--version': | 174 if opt == '--version': |
175 print '%s version %s' % (os.path.basename(sys.argv[0]), VERSION) | 175 print '%s version %s' % (os.path.basename(sys.argv[0]), VERSION) |
176 sys.exit(0) | 176 sys.exit(0) |
177 elif opt == '--help' or opt == '-h': | 177 elif opt == '--help' or opt == '-h': |
179 sys.exit(0) | 179 sys.exit(0) |
180 elif opt == '--username': | 180 elif opt == '--username': |
181 username = value | 181 username = value |
182 elif opt == '--message': | 182 elif opt == '--message': |
183 log_msg = value | 183 log_msg = value |
184 | 184 |
185 if log_msg == None: | 185 if log_msg == None: |
186 usage('Missing --message argument') | 186 usage('Missing --message argument') |
187 sys.exit(1) | 187 sys.exit(1) |
188 | 188 |
189 if len(args) != 1: | 189 if len(args) != 1: |
190 usage('Missing repository path argument') | 190 usage('Missing repository path argument') |
191 sys.exit(1) | 191 sys.exit(1) |
192 | 192 |
193 repos_path = args[0] | 193 repos_path = args[0] |
194 print 'Accessing repository at [%s]' % repos_path | 194 print 'Accessing repository at [%s]' % repos_path |
195 | 195 |
196 repository = Repository(repos_path, pool) | 196 repository = Repository(repos_path, pool) |
197 sub = repository.subpool() | 197 sub = repository.subpool() |
198 | 198 |
199 try: | 199 try: |
200 txn = repository.begin(username, log_msg) | 200 txn = repository.begin(username, log_msg) |
201 | 201 |
202 # Read commands from STDIN | 202 # Read commands from STDIN |
203 lineno = 0 | 203 lineno = 0 |
204 for line in sys.stdin: | 204 for line in sys.stdin: |
205 lineno += 1 | 205 lineno += 1 |
206 | 206 |
207 core.svn_pool_clear(sub) | 207 core.svn_pool_clear(sub) |
208 try: | 208 try: |
209 if COMMENT_RE.search(line): | 209 if COMMENT_RE.search(line): |
210 continue | 210 continue |
211 | 211 |
212 match = RCOPY_RE.search(line) | 212 match = RCOPY_RE.search(line) |
213 if match: | 213 if match: |
214 src = match.group(1) | 214 src = match.group(1) |
215 dest = match.group(2) | 215 dest = match.group(2) |
216 txn.copy(src, dest, sub) | 216 txn.copy(src, dest, sub) |
217 continue | 217 continue |
218 | 218 |
219 match = RMOVE_RE.search(line) | 219 match = RMOVE_RE.search(line) |
220 if match: | 220 if match: |
221 src = match.group(1) | 221 src = match.group(1) |
222 dest = match.group(2) | 222 dest = match.group(2) |
223 txn.move(src, dest, sub) | 223 txn.move(src, dest, sub) |
224 continue | 224 continue |
225 | 225 |
226 match = RMKDIR_RE.search(line) | 226 match = RMKDIR_RE.search(line) |
227 if match: | 227 if match: |
228 entry = match.group(1) | 228 entry = match.group(1) |
229 txn.mkdir(entry, sub) | 229 txn.mkdir(entry, sub) |
230 continue | 230 continue |
231 | 231 |
232 match = RDELETE_RE.search(line) | 232 match = RDELETE_RE.search(line) |
233 if match: | 233 if match: |
234 entry = match.group(1) | 234 entry = match.group(1) |
235 txn.delete(entry, sub) | 235 txn.delete(entry, sub) |
236 continue | 236 continue |
237 | 237 |
238 raise NameError, ('Unknown command [%s] on line %d' % | 238 raise NameError, ('Unknown command [%s] on line %d' % |
239 (line, lineno)) | 239 (line, lineno)) |
240 | 240 |
241 except: | 241 except: |
242 sys.stderr.write(('Exception occured while processing line %d:\n' % | 242 sys.stderr.write(('Exception occured while processing line %d:\n' % |
243 lineno)) | 243 lineno)) |
244 etype, value, tb = sys.exc_info() | 244 etype, value, tb = sys.exc_info() |
245 traceback.print_exception(etype, value, tb, None, sys.stderr) | 245 traceback.print_exception(etype, value, tb, None, sys.stderr) |
246 sys.stderr.write('\n') | 246 sys.stderr.write('\n') |
247 txn.rollback() | 247 txn.rollback() |
248 sys.exit(1) | 248 sys.exit(1) |
249 | 249 |
250 new_rev = txn.commit() | 250 new_rev = txn.commit() |
251 print '\nCommitted revision %d.' % new_rev | 251 print '\nCommitted revision %d.' % new_rev |
252 | 252 |
253 finally: | 253 finally: |
254 print '\nRepository closed.' | 254 print '\nRepository closed.' |
255 | 255 |
256 def main(): | 256 def main(): |
257 core.run_app(rsvn) | 257 core.run_app(rsvn) |