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
"""Return the branch that may contain uncommitted changes."""
272
master = self.get_master_branch()
273
if master is not None:
278
255
def has_stored_uncommitted(self):
279
256
"""If true, the branch has stored, uncommitted changes in it."""
280
return self._uncommitted_branch()._get_uncommitted() is not None
257
raise NotImplementedError(self.has_stored_uncommitted)
282
259
def store_uncommitted(self, creator, message=None):
283
260
"""Store uncommitted changes from a ShelfCreator.
287
264
:param message: The message to associate with the changes.
288
265
:raises: ChangesAlreadyStored if the branch already has changes.
290
branch = self._uncommitted_branch()
292
branch._put_uncommitted(None)
294
if branch.has_stored_uncommitted():
295
raise errors.ChangesAlreadyStored
296
transform = StringIO()
297
creator.write_shelf(transform, message)
299
branch._put_uncommitted(transform)
267
raise NotImplementedError(self.store_uncommitted)
301
269
def get_unshelver(self, tree):
302
270
"""Return a shelf.Unshelver for this branch and tree.
304
272
:param tree: The tree to use to construct the Unshelver.
305
273
:return: an Unshelver or None if no changes are stored.
307
transform = self._uncommitted_branch()._get_uncommitted()
308
if transform is None:
310
return shelf.Unshelver.from_tree_and_shelf(tree, transform)
275
raise NotImplementedError(self.get_unshelver)
312
277
def _get_fallback_repository(self, url, possible_transports):
313
278
"""Get the repository we fallback to at url."""
2471
2436
self._transport.put_file('stored-transform', transform)
2438
def _uncommitted_branch(self):
2439
"""Return the branch that may contain uncommitted changes."""
2440
master = self.get_master_branch()
2441
if master is not None:
2446
def has_stored_uncommitted(self):
2447
"""If true, the branch has stored, uncommitted changes in it."""
2448
return self._uncommitted_branch()._get_uncommitted() is not None
2450
def store_uncommitted(self, creator, message=None):
2451
"""Store uncommitted changes from a ShelfCreator.
2453
:param creator: The ShelfCreator containing uncommitted changes, or
2454
None to delete any stored changes.
2455
:param message: The message to associate with the changes.
2456
:raises: ChangesAlreadyStored if the branch already has changes.
2458
branch = self._uncommitted_branch()
2460
branch._put_uncommitted(None)
2462
if branch.has_stored_uncommitted():
2463
raise errors.ChangesAlreadyStored
2464
transform = StringIO()
2465
creator.write_shelf(transform, message)
2467
branch._put_uncommitted(transform)
2469
def get_unshelver(self, tree):
2470
"""Return a shelf.Unshelver for this branch and tree.
2472
:param tree: The tree to use to construct the Unshelver.
2473
:return: an Unshelver or None if no changes are stored.
2475
transform = self._uncommitted_branch()._get_uncommitted()
2476
if transform is None:
2478
return shelf.Unshelver.from_tree_and_shelf(tree, transform)
2473
2480
def is_locked(self):
2474
2481
return self.control_files.is_locked()