From 26b2ed80839c521a6b79fafda008220918ac05b5 Mon Sep 17 00:00:00 2001 From: Jesse Keating Date: Fri, 23 Jul 2010 18:07:28 -0700 Subject: Rework how we deal with branches Create a new list_branches function to discover the local and remote branches. Allow creating a new branch if the requested local branch doesn't already exist. --- src/fedpkg.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'src/fedpkg.py') diff --git a/src/fedpkg.py b/src/fedpkg.py index bf3c517..f9db3c1 100755 --- a/src/fedpkg.py +++ b/src/fedpkg.py @@ -586,16 +586,25 @@ def srpm(args): sys.exit(1) def switch_branch(args): + try: + mymodule = pyfedpkg.PackageModule(args.path) + except pyfedpkg.FedpkgError, e: + log.error('Could not init the module') + sys.exit(1) if args.branch: try: - pyfedpkg.switch_branch(args.branch) + mymodule.switch_branch(args.branch) except pyfedpkg.FedpkgError, e: - log.debug('Unable to switch to another branch: %s' % e) + log.error('Unable to switch to another branch: %s' % e) + sys.exit(1) else: try: - pyfedpkg.switch_branch(list=1) + (locals, remotes) = mymodule.list_branches() except pyfedpkg.FedpkgError, e: - log.debug('Unable to list branches: %s' % e) + log.error('Unable to list branches: %s' % e) + sys.exit(1) + print('Locals:\n %s\nRemotes:\n %s' % + ('\n '.join(locals), '\n '.join(remotes))) def tagrequest(args): # not implimented @@ -874,7 +883,8 @@ packages will be built sequentially. # switch branches parser_switchbranch = subparsers.add_parser('switch-branch', help = 'Work with branches') - parser_switchbranch.add_argument('branch', nargs = '?') + parser_switchbranch.add_argument('branch', nargs = '?', + help = 'Switch to or create branch') parser_switchbranch.add_argument('-l', '--list', help = 'List both remote-tracking branches and local branches', action = 'store_true') -- cgit