diff options
-rw-r--r-- | doc/branching-merging-systems.mdwn | 5 | ||||
-rwxr-xr-x | morph | 17 | ||||
-rwxr-xr-x | tests.branching/merge-explicitly-named-repos.script | 48 | ||||
-rw-r--r-- | tests.branching/merge-explicitly-named-repos.stdout | 1 |
4 files changed, 69 insertions, 2 deletions
diff --git a/doc/branching-merging-systems.mdwn b/doc/branching-merging-systems.mdwn index 6fe4d590..3e781b5a 100644 --- a/doc/branching-merging-systems.mdwn +++ b/doc/branching-merging-systems.mdwn @@ -295,8 +295,9 @@ Usage: morph merge BRANCH -This needs to be run inside a system branch directory, and `BRANCH` -must be another system branch checked out in the morph mine. +This needs to be run inside a system branch directory's `morphs` +repository, and `BRANCH` must be another system branch checked out +in the morph mine. * In each git repository modified by the `BRANCH` system branch, run `git merge --no-commit BRANCH`, then undo any changes to @@ -469,7 +469,24 @@ class Morph(cliapp.Application): self._clone_to_directory(new_repo, repo, ref) self.runcmd(['git', 'checkout', '-b', system_branch, ref], cwd=new_repo) + + def cmd_merge(self, args): + '''Merge specified repositories from another system branch.''' + + if len(args) == 0: + raise cliapp.AppException('morph merge must get a branch name ' + 'and some repo names as arguments') + + other_branch = args[0] + mine = self._deduce_mine_directory() + this_branch = self._deduce_system_branch() + for repo in args[1:]: + basename = os.path.basename(repo) + pull_from = os.path.join(mine, other_branch, basename) + repo_dir = os.path.join(mine, this_branch, basename) + self.runcmd(['git', 'pull', pull_from], cwd=repo_dir) + def msg(self, msg): '''Show a message to the user about what is going on.''' logging.debug(msg) diff --git a/tests.branching/merge-explicitly-named-repos.script b/tests.branching/merge-explicitly-named-repos.script new file mode 100755 index 00000000..de6ecebc --- /dev/null +++ b/tests.branching/merge-explicitly-named-repos.script @@ -0,0 +1,48 @@ +#!/bin/sh +# Copyright (C) 2012 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 +# the Free Software Foundation; version 2 of the License. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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. + + +# Check that "morph merge" merges explicitly named repositories. + + +set -eu + + +# Create system branch. +cd "$DATADIR/mine" +"$SRCDIR/scripts/test-morph" init +"$SRCDIR/scripts/test-morph" branch newbranch + +# Make a change to a chunk. +cd newbranch/morphs +"$SRCDIR/scripts/test-morph" edit hello master +cd ../hello +touch newfile.txt +git add newfile.txt +git commit -m foo --quiet + +# Merge changes to a new system branch. +cd "$DATADIR/mine" +"$SRCDIR/scripts/test-morph" branch otherbranch +cd otherbranch/morphs +"$SRCDIR/scripts/test-morph" edit hello master +"$SRCDIR/scripts/test-morph" merge newbranch hello + +# Check results. +cd ../hello +git status --short # make sure all changes are committed +ls newfile.txt # make sure the new file is there + diff --git a/tests.branching/merge-explicitly-named-repos.stdout b/tests.branching/merge-explicitly-named-repos.stdout new file mode 100644 index 00000000..cd2122c4 --- /dev/null +++ b/tests.branching/merge-explicitly-named-repos.stdout @@ -0,0 +1 @@ +newfile.txt |