|
109 | 109 | )
|
110 | 110 |
|
111 | 111 | # Semi-standard module versioning.
|
112 |
| -__version__ = '0.31' |
| 112 | +__version__ = '0.32' |
113 | 113 |
|
114 | 114 | USER_CONFIG_FILE = os.path.expanduser('~/.vcs-repo-mgr.ini')
|
115 | 115 | """The absolute pathname of the user-specific configuration file (a string)."""
|
|
136 | 136 | loaded_repositories = {}
|
137 | 137 |
|
138 | 138 |
|
| 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 | + |
139 | 156 | def coerce_repository(value):
|
140 | 157 | """
|
141 | 158 | 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):
|
968 | 985 | the feature branch starts (a string or
|
969 | 986 | :data:`None`, defaults to
|
970 | 987 | :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()`). |
974 | 990 | :param delete: :data:`True` (the default) to delete or close the
|
975 | 991 | feature branch after it is merged, :data:`False`
|
976 | 992 | otherwise.
|
@@ -998,7 +1014,7 @@ def merge_up(self, target_branch=None, feature_branch=None, delete=True):
|
998 | 1014 | if not target_branch:
|
999 | 1015 | raise TypeError("You need to specify the target branch! (where merging starts)")
|
1000 | 1016 | # 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 |
1002 | 1018 | # Make sure we start with a clean working tree.
|
1003 | 1019 | self.ensure_clean()
|
1004 | 1020 | # Make sure we're up to date with our upstream repository (if any).
|
|
0 commit comments