58
from bzrlib.trace import mutter, mutter_callsite, warning
58
from bzrlib.trace import (
59
log_exception_quietly, note, mutter, mutter_callsite, warning)
61
62
# Old formats display a warning, but only once
117
119
self._generate_revision_if_needed()
118
120
self.__heads = graph.HeadsCache(repository.get_graph()).heads
122
def _validate_unicode_text(self, text, context):
123
"""Verify things like commit messages don't have bogus characters."""
125
raise ValueError('Invalid value for %s: %r' % (context, text))
127
def _validate_revprops(self, revprops):
128
for key, value in revprops.iteritems():
129
# We know that the XML serializers do not round trip '\r'
130
# correctly, so refuse to accept them
131
if not isinstance(value, basestring):
132
raise ValueError('revision property (%s) is not a valid'
133
' (unicode) string: %r' % (key, value))
134
self._validate_unicode_text(value,
135
'revision property (%s)' % (key,))
120
137
def commit(self, message):
121
138
"""Make the actual commit.
123
140
:return: The revision id of the recorded revision.
142
self._validate_unicode_text(message, 'commit message')
125
143
rev = _mod_revision.Revision(
126
144
timestamp=self._timestamp,
127
145
timezone=self._timezone,
513
531
r'.* revision="(?P<revision_id>[^"]+)"'
516
def abort_write_group(self):
534
def abort_write_group(self, suppress_errors=False):
517
535
"""Commit the contents accrued within the current write group.
537
:param suppress_errors: if true, abort_write_group will catch and log
538
unexpected errors that happen during the abort, rather than
539
allowing them to propagate. Defaults to False.
519
541
:seealso: start_write_group.
521
543
if self._write_group is not self.get_transaction():
522
544
# has an unlock or relock occured ?
523
545
raise errors.BzrError('mismatched lock context and write group.')
524
self._abort_write_group()
547
self._abort_write_group()
548
except Exception, exc:
549
self._write_group = None
550
if not suppress_errors:
552
mutter('abort_write_group failed')
553
log_exception_quietly()
554
note('bzr: ERROR (ignored): %s', exc)
525
555
self._write_group = None
527
557
def _abort_write_group(self):
2806
2836
# fetching from a stacked repository or into a stacked repository
2807
2837
# we use the generic fetch logic which uses the VersionedFiles
2808
2838
# attributes on repository.
2840
# XXX: Andrew suggests removing the check on the target
2809
2842
from bzrlib.fetch import RepoFetcher
2810
2843
fetcher = RepoFetcher(self.target, self.source, revision_id,
2811
2844
pb, find_ghosts)