~gz/bzr/resolve_dir_removal_auto_344013

« back to all changes in this revision

Viewing changes to bzrlib/workingtree.py

  • Committer: Patch Queue Manager
  • Date: 2012-07-23 17:56:45 UTC
  • mfrom: (6538.1.34 branch-store)
  • Revision ID: pqm@pqm.ubuntu.com-20120723175645-92crzj8j7bfnuglm
(abentley) switch --store stores uncommitted changes in branch (Aaron
 Bentley)

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
    revision as _mod_revision,
61
61
    revisiontree,
62
62
    rio as _mod_rio,
 
63
    shelf,
63
64
    transform,
64
65
    transport,
65
66
    ui,
1351
1352
                basis_tree.unlock()
1352
1353
        return conflicts
1353
1354
 
 
1355
    @needs_write_lock
 
1356
    def store_uncommitted(self):
 
1357
        """Store uncommitted changes from the tree in the branch."""
 
1358
        target_tree = self.basis_tree()
 
1359
        shelf_creator = shelf.ShelfCreator(self, target_tree)
 
1360
        try:
 
1361
            if not shelf_creator.shelve_all():
 
1362
                return
 
1363
            self.branch.store_uncommitted(shelf_creator)
 
1364
            shelf_creator.transform()
 
1365
        finally:
 
1366
            shelf_creator.finalize()
 
1367
        note('Uncommitted changes stored in branch "%s".', self.branch.nick)
 
1368
 
 
1369
    @needs_write_lock
 
1370
    def restore_uncommitted(self):
 
1371
        """Restore uncommitted changes from the branch into the tree."""
 
1372
        unshelver = self.branch.get_unshelver(self)
 
1373
        if unshelver is None:
 
1374
            return
 
1375
        try:
 
1376
            merger = unshelver.make_merger()
 
1377
            merger.ignore_zero = True
 
1378
            merger.do_merge()
 
1379
            self.branch.store_uncommitted(None)
 
1380
        finally:
 
1381
            unshelver.finalize()
 
1382
 
1354
1383
    def revision_tree(self, revision_id):
1355
1384
        """See Tree.revision_tree.
1356
1385