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
183
183
# avoid circular imports
184
184
from bzrlib import commit
185
187
possible_master_transports=[]
186
revprops = commit.Commit.update_revprops(
189
kwargs.pop('authors', None),
190
kwargs.pop('author', None),
188
if not 'branch-nick' in revprops:
189
revprops['branch-nick'] = self.branch._get_nick(
191
190
kwargs.get('local', False),
192
191
possible_master_transports)
192
authors = kwargs.pop('authors', None)
193
author = kwargs.pop('author', None)
194
if authors is not None:
195
if author is not None:
196
raise AssertionError('Specifying both author and authors '
197
'is not allowed. Specify just authors instead')
198
if 'author' in revprops or 'authors' in revprops:
199
# XXX: maybe we should just accept one of them?
200
raise AssertionError('author property given twice')
202
for individual in authors:
203
if '\n' in individual:
204
raise AssertionError('\\n is not a valid character '
205
'in an author identity')
206
revprops['authors'] = '\n'.join(authors)
207
if author is not None:
208
symbol_versioning.warn('The parameter author was deprecated'
209
' in version 1.13. Use authors instead',
211
if 'author' in revprops or 'authors' in revprops:
212
# XXX: maybe we should just accept one of them?
213
raise AssertionError('author property given twice')
215
raise AssertionError('\\n is not a valid character '
216
'in an author identity')
217
revprops['authors'] = author
193
218
# args for wt.commit start at message from the Commit.commit method,
194
219
args = (message, ) + args
195
220
for hook in MutableTree.hooks['start_commit']:
236
def check_changed_or_out_of_date(self, strict, opt_name,
237
more_error, more_warning):
238
"""Check the tree for uncommitted changes and branch synchronization.
240
If strict is None and not set in the config files, a warning is issued.
241
If strict is True, an error is raised.
242
If strict is False, no checks are done and no warning is issued.
244
:param strict: True, False or None, searched in branch config if None.
246
:param opt_name: strict option name to search in config file.
248
:param more_error: Details about how to avoid the check.
250
:param more_warning: Details about what is happening.
253
strict = self.branch.get_config().get_user_option_as_bool(opt_name)
254
if strict is not False:
256
if (self.has_changes()):
257
err_class = errors.UncommittedChanges
258
elif self.last_revision() != self.branch.last_revision():
259
# The tree has lost sync with its branch, there is little
260
# chance that the user is aware of it but he can still force
261
# the action with --no-strict
262
err_class = errors.OutOfDateTree
263
if err_class is not None:
265
err = err_class(self, more=more_warning)
266
# We don't want to interrupt the user if he expressed no
267
# preference about strict.
268
trace.warning('%s', err._format())
270
err = err_class(self, more=more_error)
274
261
def last_revision(self):
275
262
"""Return the revision id of the last commit performed in this tree.
375
362
This is designed more towards DWIM for humans than API clarity.
376
363
For the specific behaviour see the help for cmd_add().
378
:param file_list: List of zero or more paths. *NB: these are
379
interpreted relative to the process cwd, not relative to the
380
tree.* (Add and most other tree methods use tree-relative
382
365
:param action: A reporter to be called with the inventory, parent_ie,
383
366
path and kind of the path being added. It may return a file_id if
384
367
a specific one should be used.
408
389
user_dirs = set()
409
conflicts_related = set()
410
# Not all mutable trees can have conflicts
411
if getattr(self, 'conflicts', None) is not None:
412
# Collect all related files without checking whether they exist or
413
# are versioned. It's cheaper to do that once for all conflicts
414
# than trying to find the relevant conflict for each added file.
415
for c in self.conflicts():
416
conflicts_related.update(c.associated_filenames())
418
391
# validate user file paths and convert all paths to tree
419
392
# relative : it's cheaper to make a tree relative path an abspath
480
453
if illegalpath_re.search(directory.raw_path):
481
454
trace.warning("skipping %r (contains \\n or \\r)" % abspath)
483
if directory.raw_path in conflicts_related:
484
# If the file looks like one generated for a conflict, don't
487
'skipping %s (generated to help resolve conflicts)',
491
457
if parent_ie is not None:
492
458
versioned = directory.base_path in parent_ie.children