From 31aff9515f77a0d95140e07ce5f95d6db784e9b9 Mon Sep 17 00:00:00 2001 From: Hans Ulrich Niedermann Date: Tue, 10 Aug 2010 13:13:15 +0200 Subject: Add "fedpkg clone --initial-merge" argument --- src/fedpkg.py | 14 +++++++++++--- src/pyfedpkg/__init__.py | 7 +++++-- src/pyfedpkg/initial_merge.py | 10 ++++++++++ 3 files changed, 26 insertions(+), 5 deletions(-) diff --git a/src/fedpkg.py b/src/fedpkg.py index d50d7dc..5c51061 100755 --- a/src/fedpkg.py +++ b/src/fedpkg.py @@ -417,6 +417,8 @@ def clone(args): pyfedpkg.clone_with_dirs(module, args.user) else: pyfedpkg.clone(module, args.user, args.path, args.branch) + if args.initial_merge: + pyfedpkg.initial_merge.handle_repo(module) except pyfedpkg.FedpkgError, e: log.error('Could not clone: %s' % e) sys.exit(1) @@ -825,9 +827,15 @@ packages will be built sequentially. parser_clone = subparsers.add_parser('clone', help = 'Clone and checkout a module') # Allow an old style clone with subdirs for branches - parser_clone.add_argument('--branches', '-B', - action = 'store_true', - help = 'Do an old style checkout with subdirs for branches') + parser_clone_branches_group = parser_clone.add_mutually_exclusive_group() + parser_clone_branches_group.add_argument( + '--branches', '-B', + action = 'store_true', + help = 'Do an old style checkout with subdirs for branches') + parser_clone_branches_group.add_argument( + '--initial-merge', '-i', + action = 'store_true', + help = 'Run initial-merge on the cloned repo immediately') # provide a convenient way to get to a specific branch parser_clone.add_argument('--branch', '-b', help = 'Check out a specific branch') diff --git a/src/pyfedpkg/__init__.py b/src/pyfedpkg/__init__.py index dbd0878..5d764b8 100644 --- a/src/pyfedpkg/__init__.py +++ b/src/pyfedpkg/__init__.py @@ -28,8 +28,6 @@ import stat import StringIO import OpenSSL -from . import initial_merge - # Define some global variables, put them here to make it easy to change LOOKASIDE = 'http://pkgs.fedoraproject.org/repo/pkgs' @@ -46,6 +44,11 @@ BRANCHFILTER = 'f\d\d\/master|master|el\d\/master|olpc\d\/master' class FedpkgError(Exception): pass + +# This module needs FedpkgError to be defined +from . import initial_merge + + # Setup our logger # Null logger to avoid spurrious messages, add a handler in app code class NullHandler(logging.Handler): diff --git a/src/pyfedpkg/initial_merge.py b/src/pyfedpkg/initial_merge.py index 15d0a6e..12cd865 100755 --- a/src/pyfedpkg/initial_merge.py +++ b/src/pyfedpkg/initial_merge.py @@ -162,7 +162,17 @@ class Filter(object): self.branch_list = [item] +class UnknownRepoTypeError(pyfedpkg.FedpkgError): + pass + + def handle_repo(repo, dry_run=False): + if type(repo) == str: + repo = git.Repo(repo) + elif isinstance(repo, git.Repo): + pass + else: + raise UnknownRepoTypeError("%s" % repo) log.info("######## initial-merge %s ########" % repo.working_tree_dir) _locals, remotes = pyfedpkg._list_branches(repo=repo) aa = [ Branch(repo.git.rev_parse('%s^{tree}' % b), b) for b in remotes ] -- cgit