Mercurial > hgsubversion
comparison hgsubversion/maps.py @ 1213:295d2f0cc275
maps: change branchmap to initialize with an svnmeta object
This refactoring will help us in a future patch have all map objects inherit
from a common ancestor.
| author | Sean Farley <sean.michael.farley@gmail.com> |
|---|---|
| date | Mon, 24 Mar 2014 11:20:48 -0500 |
| parents | 56d6e0273733 |
| children | 2c793092862b |
comparison
equal
deleted
inserted
replaced
| 1212:0ca7f80d0ab6 | 1213:295d2f0cc275 |
|---|---|
| 366 | 366 |
| 367 All changes on the oldname branch will now be on the newname branch; all | 367 All changes on the oldname branch will now be on the newname branch; all |
| 368 changes on other will now be on default (have no branch name set). | 368 changes on other will now be on default (have no branch name set). |
| 369 ''' | 369 ''' |
| 370 | 370 |
| 371 def __init__(self, ui, path): | 371 def __init__(self, meta): |
| 372 self.ui = ui | 372 self.meta = meta |
| 373 self.path = path | |
| 374 self.super = super(BranchMap, self) | 373 self.super = super(BranchMap, self) |
| 375 self.super.__init__() | 374 self.super.__init__() |
| 376 self.load(path) | 375 self.load(self.meta.branchmap_file) |
| 377 | 376 |
| 378 # append branch mapping specified from the commandline | 377 # append branch mapping specified from the commandline |
| 379 clmap = util.configpath(self.ui, 'branchmap') | 378 clmap = util.configpath(self.meta.ui, 'branchmap') |
| 380 if clmap: | 379 if clmap: |
| 381 self.load(clmap) | 380 self.load(clmap) |
| 382 | 381 |
| 383 def load(self, path): | 382 def load(self, path): |
| 384 '''Load mappings from a file at the specified path.''' | 383 '''Load mappings from a file at the specified path.''' |
| 385 if not os.path.exists(path): | 384 if not os.path.exists(path): |
| 386 return | 385 return |
| 387 | 386 |
| 388 writing = False | 387 writing = False |
| 389 if path != self.path: | 388 if path != self.meta.branchmap_file: |
| 390 writing = open(self.path, 'a') | 389 writing = open(self.meta.branchmap_file, 'a') |
| 391 | 390 |
| 392 self.ui.debug('reading branchmap from %s\n' % path) | 391 self.ui.debug('reading branchmap from %s\n' % path) |
| 393 f = open(path, 'r') | 392 f = open(path, 'r') |
| 394 for number, line in enumerate(f): | 393 for number, line in enumerate(f): |
| 395 | 394 |
| 402 | 401 |
| 403 try: | 402 try: |
| 404 src, dst = line.split('=', 1) | 403 src, dst = line.split('=', 1) |
| 405 except (IndexError, ValueError): | 404 except (IndexError, ValueError): |
| 406 msg = 'ignoring line %i in branch map %s: %s\n' | 405 msg = 'ignoring line %i in branch map %s: %s\n' |
| 407 self.ui.status(msg % (number, path, line.rstrip())) | 406 self.meta.ui.status(msg % (number, path, line.rstrip())) |
| 408 continue | 407 continue |
| 409 | 408 |
| 410 src = src.strip() | 409 src = src.strip() |
| 411 dst = dst.strip() | 410 dst = dst.strip() |
| 412 self.ui.debug('adding branch %s to branch map\n' % src) | 411 self.meta.ui.debug('adding branch %s to branch map\n' % src) |
| 413 | 412 |
| 414 if not dst: | 413 if not dst: |
| 415 # prevent people from assuming such lines are valid | 414 # prevent people from assuming such lines are valid |
| 416 raise hgutil.Abort('removing branches is not supported, yet\n' | 415 raise hgutil.Abort('removing branches is not supported, yet\n' |
| 417 '(line %i in branch map %s)' | 416 '(line %i in branch map %s)' |
| 418 % (number, path)) | 417 % (number, path)) |
| 419 elif src in self and dst != self[src]: | 418 elif src in self and dst != self[src]: |
| 420 msg = 'overriding branch: "%s" to "%s" (%s)\n' | 419 msg = 'overriding branch: "%s" to "%s" (%s)\n' |
| 421 self.ui.status(msg % (self[src], dst, src)) | 420 self.meta.ui.status(msg % (self[src], dst, src)) |
| 422 self[src] = dst | 421 self[src] = dst |
| 423 | 422 |
| 424 f.close() | 423 f.close() |
| 425 if writing: | 424 if writing: |
| 426 writing.close() | 425 writing.close() |
