~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/builtins.py

  • Committer: Aaron Bentley
  • Date: 2008-12-03 05:31:27 UTC
  • mto: This revision was merged to the branch mainline in revision 3893.
  • Revision ID: aaron@aaronbentley.com-20081203053127-vozu5rmsixaadw0v
Change ls-shelf to shelve --list

Show diffs side-by-side

added added

removed removed

Lines of Context:
4738
4738
    ie. out of the way, until a later time when you can bring them back from
4739
4739
    the shelf with the 'unshelve' command.
4740
4740
 
 
4741
    If shelve --list is specified, previously-shelved changes are listed.
 
4742
 
4741
4743
    Shelve is intended to help separate several sets of changes that have
4742
4744
    been inappropriately mingled.  If you just want to get rid of all changes
4743
4745
    and you don't need to restore them later, use revert.  If you want to
4760
4762
        'message',
4761
4763
        RegistryOption('writer', 'Method to use for writing diffs.',
4762
4764
                       bzrlib.option.diff_writer_registry,
4763
 
                       value_switches=True, enum_switch=False)
 
4765
                       value_switches=True, enum_switch=False),
 
4766
 
 
4767
        Option('list', help='list shelved changes.'),
4764
4768
    ]
4765
4769
    _see_also = ['unshelve', 'ls-shelf']
4766
4770
 
4767
4771
    def run(self, revision=None, all=False, file_list=None, message=None,
4768
 
            writer=None):
 
4772
            writer=None, list=False):
 
4773
        if list:
 
4774
            return self.run_for_list()
4769
4775
        from bzrlib.shelf_ui import Shelver
4770
4776
        if writer is None:
4771
4777
            writer = bzrlib.option.diff_writer_registry.get()
4775
4781
        except errors.UserAbort:
4776
4782
            return 0
4777
4783
 
 
4784
    def run_for_list(self):
 
4785
        tree = WorkingTree.open('.')
 
4786
        tree.lock_read()
 
4787
        try:
 
4788
            manager = tree.get_shelf_manager()
 
4789
            shelves = manager.active_shelves()
 
4790
            if len(shelves) == 0:
 
4791
                note('No shelved changes.')
 
4792
                return 0
 
4793
            for shelf_id in reversed(shelves):
 
4794
                message = manager.get_metadata(shelf_id).get('message')
 
4795
                if message is None:
 
4796
                    message = '<no message>'
 
4797
                self.outf.write('%3d: %s\n' % (shelf_id, message))
 
4798
            return 1
 
4799
        finally:
 
4800
            tree.unlock()
 
4801
 
4778
4802
 
4779
4803
class cmd_unshelve(Command):
4780
4804
    """Restore shelved changes.
4801
4825
        Unshelver.from_args(shelf_id, action).run()
4802
4826
 
4803
4827
 
4804
 
class cmd_ls_shelf(Command):
4805
 
    """List shelved changes."""
4806
 
 
4807
 
    _see_also = ['shelve', 'unshelve']
4808
 
 
4809
 
    def run(self):
4810
 
        tree = WorkingTree.open('.')
4811
 
        tree.lock_read()
4812
 
        try:
4813
 
            manager = tree.get_shelf_manager()
4814
 
            shelves = manager.active_shelves()
4815
 
            if len(shelves) == 0:
4816
 
                note('No shelved changes.')
4817
 
                return 0
4818
 
            for shelf_id in reversed(shelves):
4819
 
                message = manager.get_metadata(shelf_id).get('message')
4820
 
                if message is None:
4821
 
                    message = '<no message>'
4822
 
                self.outf.write('%3d: %s\n' % (shelf_id, message))
4823
 
            return 1
4824
 
        finally:
4825
 
            tree.unlock()
4826
 
 
4827
 
 
4828
4828
def _create_prefix(cur_transport):
4829
4829
    needed = [cur_transport]
4830
4830
    # Recurse upwards until we can create a directory successfully