1
# Copyright (C) 2006, 2007 Canonical Ltd
1
# Copyright (C) 2006-2011 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
184
184
# avoid circular imports
185
185
from bzrlib import commit
188
186
possible_master_transports=[]
189
if not 'branch-nick' in revprops:
190
revprops['branch-nick'] = self.branch._get_nick(
187
revprops = commit.Commit.update_revprops(
190
kwargs.pop('authors', None),
191
kwargs.pop('author', None),
191
192
kwargs.get('local', False),
192
193
possible_master_transports)
193
authors = kwargs.pop('authors', None)
194
author = kwargs.pop('author', None)
195
if authors is not None:
196
if author is not None:
197
raise AssertionError('Specifying both author and authors '
198
'is not allowed. Specify just authors instead')
199
if 'author' in revprops or 'authors' in revprops:
200
# XXX: maybe we should just accept one of them?
201
raise AssertionError('author property given twice')
203
for individual in authors:
204
if '\n' in individual:
205
raise AssertionError('\\n is not a valid character '
206
'in an author identity')
207
revprops['authors'] = '\n'.join(authors)
208
if author is not None:
209
symbol_versioning.warn('The parameter author was deprecated'
210
' in version 1.13. Use authors instead',
212
if 'author' in revprops or 'authors' in revprops:
213
# XXX: maybe we should just accept one of them?
214
raise AssertionError('author property given twice')
216
raise AssertionError('\\n is not a valid character '
217
'in an author identity')
218
revprops['authors'] = author
219
194
# args for wt.commit start at message from the Commit.commit method,
220
195
args = (message, ) + args
221
196
for hook in MutableTree.hooks['start_commit']:
237
def check_changed_or_out_of_date(self, strict, opt_name,
238
more_error, more_warning):
239
"""Check the tree for uncommitted changes and branch synchronization.
241
If strict is None and not set in the config files, a warning is issued.
242
If strict is True, an error is raised.
243
If strict is False, no checks are done and no warning is issued.
245
:param strict: True, False or None, searched in branch config if None.
247
:param opt_name: strict option name to search in config file.
249
:param more_error: Details about how to avoid the check.
251
:param more_warning: Details about what is happening.
254
strict = self.branch.get_config().get_user_option_as_bool(opt_name)
255
if strict is not False:
257
if (self.has_changes()):
258
err_class = errors.UncommittedChanges
259
elif self.last_revision() != self.branch.last_revision():
260
# The tree has lost sync with its branch, there is little
261
# chance that the user is aware of it but he can still force
262
# the action with --no-strict
263
err_class = errors.OutOfDateTree
264
if err_class is not None:
266
err = err_class(self, more=more_warning)
267
# We don't want to interrupt the user if he expressed no
268
# preference about strict.
269
trace.warning('%s', err._format())
271
err = err_class(self, more=more_error)
262
275
def last_revision(self):
263
276
"""Return the revision id of the last commit performed in this tree.
394
409
user_dirs = set()
410
conflicts_related = set()
411
# Not all mutable trees can have conflicts
412
if getattr(self, 'conflicts', None) is not None:
413
# Collect all related files without checking whether they exist or
414
# are versioned. It's cheaper to do that once for all conflicts
415
# than trying to find the relevant conflict for each added file.
416
for c in self.conflicts():
417
conflicts_related.update(c.associated_filenames())
396
419
# expand any symlinks in the directory part, while leaving the
464
487
if illegalpath_re.search(directory.raw_path):
465
488
trace.warning("skipping %r (contains \\n or \\r)" % abspath)
490
if directory.raw_path in conflicts_related:
491
# If the file looks like one generated for a conflict, don't
494
'skipping %s (generated to help resolve conflicts)',
468
498
if parent_ie is not None:
469
499
versioned = directory.base_path in parent_ie.children
519
549
this_ie = inv[this_id]
550
# Same as in _add_one below, if the inventory doesn't
551
# think this is a directory, update the inventory
552
if this_ie.kind != 'directory':
553
this_ie = inventory.make_entry('directory',
554
this_ie.name, this_ie.parent_id, this_id)
521
558
for subf in sorted(os.listdir(abspath)):
522
559
# here we could use TreeDirectory rather than