/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to breezy/workingtree.py

  • Committer: Jelmer Vernooij
  • Date: 2017-09-10 02:23:30 UTC
  • mfrom: (6772.3.3 supports-shelving)
  • Revision ID: jelmer@jelmer.uk-20170910022330-j51cdokj3hx5r3y5
Merge lp:~jelmer/brz/supports-shelving.

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
    generate_ids,
53
53
    merge,
54
54
    revision as _mod_revision,
55
 
    shelf,
56
55
    transform,
57
56
    transport,
58
57
    ui,
76
75
 
77
76
class SettingFileIdUnsupported(errors.BzrError):
78
77
 
79
 
    _fmt = "This format does not support setting file ids."""
 
78
    _fmt = "This format does not support setting file ids."
 
79
 
 
80
 
 
81
class ShelvingUnsupported(errors.BzrError):
 
82
 
 
83
    _fmt = "This format does not support shelving changes."
80
84
 
81
85
 
82
86
class TreeEntry(object):
1151
1155
 
1152
1156
    def store_uncommitted(self):
1153
1157
        """Store uncommitted changes from the tree in the branch."""
1154
 
        with self.lock_write():
1155
 
            target_tree = self.basis_tree()
1156
 
            shelf_creator = shelf.ShelfCreator(self, target_tree)
1157
 
            try:
1158
 
                if not shelf_creator.shelve_all():
1159
 
                    return
1160
 
                self.branch.store_uncommitted(shelf_creator)
1161
 
                shelf_creator.transform()
1162
 
            finally:
1163
 
                shelf_creator.finalize()
1164
 
            note('Uncommitted changes stored in branch "%s".', self.branch.nick)
 
1158
        raise NotImplementedError(self.store_uncommitted)
1165
1159
 
1166
1160
    def restore_uncommitted(self):
1167
1161
        """Restore uncommitted changes from the branch into the tree."""
1168
 
        with self.lock_write():
1169
 
            unshelver = self.branch.get_unshelver(self)
1170
 
            if unshelver is None:
1171
 
                return
1172
 
            try:
1173
 
                merger = unshelver.make_merger()
1174
 
                merger.ignore_zero = True
1175
 
                merger.do_merge()
1176
 
                self.branch.store_uncommitted(None)
1177
 
            finally:
1178
 
                unshelver.finalize()
 
1162
        raise NotImplementedError(self.restore_uncommitted)
1179
1163
 
1180
1164
    def revision_tree(self, revision_id):
1181
1165
        """See Tree.revision_tree.
1559
1543
 
1560
1544
    def get_shelf_manager(self):
1561
1545
        """Return the ShelfManager for this WorkingTree."""
1562
 
        from .shelf import ShelfManager
1563
 
        return ShelfManager(self, self._transport)
 
1546
        raise NotImplementedError(self.get_shelf_manager)
1564
1547
 
1565
1548
 
1566
1549
class WorkingTreeFormatRegistry(controldir.ControlComponentFormatRegistry):
1626
1609
    supports_setting_file_ids = True
1627
1610
    """If this format allows setting the file id."""
1628
1611
 
 
1612
    supports_store_uncommitted = True
 
1613
    """If this format supports shelve-like functionality."""
 
1614
 
1629
1615
    def initialize(self, controldir, revision_id=None, from_branch=None,
1630
1616
                   accelerator_tree=None, hardlink=False):
1631
1617
        """Initialize a new working tree in controldir.