diff options
author | Max Bowsher <maxb@f2s.com> | 2009-11-04 00:49:10 +0000 |
---|---|---|
committer | Max Bowsher <maxb@f2s.com> | 2009-11-04 00:49:10 +0000 |
commit | b0b323a519528740f29d7a30d58347774bda077c (patch) | |
tree | f81ffe23258e7ee2373e959e806ee5814c0b896e | |
parent | 1d07ce54fba8141889b64ab1877ba8179753d221 (diff) | |
download | python-fastimport-b0b323a519528740f29d7a30d58347774bda077c.tar.gz |
Avoid spurious 'git-' being prefixed on branches whose names happen to end with 'trunk',
by tightening logic in BranchMapper._git_to_bzr_name. Also document.
-rw-r--r-- | branch_mapper.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/branch_mapper.py b/branch_mapper.py index 3bfc39b..565f8e8 100644 --- a/branch_mapper.py +++ b/branch_mapper.py @@ -17,7 +17,11 @@ """An object that maps bzr branch names <-> git ref names.""" +import re + + class BranchMapper(object): + _GIT_TRUNK_RE = re.compile('(?:git-)*trunk') def git_to_bzr(self, ref_names): """Get the mapping from git reference names to Bazaar branch names. @@ -46,9 +50,13 @@ class BranchMapper(object): return bazaar_names def _git_to_bzr_name(self, git_name): + # Make a simple name more bzr-like, by mapping git 'master' to bzr 'trunk'. + # To avoid collision, map git 'trunk' to bzr 'git-trunk'. Likewise + # 'git-trunk' to 'git-git-trunk' and so on, such that the mapping is + # one-to-one in both directions. if git_name == 'master': bazaar_name = 'trunk' - elif git_name.endswith('trunk'): + elif self._GIT_TRUNK_RE.match(git_name): bazaar_name = 'git-%s' % (git_name,) else: bazaar_name = git_name |