Skip to content

Commit 93787b6

Browse files
committed
Enable feature branch customization for merge_up()
1 parent dc900bc commit 93787b6

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

vcs_repo_mgr/__init__.py

+21-5
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109
)
110110

111111
# Semi-standard module versioning.
112-
__version__ = '0.31'
112+
__version__ = '0.32'
113113

114114
USER_CONFIG_FILE = os.path.expanduser('~/.vcs-repo-mgr.ini')
115115
"""The absolute pathname of the user-specific configuration file (a string)."""
@@ -136,6 +136,23 @@
136136
loaded_repositories = {}
137137

138138

139+
def coerce_feature_branch(value):
140+
"""
141+
Convert a string to a :class:`FeatureBranchSpec` object.
142+
143+
:param value: A string or :class:`FeatureBranchSpec` object.
144+
:returns: A :class:`FeatureBranchSpec` object.
145+
"""
146+
# Repository objects pass through untouched.
147+
if isinstance(value, FeatureBranchSpec):
148+
return value
149+
# We expect a string with a name or URL.
150+
if not isinstance(value, string_types):
151+
msg = "Expected string or FeatureBranchSpec object as argument, got %s instead!"
152+
raise ValueError(msg % type(value))
153+
return FeatureBranchSpec(value)
154+
155+
139156
def coerce_repository(value):
140157
"""
141158
Convert a string (taken to be a repository name or location) to a :class:`Repository` object.
@@ -968,9 +985,8 @@ def merge_up(self, target_branch=None, feature_branch=None, delete=True):
968985
the feature branch starts (a string or
969986
:data:`None`, defaults to
970987
:attr:`current_branch`).
971-
:param feature_branch: The feature branch to merge in (a string or
972-
:data:`None`). Strings are parsed using
973-
:class:`FeatureBranchSpec`.
988+
:param feature_branch: The feature branch to merge in (any value
989+
accepted by :func:`coerce_feature_branch()`).
974990
:param delete: :data:`True` (the default) to delete or close the
975991
feature branch after it is merged, :data:`False`
976992
otherwise.
@@ -998,7 +1014,7 @@ def merge_up(self, target_branch=None, feature_branch=None, delete=True):
9981014
if not target_branch:
9991015
raise TypeError("You need to specify the target branch! (where merging starts)")
10001016
# Parse the feature branch specification.
1001-
feature_branch = FeatureBranchSpec(feature_branch) if feature_branch else None
1017+
feature_branch = coerce_feature_branch(feature_branch) if feature_branch else None
10021018
# Make sure we start with a clean working tree.
10031019
self.ensure_clean()
10041020
# Make sure we're up to date with our upstream repository (if any).

0 commit comments

Comments
 (0)