Created
September 15, 2015 08:23
-
-
Save banterCZ/72a6ea4e6ed1fd41ae74 to your computer and use it in GitHub Desktop.
A Mercurial extension used to with features branches
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""commands for working with feature branches | |
feature_branches is a Mercurial extension used to with features branches.""" | |
from mercurial import util, commands, merge | |
def close_feature(ui, repo, node, **opts): | |
"""Close a feature branch (e.g. fb-123) and merge it to default.""" | |
branch = "fb-" + node | |
close_branch(branch, ui, repo, node, **opts) | |
def close_bug(ui, repo, node, **opts): | |
"""Close a feature branch (e.g. bb-666) and merge it to default.""" | |
branch = "bb-" + node | |
close_branch(branch, ui, repo, node, **opts) | |
def close_branch(branch, ui, repo, node, **opts): | |
try: | |
commands.update(ui, repo, rev=branch) | |
except Exception, e: | |
raise util.Abort('The branch %s does NOT exist!' % branch) | |
commands.commit(ui, repo=repo, message='Close branch %s.' % branch, close_branch=True) | |
commands.update(ui, repo, rev='default') | |
merge.update(repo, node=branch, branchmerge=True, force=False, partial=False) | |
commands.commit(ui, repo=repo, message='Merge branch %s -> default.' % branch) | |
cmdtable = { | |
"close-feature": (close_feature, [], "hg close-feature 123"), | |
"close-bug": (close_bug, [], "hg close-bug 666") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment