1127
1127
# Get the source branch
1128
1128
(tree, br_from,
1129
1129
_unused) = bzrdir.BzrDir.open_containing_tree_or_branch(directory)
1131
strict = br_from.get_config().get_user_option_as_bool('push_strict')
1132
if strict is None: strict = True # default value
1133
1130
# Get the tip's revision_id
1134
1131
revision = _get_one_revision('push', revision)
1135
1132
if revision is not None:
1136
1133
revision_id = revision.in_history(br_from).rev_id
1138
1135
revision_id = None
1139
if strict and tree is not None and revision_id is None:
1140
if (tree.has_changes()):
1141
raise errors.UncommittedChanges(
1142
tree, more='Use --no-strict to force the push.')
1143
if tree.last_revision() != tree.branch.last_revision():
1144
# The tree has lost sync with its branch, there is little
1145
# chance that the user is aware of it but he can still force
1146
# the push with --no-strict
1147
raise errors.OutOfDateTree(
1148
tree, more='Use --no-strict to force the push.')
1136
if tree is not None and revision_id is None:
1137
tree.warn_if_changed_or_out_of_date(
1138
strict, 'push_strict', 'Use --no-strict to force the push.')
1150
1139
# Get the stacked_on branch, if any
1151
1140
if stacked_on is not None:
1152
1141
stacked_on = urlutils.normalize_url(stacked_on)