1
# Copyright (C) 2006, 2007 Canonical Ltd
1
# Copyright (C) 2006-2010 Canonical Ltd
3
3
# This program is free software; you can redistribute it and/or modify
4
4
# it under the terms of the GNU General Public License as published by
261
def warn_if_changed_or_out_of_date(self, strict, opt_name, more_msg):
262
"""Check the tree for uncommitted changes and branch synchronization.
264
If strict is None and not set in the config files, a warning is issued.
265
If strict is True, an error is raised.
266
If strict is False, no checks are done and no warning is issued.
268
:param strict: True, False or None, searched in branch config if None.
270
:param opt_name: strict option name to search in config file.
272
:param more_msg: Details about how to avoid the warnings.
275
strict = self.branch.get_config().get_user_option_as_bool(opt_name)
276
if strict is not False:
278
if (self.has_changes()):
279
err = errors.UncommittedChanges(self, more=more_msg)
280
elif self.last_revision() != self.branch.last_revision():
281
# The tree has lost sync with its branch, there is little
282
# chance that the user is aware of it but he can still force
283
# the action with --no-strict
284
err = errors.OutOfDateTree(self, more=more_msg)
287
# We don't want to interrupt the user if he expressed no
288
# preference about strict.
289
trace.warning('%s', (err._format(),))
261
294
def last_revision(self):
262
295
"""Return the revision id of the last commit performed in this tree.