diff options
author | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-03-26 14:24:17 +0100 |
---|---|---|
committer | Lars Wirzenius <lars.wirzenius@codethink.co.uk> | 2012-03-26 14:24:17 +0100 |
commit | f171b6b27ac8d3bb7235d409cb2510516cf66b8f (patch) | |
tree | fcd28f1e80330f410a2660748455bbdff0db2d6f /morph | |
parent | 40a62a1a3057d0ff24d69a3bc33c041ac0df8129 (diff) | |
download | morph-f171b6b27ac8d3bb7235d409cb2510516cf66b8f.tar.gz |
Fix "morph checkout" and system branch deduction
Checkout now does "git remote update" so the local branch gets the
remote branches. This will spend a bit more time, but it's needed for
"morph edit foo" to work when there's an existing "foo" branch in
origin.
System branches are no longer deduced from the currently checked
out branch name of the current git repository, since that doesn't
work when "morph edit" checks out an existing branch. Instead,
we deduce it from the current working directory name (relative to
the mine directory).
Diffstat (limited to 'morph')
-rwxr-xr-x | morph | 20 |
1 files changed, 15 insertions, 5 deletions
@@ -412,6 +412,9 @@ class Morph(cliapp.Application): # Set the origin to point at the original repository. morphlib.git.set_remote(dirname, 'origin', treeish.original_repo) + + # Update remotes. + self.runcmd(['git', 'remote', 'update'], cwd=dirname) def cmd_branch(self, args): '''Branch the whole system.''' @@ -453,11 +456,18 @@ class Morph(cliapp.Application): self._clone_to_directory(new_repo, repo, system_branch) def _deduce_system_branch(self): - out = self.runcmd(['git', 'branch']) - for line in out.splitlines(): - if line.startswith('* '): - return line.strip()[2:] - return None + minedir = self._deduce_mine_directory() + if minedir is None: + return None + + if not minedir.endswith('/'): + minedir += '/' + + cwd = os.getcwd() + if not cwd.startswith(minedir): + return None + + return os.path.dirname(cwd[len(minedir):]) def cmd_show_system_branch(self, args): '''Print name of current system branch. |