1
# Copyright (C) 2006-2010 Canonical Ltd
1
# Copyright (C) 2006, 2007 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 check_changed_or_out_of_date(self, strict, opt_name,
262
more_error, more_warning):
263
"""Check the tree for uncommitted changes and branch synchronization.
265
If strict is None and not set in the config files, a warning is issued.
266
If strict is True, an error is raised.
267
If strict is False, no checks are done and no warning is issued.
269
:param strict: True, False or None, searched in branch config if None.
271
:param opt_name: strict option name to search in config file.
273
:param more_error: Details about how to avoid the check.
275
:param more_warning: Details about what is happening.
278
strict = self.branch.get_config().get_user_option_as_bool(opt_name)
279
if strict is not False:
281
if (self.has_changes()):
282
err_class = errors.UncommittedChanges
283
elif self.last_revision() != self.branch.last_revision():
284
# The tree has lost sync with its branch, there is little
285
# chance that the user is aware of it but he can still force
286
# the action with --no-strict
287
err_class = errors.OutOfDateTree
288
if err_class is not None:
290
err = err_class(self, more=more_warning)
291
# We don't want to interrupt the user if he expressed no
292
# preference about strict.
293
trace.warning('%s', err._format())
295
err = err_class(self, more=more_error)
299
261
def last_revision(self):
300
262
"""Return the revision id of the last commit performed in this tree.