253
253
raise NotImplementedError(self._get_config)
255
def _get_uncommitted(self):
256
"""Return a serialized TreeTransform for uncommitted changes.
258
:return: a file-like object containing a serialized TreeTransform or
259
None if no uncommitted changes are stored.
261
raise NotImplementedError(self._get_uncommitted)
263
def _put_uncommitted(self, transform):
264
"""Store a serialized TreeTransform for uncommitted changes.
266
:param input: a file-like object.
268
raise NotImplementedError(self._put_uncommitted)
270
def _uncommitted_branch(self):
271
master = self.get_master_branch()
272
if master is not None:
277
def has_stored_uncommitted(self):
278
"""If true, the branch has stored, uncommitted changes in it."""
279
return self._uncommitted_branch()._get_uncommitted() is not None
255
281
def store_uncommitted(self, creator, message=None):
256
"""Store uncommitted changes from a ShelfCreator.
258
:param creator: The ShelfCreator containing uncommitted changes, or
259
None to delete any stored changes.
260
:param message: The message to associate with the changes.
261
:raises: ChangesAlreadyStored if the branch already has changes.
263
raise NotImplementedError(self.store_uncommitted)
282
branch = self._uncommitted_branch()
283
if branch.has_stored_uncommitted():
284
raise errors.ChangesAlreadyStored
285
transform = StringIO()
286
creator.write_shelf(transform, message)
288
branch._put_uncommitted(transform)
265
290
def get_unshelver(self, tree):
266
"""Return a shelf.Unshelver for this branch and tree.
268
:param tree: The tree to use to construct the Unshelver.
269
:return: an Unshelver or None if no changes are stored.
271
raise NotImplementedError(self.get_unshelver)
291
transform = self._uncommitted_branch()._get_uncommitted()
292
if transform is None:
294
return shelf.Unshelver.from_tree_and_shelf(tree, transform)
273
296
def _get_fallback_repository(self, url, possible_transports):
274
297
"""Get the repository we fallback to at url."""
2405
2428
self.conf_store = _mod_config.BranchStore(self)
2406
2429
return self.conf_store
2408
def _uncommitted_branch(self):
2409
"""Return the branch that may contain uncommitted changes."""
2410
master = self.get_master_branch()
2411
if master is not None:
2416
def store_uncommitted(self, creator, message=None):
2417
"""Store uncommitted changes from a ShelfCreator.
2419
:param creator: The ShelfCreator containing uncommitted changes, or
2420
None to delete any stored changes.
2421
:param message: The message to associate with the changes.
2422
:raises: ChangesAlreadyStored if the branch already has changes.
2424
branch = self._uncommitted_branch()
2426
branch._transport.delete('stored-transform')
2428
if branch._transport.has('stored-transform'):
2429
raise errors.ChangesAlreadyStored
2430
transform = StringIO()
2431
creator.write_shelf(transform, message)
2433
branch._transport.put_file('stored-transform', transform)
2435
def get_unshelver(self, tree):
2436
"""Return a shelf.Unshelver for this branch and tree.
2438
:param tree: The tree to use to construct the Unshelver.
2439
:return: an Unshelver or None if no changes are stored.
2441
branch = self._uncommitted_branch()
2431
def _get_uncommitted(self):
2432
"""Return a serialized TreeTransform for uncommitted changes.
2434
:return: a file-like object containing a serialized TreeTransform or
2435
None if no uncommitted changes are stored.
2443
transform = branch._transport.get('stored-transform')
2438
return self._transport.get('stored-transform')
2444
2439
except errors.NoSuchFile:
2446
return shelf.Unshelver.from_tree_and_shelf(tree, transform)
2442
def _put_uncommitted(self, transform):
2443
"""Store a serialized TreeTransform for uncommitted changes.
2445
:param input: a file-like object.
2447
if transform is None:
2449
self._transport.delete('stored-transform')
2450
except errors.NoSuchFile:
2453
self._transport.put_file('stored-transform', transform)
2448
2455
def is_locked(self):
2449
2456
return self.control_files.is_locked()