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