summaryrefslogtreecommitdiff
path: root/morphlib/sysbranchdir.py
diff options
context:
space:
mode:
Diffstat (limited to 'morphlib/sysbranchdir.py')
-rw-r--r--morphlib/sysbranchdir.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/morphlib/sysbranchdir.py b/morphlib/sysbranchdir.py
index 4351c6b3..69119f5b 100644
--- a/morphlib/sysbranchdir.py
+++ b/morphlib/sysbranchdir.py
@@ -1,4 +1,4 @@
-# Copyright (C) 2013-2014 Codethink Limited
+# Copyright (C) 2013-2015 Codethink Limited
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
@@ -10,8 +10,7 @@
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
-# with this program; if not, write to the Free Software Foundation, Inc.,
-# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+# with this program. If not, see <http://www.gnu.org/licenses/>.
#
# =*= License: GPL-2 =*=
@@ -72,7 +71,11 @@ class SystemBranchDirectory(object):
def _find_git_directory(self, repo_url):
for gd in self.list_git_directories():
- if gd.get_config('morph.repository') == repo_url:
+ try:
+ gd_repo_url = gd.get_config('morph.repository')
+ except cliapp.AppException: # pragma: no cover
+ continue
+ if gd_repo_url == repo_url:
return gd.dirname
return None
@@ -103,6 +106,11 @@ class SystemBranchDirectory(object):
return os.path.join(self.root_directory, relative)
+ def relative_to_root_repo(self, path): # pragma: no cover
+ gitdirpath = self.get_git_directory_name(self.root_repository_url)
+
+ return os.path.relpath(os.path.abspath(path), gitdirpath)
+
def get_git_directory_name(self, repo_url):
'''Return directory pathname for a given git repository.
@@ -119,6 +127,7 @@ class SystemBranchDirectory(object):
'''
found_repo = self._find_git_directory(repo_url)
+
if not found_repo:
return self._fabricate_git_directory_name(repo_url)
return found_repo