diff options
author | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-09-03 14:16:44 +0100 |
---|---|---|
committer | Sam Thursfield <sam.thursfield@codethink.co.uk> | 2012-09-03 14:16:44 +0100 |
commit | d415901bc394c64752b54089427b7b0b5638ca2a (patch) | |
tree | 8a619f706b951000f9c525bfd7824b796ce247c8 | |
parent | af2ad500d2cfab8969de95f09d5c3be42b5ce252 (diff) | |
parent | 6935a3db514f1552c2ffd4d24b6521bb185dcd73 (diff) | |
download | morph-d415901bc394c64752b54089427b7b0b5638ca2a.tar.gz |
Merge branch 'jannis/git-config-for-branch-options'
7 files changed, 32 insertions, 28 deletions
diff --git a/morphlib/plugins/branch_and_merge_plugin.py b/morphlib/plugins/branch_and_merge_plugin.py index abadf8da..84bedd36 100644 --- a/morphlib/plugins/branch_and_merge_plugin.py +++ b/morphlib/plugins/branch_and_merge_plugin.py @@ -107,12 +107,16 @@ class BranchAndMergePlugin(cliapp.Plugin): with open(filename, 'w') as f: f.write('%s\n' % repo) - @staticmethod - def read_branch_root(branch_dir): - filename = os.path.join(branch_dir, '.morph-system-branch', - 'branch-root') - with open(filename, 'r') as f: - return f.read().strip() + 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, + 'branch.%s' % option, '%s' % value]) + + def get_branch_config(self, branch_dir, option): + filename = os.path.join(branch_dir, '.morph-system-branch', 'config') + value = self.app.runcmd(['git', 'config', '-f', filename, + 'branch.%s' % option]) + return value.strip() @staticmethod def clone_to_directory(app, dirname, reponame, ref): @@ -280,7 +284,7 @@ class BranchAndMergePlugin(cliapp.Plugin): os.mkdir(os.path.join(branch_dir, '.morph-system-branch')) # Remember the repository we branched off from. - self.write_branch_root(branch_dir, repo) + self.set_branch_config(branch_dir, 'branch-root', repo) # Clone into system branch directory. repo_dir = os.path.join(branch_dir, self.convert_uri_to_path(repo)) @@ -326,7 +330,7 @@ class BranchAndMergePlugin(cliapp.Plugin): os.mkdir(os.path.join(branch_dir, '.morph-system-branch')) # Remember the repository we branched off from. - self.write_branch_root(branch_dir, repo) + self.set_branch_config(branch_dir, 'branch-root', repo) # Clone into system branch directory. repo_dir = os.path.join(branch_dir, self.convert_uri_to_path(repo)) @@ -343,7 +347,7 @@ class BranchAndMergePlugin(cliapp.Plugin): workspace = self.deduce_workspace() system_branch = self.deduce_system_branch() branch_dir = os.path.join(workspace, system_branch) - branch_root = self.read_branch_root(branch_dir) + branch_root = self.get_branch_config(branch_dir, 'branch-root') self.app.output.write('%s\n' % branch_root) def merge(self, args): @@ -378,7 +382,7 @@ class BranchAndMergePlugin(cliapp.Plugin): # Find out which repository we branched off from. branch_dir = os.path.join(workspace, system_branch) - branch_root = self.read_branch_root(branch_dir) + branch_root = self.get_branch_config(branch_dir, 'branch-root') # Convert it to a local directory in the branch. branch_root_path = self.convert_uri_to_path(branch_root) diff --git a/tests.branching/branch-creates-new-system-branch-not-from-master.stdout b/tests.branching/branch-creates-new-system-branch-not-from-master.stdout index d68a6342..443f325b 100644 --- a/tests.branching/branch-creates-new-system-branch-not-from-master.stdout +++ b/tests.branching/branch-creates-new-system-branch-not-from-master.stdout @@ -9,7 +9,7 @@ d ./newbranch d ./newbranch/.morph-system-branch d ./newbranch/baserock:morphs d ./newbranch/baserock:morphs/.git -f ./newbranch/.morph-system-branch/branch-root +f ./newbranch/.morph-system-branch/config f ./newbranch/baserock:morphs/hello-stratum.morph f ./newbranch/baserock:morphs/hello-system.morph f ./newbranch/baserock:morphs/this.is.alfred diff --git a/tests.branching/branch-creates-new-system-branch.stdout b/tests.branching/branch-creates-new-system-branch.stdout index 3f2dba1d..e79e8588 100644 --- a/tests.branching/branch-creates-new-system-branch.stdout +++ b/tests.branching/branch-creates-new-system-branch.stdout @@ -9,7 +9,7 @@ d ./newbranch d ./newbranch/.morph-system-branch d ./newbranch/baserock:morphs d ./newbranch/baserock:morphs/.git -f ./newbranch/.morph-system-branch/branch-root +f ./newbranch/.morph-system-branch/config f ./newbranch/baserock:morphs/hello-stratum.morph f ./newbranch/baserock:morphs/hello-system.morph Current branches: diff --git a/tests.branching/branch-works-anywhere.stdout b/tests.branching/branch-works-anywhere.stdout index cddc2d76..ec22698f 100644 --- a/tests.branching/branch-works-anywhere.stdout +++ b/tests.branching/branch-works-anywhere.stdout @@ -9,7 +9,7 @@ d ./branch1 d ./branch1/.morph-system-branch d ./branch1/baserock:morphs d ./branch1/baserock:morphs/.git -f ./branch1/.morph-system-branch/branch-root +f ./branch1/.morph-system-branch/config f ./branch1/baserock:morphs/hello-stratum.morph f ./branch1/baserock:morphs/hello-system.morph Workspace after creating the second branch: @@ -27,10 +27,10 @@ d ./branch2 d ./branch2/.morph-system-branch d ./branch2/baserock:morphs d ./branch2/baserock:morphs/.git -f ./branch1/.morph-system-branch/branch-root +f ./branch1/.morph-system-branch/config f ./branch1/baserock:morphs/hello-stratum.morph f ./branch1/baserock:morphs/hello-system.morph -f ./branch2/.morph-system-branch/branch-root +f ./branch2/.morph-system-branch/config f ./branch2/baserock:morphs/hello-stratum.morph f ./branch2/baserock:morphs/hello-system.morph Workspace after creating the third branch: @@ -52,13 +52,13 @@ d ./branch3 d ./branch3/.morph-system-branch d ./branch3/baserock:morphs d ./branch3/baserock:morphs/.git -f ./branch1/.morph-system-branch/branch-root +f ./branch1/.morph-system-branch/config f ./branch1/baserock:morphs/hello-stratum.morph f ./branch1/baserock:morphs/hello-system.morph -f ./branch2/.morph-system-branch/branch-root +f ./branch2/.morph-system-branch/config f ./branch2/baserock:morphs/hello-stratum.morph f ./branch2/baserock:morphs/hello-system.morph -f ./branch3/.morph-system-branch/branch-root +f ./branch3/.morph-system-branch/config f ./branch3/baserock:morphs/hello-stratum.morph f ./branch3/baserock:morphs/hello-system.morph Workspace after creating the fourth branch: @@ -84,15 +84,15 @@ d ./branch4 d ./branch4/.morph-system-branch d ./branch4/baserock:morphs d ./branch4/baserock:morphs/.git -f ./branch1/.morph-system-branch/branch-root +f ./branch1/.morph-system-branch/config f ./branch1/baserock:morphs/hello-stratum.morph f ./branch1/baserock:morphs/hello-system.morph -f ./branch2/.morph-system-branch/branch-root +f ./branch2/.morph-system-branch/config f ./branch2/baserock:morphs/hello-stratum.morph f ./branch2/baserock:morphs/hello-system.morph -f ./branch3/.morph-system-branch/branch-root +f ./branch3/.morph-system-branch/config f ./branch3/baserock:morphs/hello-stratum.morph f ./branch3/baserock:morphs/hello-system.morph -f ./branch4/.morph-system-branch/branch-root +f ./branch4/.morph-system-branch/config f ./branch4/baserock:morphs/hello-stratum.morph f ./branch4/baserock:morphs/hello-system.morph diff --git a/tests.branching/checkout-existing-branch.stdout b/tests.branching/checkout-existing-branch.stdout index 1af2900c..4a8a614b 100644 --- a/tests.branching/checkout-existing-branch.stdout +++ b/tests.branching/checkout-existing-branch.stdout @@ -9,7 +9,7 @@ d ./master d ./master/.morph-system-branch d ./master/baserock:morphs d ./master/baserock:morphs/.git -f ./master/.morph-system-branch/branch-root +f ./master/.morph-system-branch/config f ./master/baserock:morphs/hello-stratum.morph f ./master/baserock:morphs/hello-system.morph Current branches: diff --git a/tests.branching/checkout-non-aliased-repos.stdout b/tests.branching/checkout-non-aliased-repos.stdout index 872d74aa..dbaa3e5c 100644 --- a/tests.branching/checkout-non-aliased-repos.stdout +++ b/tests.branching/checkout-non-aliased-repos.stdout @@ -12,7 +12,7 @@ d ./master/TEMP_DIR d ./master/DATADIR d ./master/DATADIR/morphs d ./master/DATADIR/morphs/.git -f ./master/.morph-system-branch/branch-root +f ./master/.morph-system-branch/config f ./master/DATADIR/morphs/hello-stratum.morph f ./master/DATADIR/morphs/hello-system.morph Current branches of repo with suffix: @@ -31,7 +31,7 @@ d ./master/TEMP_DIR d ./master/DATADIR d ./master/DATADIR/morphs d ./master/DATADIR/morphs/.git -f ./master/.morph-system-branch/branch-root +f ./master/.morph-system-branch/config f ./master/DATADIR/morphs/hello-stratum.morph f ./master/DATADIR/morphs/hello-system.morph Current branches of repo without suffix: diff --git a/tests.branching/checkout-works-anywhere.stdout b/tests.branching/checkout-works-anywhere.stdout index 0cd18b85..bb4cc1fa 100644 --- a/tests.branching/checkout-works-anywhere.stdout +++ b/tests.branching/checkout-works-anywhere.stdout @@ -9,7 +9,7 @@ d ./master d ./master/.morph-system-branch d ./master/baserock:morphs d ./master/baserock:morphs/.git -f ./master/.morph-system-branch/branch-root +f ./master/.morph-system-branch/config f ./master/baserock:morphs/hello-stratum.morph f ./master/baserock:morphs/hello-system.morph Workspace after checking out master from within a new branch: @@ -27,9 +27,9 @@ d ./newbranch d ./newbranch/.morph-system-branch d ./newbranch/baserock:morphs d ./newbranch/baserock:morphs/.git -f ./master/.morph-system-branch/branch-root +f ./master/.morph-system-branch/config f ./master/baserock:morphs/hello-stratum.morph f ./master/baserock:morphs/hello-system.morph -f ./newbranch/.morph-system-branch/branch-root +f ./newbranch/.morph-system-branch/config f ./newbranch/baserock:morphs/hello-stratum.morph f ./newbranch/baserock:morphs/hello-system.morph |