def main():

    parser = ArgParser(usage)
    parser.add_argument(
        "module_name", type=str, default="", help="name of module to checkout")
    args = parser.parse_args()

#    if len(args) != 1: >>> argparse can't run if args not given <<<
#        parser.error("Incorrect number of arguments.")
    module = args.module
    
    # import svn client
    from dls_environment.svn import svnClient
    svn = svnClient()

    if args.area == "ioc":
        assert len(module.split('/')) > 1, 'Missing Technical Area under Beamline'

    vendor = gitf.vendorModule(module, args.area)
    vendor_current = os.path.join(vendor, "current")
    svn.setLogMessage('Searching vendor module branch for last import to "current"')

    for node in svn.ls(vendor):
        tt = os.path.join(vendor, os.path.basename(node['name']))

        if os.path.basename(node['name']) != "current":
            diffs = svn.diff('/tmp', vendor_current,
                             svn.Revision(svn.opt_revision_kind.head),
                             tt, svn.Revision(svn.opt_revision_kind.head),
                             True, True, True)
            if not diffs:
                print os.path.basename(node['name'])
                break
def main():

    parser = make_parser()
    args = parser.parse_args()

#    if len(args)!=3:
#        parser.error("Incorrect number of arguments.")

    # setup the environment
    module = args.module_name
    release_number = args.release
    branch_name = args.branch_name
    
    # import svn client
    from dls_environment.svn import svnClient    
    svn = svnClient()
    svn.setLogMessage(module + ": creating bugfix branch " + branch_name)
    
    # setup area
    if args.area == "ioc":
        assert len(module.split('/')) > 1, "Missing Technical Area under Beamline"
    release = os.path.join(gitf.prodModule(module, args.area), release_number)
    branch = os.path.join(gitf.branchModule(module, args.area), branch_name)

    # Check for existence of release in svn, non-existence of branch in svn and current directory
    assert svn.pathcheck(release), 'Repository does not contain "' + release + '"'
    assert not svn.pathcheck(branch), 'Repository already contains "' + branch + '"'
    assert not os.path.isdir(branch.split("/")[-1]), \
        branch.split("/")[-1] + " already exists in this directory. " \
                                "Please choose another name or move elsewhere."

    # Make the module in branch directory if it doesn't exist
    if not svn.pathcheck(gitf.branchModule(module, args.area)):
        svn.mkdir(gitf.branchModule(module, args.area))

    svn.copy(release, branch)
    print 'Created bugfix branch from ' + module + ': ' + \
          release_number + " in " + branch
    
    svn.checkout(branch, branch_name)
    print 'Checked out to ./' + branch_name