diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-09-07 19:27:40 +0100 |
---|---|---|
committer | Jannis Pohlmann <jannis.pohlmann@codethink.co.uk> | 2012-09-10 12:57:15 +0000 |
commit | 5986caa568d9d8649dcd1a7015306235f1f0781d (patch) | |
tree | 1329e52ba3963e81696b922cae089a666517b591 | |
parent | 941adb363e4e0d548c9507e6a48d98990c692260 (diff) | |
download | morph-5986caa568d9d8649dcd1a7015306235f1f0781d.tar.gz |
Reorder branch & merge utility functions to top of the class
-rw-r--r-- | morphlib/plugins/branch_and_merge_plugin.py | 80 |
1 files changed, 40 insertions, 40 deletions
diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py index a3681909..5e5ce0c1 100644 --- a/morphlib/plugins/branch_and_merge_plugin.py +++ b/morphlib/plugins/branch_and_merge_plugin.py @@ -115,6 +115,22 @@ class BranchAndMergePlugin(cliapp.Plugin): raise cliapp.AppException("Can't find the system branch directory") + def find_repository(self, branch_dir, repo): + for dirname in self.walk_special_directories(branch_dir, + special_subdir='.git'): + original_repo = self.get_repo_config(dirname, 'morph.repository') + if repo == original_repo: + return dirname + return None + + def find_system_branch(self, workspace, branch_name): + for dirname in self.walk_special_directories( + workspace, special_subdir='.morph-system-branch'): + branch = self.get_branch_config(dirname, 'branch.name') + if branch_name == branch: + return dirname + return None + def set_branch_config(self, branch_dir, option, value): filename = os.path.join(branch_dir, '.morph-system-branch', 'config') self.app.runcmd(['git', 'config', '-f', filename, option, value]) @@ -131,6 +147,30 @@ class BranchAndMergePlugin(cliapp.Plugin): value = self.app.runcmd(['git', 'config', option], cwd=repo_dir) return value.strip() + def get_uncommitted_changes(self, repo_dir, env={}): + status = self.app.runcmd(['git', 'status', '--porcelain'], + cwd=repo_dir, env=env) + changes = [] + for change in status.strip().splitlines(): + xy, paths = change.strip().split(' ', 1) + if xy != '??': + changes.append(paths.split()[0]) + return changes + + def resolve_ref(self, repodir, ref): + try: + return self.app.runcmd(['git', 'show-ref', ref], + cwd=repodir).split()[0] + except: + return None + + def resolve_reponame(self, reponame): + '''Return the full pull URL of a reponame.''' + + resolver = morphlib.repoaliasresolver.RepoAliasResolver( + self.app.settings['repo-alias']) + return resolver.pull_url(reponame) + def clone_to_directory(self, dirname, reponame, ref): '''Clone a repository below a directory. @@ -175,13 +215,6 @@ class BranchAndMergePlugin(cliapp.Plugin): self.app.runcmd(['git', 'remote', 'update'], cwd=dirname) - def resolve_reponame(self, reponame): - '''Return the full pull URL of a reponame.''' - - resolver = morphlib.repoaliasresolver.RepoAliasResolver( - self.app.settings['repo-alias']) - return resolver.pull_url(reponame) - def load_morphology(self, repo_dir, name, ref=None): if ref is None: filename = os.path.join(repo_dir, '%s.morph' % name) @@ -297,22 +330,6 @@ class BranchAndMergePlugin(cliapp.Plugin): if max_subdirs > 0 and len(subdirs) > max_subdirs: break - def find_repository(self, branch_dir, repo): - for dirname in self.walk_special_directories(branch_dir, - special_subdir='.git'): - original_repo = self.get_repo_config(dirname, 'morph.repository') - if repo == original_repo: - return dirname - return None - - def find_system_branch(self, workspace, branch_name): - for dirname in self.walk_special_directories( - workspace, special_subdir='.morph-system-branch'): - branch = self.get_branch_config(dirname, 'branch.name') - if branch_name == branch: - return dirname - return None - def petrify(self, args): '''Make refs to chunks be absolute SHA-1s.''' @@ -774,23 +791,6 @@ class BranchAndMergePlugin(cliapp.Plugin): for info in morphology['chunks']: inject_build_ref(info) - def resolve_ref(self, repodir, ref): - try: - return self.app.runcmd(['git', 'show-ref', ref], - cwd=repodir).split()[0] - except: - return None - - def get_uncommitted_changes(self, repo_dir, env={}): - status = self.app.runcmd(['git', 'status', '--porcelain'], - cwd=repo_dir, env=env) - changes = [] - for change in status.strip().splitlines(): - xy, paths = change.strip().split(' ', 1) - if xy != '??': - changes.append(paths.split()[0]) - return changes - def generate_build_ref_names(self, build_repos, branch_uuid): for repo, info in build_repos.iteritems(): repo_dir = info['dirname'] |