# HG changeset patch # User Sean Farley # Date 1395678048 18000 # Node ID 295d2f0cc275ad959844294e9e7eb976ce674f06 # Parent 0ca7f80d0ab65f7a4094a2fe33bba217d4758550 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. diff --git a/hgsubversion/maps.py b/hgsubversion/maps.py --- a/hgsubversion/maps.py +++ b/hgsubversion/maps.py @@ -368,15 +368,14 @@ class BranchMap(dict): changes on other will now be on default (have no branch name set). ''' - def __init__(self, ui, path): - self.ui = ui - self.path = path + def __init__(self, meta): + self.meta = meta self.super = super(BranchMap, self) self.super.__init__() - self.load(path) + self.load(self.meta.branchmap_file) # append branch mapping specified from the commandline - clmap = util.configpath(self.ui, 'branchmap') + clmap = util.configpath(self.meta.ui, 'branchmap') if clmap: self.load(clmap) @@ -386,8 +385,8 @@ class BranchMap(dict): return writing = False - if path != self.path: - writing = open(self.path, 'a') + if path != self.meta.branchmap_file: + writing = open(self.meta.branchmap_file, 'a') self.ui.debug('reading branchmap from %s\n' % path) f = open(path, 'r') @@ -404,12 +403,12 @@ class BranchMap(dict): src, dst = line.split('=', 1) except (IndexError, ValueError): msg = 'ignoring line %i in branch map %s: %s\n' - self.ui.status(msg % (number, path, line.rstrip())) + self.meta.ui.status(msg % (number, path, line.rstrip())) continue src = src.strip() dst = dst.strip() - self.ui.debug('adding branch %s to branch map\n' % src) + self.meta.ui.debug('adding branch %s to branch map\n' % src) if not dst: # prevent people from assuming such lines are valid @@ -418,7 +417,7 @@ class BranchMap(dict): % (number, path)) elif src in self and dst != self[src]: msg = 'overriding branch: "%s" to "%s" (%s)\n' - self.ui.status(msg % (self[src], dst, src)) + self.meta.ui.status(msg % (self[src], dst, src)) self[src] = dst f.close() diff --git a/hgsubversion/svnmeta.py b/hgsubversion/svnmeta.py --- a/hgsubversion/svnmeta.py +++ b/hgsubversion/svnmeta.py @@ -242,7 +242,7 @@ class SVNMeta(object): @property def branchmap(self): if self._branchmap is None: - self._branchmap = maps.BranchMap(self.ui, self.branchmap_file) + self._branchmap = maps.BranchMap(self) return self._branchmap @property