diff options
Diffstat (limited to 'src/pyfedpkg/initial_merge.py')
-rwxr-xr-x | src/pyfedpkg/initial_merge.py | 42 |
1 files changed, 40 insertions, 2 deletions
diff --git a/src/pyfedpkg/initial_merge.py b/src/pyfedpkg/initial_merge.py index 8a3cf6d..5782740 100755 --- a/src/pyfedpkg/initial_merge.py +++ b/src/pyfedpkg/initial_merge.py @@ -16,6 +16,7 @@ via subprocess.Popen, as fedpkg has a bunch of issues with changing CWD. """ +import argparse import sys import os import subprocess @@ -159,8 +160,8 @@ def handle_path(path=None): if not path: path = os.getcwd() oldcwd = os.getcwd() - os.chdir(d) - print "########", "Entering", d, "########" + os.chdir(path) + print "########", "Entering", path, "########" handle_curdir() print "Leaving", os.getcwd() os.chdir(oldcwd) @@ -174,5 +175,42 @@ def main(args): handle_curdir() +class Action(argparse.Action): + + def __init__(self, *args, **kwargs): + super(Action, self).__init__(*args, **kwargs) + self.default_value = ['.'] + + def __call__(self, parser, namespace, values, option_string=None): + print "initial_merge.Action(", self, \ + ", parser=", parser, \ + ", namespace=", namespace, \ + ", values=", values, \ + ", option_string=", option_string + if values: + setattr(namespace, self.dest, values) + else: + setattr(namespace, self.dest, self.default) + + +def fedpkg_command(args): + print repr(args) + print args + print repr(args.__dict__) + for repo in args.repos: + handle_path(repo) + + +def get_parser(subparsers): + sp = subparsers.add_parser('initial-merge', + help = 'Do initial-git merge joining branches with identical trees') + sp.add_argument('repos', metavar='repo-path', + nargs='*', default=['.'], + action=Action, + help = 'The directories with the repos to initial-merge') + sp.set_defaults(command = fedpkg_command) + return sp + + if __name__ == '__main__': main(sys.argv[1:]) |