Commits

Anonymous committed a084e11

Add --list option to the shelve command

  • Participants
  • Parent commits 297d13f

Comments (0)

Files changed (1)

     if not ui.interactive:
         raise util.Abort(_('shelve can only be run interactively'))
 
+    # List all the active shelves by name and return '
+    if opts['list']:
+        listshelves(ui,repo)
+        return
+
     forced = opts['force'] or opts['append']
     
     # Shelf name and path
     fancyopts.fancyopts([], commands.commitopts, opts)
     return cmdutil.commit(ui, repo, shelvefunc, pats, opts)
 
-
+def listshelves(ui,repo):
+    # Check for shelve file at old location first
+    if os.path.isfile(repo.join('shelve')):
+        ui.status('default\n')
+    
+    # Now go through all the files in the shelves folder and list them out
+    dirname = repo.join('shelves')
+    if os.path.isdir(dirname):
+        for filename in os.listdir(repo.join('shelves')):
+            ui.status(filename + '\n')
+    
 def unshelve(ui, repo, *pats, **opts):
     '''restore shelved changes'''
 
 
     # List all the active shelves by name and return '
     if opts['list']:
-        # Check for shelve file at old location first
-        if os.path.isfile(repo.join('shelve')):
-            ui.status('default\n')
-        
-        # Now go through all the files in the shelves folder and list them out
-        dirname = repo.join('shelves')
-        if os.path.isdir(dirname):
-            for filename in os.listdir(repo.join('shelves')):
-                ui.status(filename + '\n')
+        listshelves(ui,repo)
         return
         
     try:
            _('shelve all changes')),
           ('n', 'name', '',
            _('shelve changes to specified shelf name')),
+           ('l', 'list', None, _('list active shelves')),
          ] + commands.walkopts,
          _('hg shelve [OPTION]... [FILE]...')),
     "unshelve":