From b7eeeade261047f53deceeb367d697218e19dcc5 Mon Sep 17 00:00:00 2001 From: Catalin Marinas Date: Wed, 28 May 2008 22:02:02 +0100 Subject: [PATCH] Convert "top" to the new infrastructure Signed-off-by: Catalin Marinas --- stgit/commands/top.py | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/stgit/commands/top.py b/stgit/commands/top.py index e7cb275..c8fbba4 100644 --- a/stgit/commands/top.py +++ b/stgit/commands/top.py @@ -16,33 +16,30 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA """ -import sys, os -from optparse import OptionParser, make_option - -from stgit.commands.common import * -from stgit.utils import * -from stgit.out import * -from stgit import stack, git +from optparse import make_option +from stgit.commands import common +from stgit.out import out help = 'print the name of the top patch' usage = """%prog [options] Print the name of the current (topmost) patch.""" -directory = DirectoryHasRepository() +directory = common.DirectoryHasRepositoryLib() options = [make_option('-b', '--branch', help = 'use BRANCH instead of the default one')] - def func(parser, options, args): """Show the name of the topmost patch """ if len(args) != 0: parser.error('incorrect number of arguments') - name = crt_series.get_current() - if name: - out.stdout(name) + stack = directory.repository.get_stack(options.branch) + applied = stack.patchorder.applied + + if applied: + out.stdout(applied[-1]) else: - raise CmdException, 'No patches applied' + raise common.CmdException, 'No patches applied' -- 2.11.0