예제 #1
0
파일: qcommit.py 프로젝트: nwgh/gitq
def do_cleanup_and_empty_series(patchdir, abfile):
    do_cleanup(patchdir, abfile)

    # These are no longer patches, so get them out of the series
    for sha in pgl.config['SERIES']:
        name = pgl.config['NAMES'][sha]
        del pgl.config['NAMES'][sha]
        del pgl.config['SHAS'][name]
    pgl.config['SERIES'] = []
    pgl.config['ACTIVE_PATCH'] = None
    gitq.write_series()
예제 #2
0
def do_cleanup_and_empty_series(patchdir, abfile):
    do_cleanup(patchdir, abfile)

    # These are no longer patches, so get them out of the series
    for sha in pgl.config['SERIES']:
        name = pgl.config['NAMES'][sha]
        del pgl.config['NAMES'][sha]
        del pgl.config['SHAS'][name]
    pgl.config['SERIES'] = []
    pgl.config['ACTIVE_PATCH'] = None
    gitq.write_series()
예제 #3
0
def main():
    ap = argparse.ArgumentParser(description='Create a new patch',
                                 prog='git qnew')
    ap.add_argument('pname', help='Name of patch')
    ap.add_argument('-a',
                    dest='all',
                    help='Add all unstaged changes to patch',
                    action='store_true',
                    default=False)
    ap.add_argument('-m',
                    dest='commitmsg',
                    help='Commit message for patch',
                    default=None)
    # TODO - handle different username/email
    args = ap.parse_args()

    # Make sure we have all the config we need
    gitq.include_config()

    # Make sure our queue directory is setup
    if not os.path.exists(pgl.config['QUEUE_SERIES']):
        if not os.path.exists(pgl.config['BRANCH_QUEUE']):
            if not os.path.exists(pgl.config['QUEUES']):
                os.mkdir(pgl.config['QUEUES'])
            os.mkdir(pgl.config['BRANCH_QUEUE'])
        file(pgl.config['QUEUE_SERIES'], 'w').close()
    if not os.path.exists(pgl.config['UNAPPLIED_PATCHES']):
        file(pgl.config['UNAPPLIED_PATCHES'], 'w').close()
    if not os.path.exists(pgl.config['SHA_NAME_MAP']):
        file(pgl.config['SHA_NAME_MAP'], 'w').close()

    # Make sure we don't already have a patch named like the one we want
    gitq.load_series()

    # Commit outstanding changes
    if not gitq.update_patch(
            commit_all=args.all, commitmsg=args.commitmsg, new=True):
        pgl.die('Nothing to make a new patch from!')

    # Do this again here to figure out the base of our new patch
    gitq.include_config()
    patchbase = pgl.config['HEAD_SHA']

    # Update our stored idea of the patch series on disk
    pgl.config['SERIES'].append(patchbase)
    pgl.config['ACTIVE_PATCH'] = patchbase
    pgl.config['NAMES'][patchbase] = args.pname
    gitq.write_series()

    # Done!
    sys.stdout.write('Started new patch on branch %s\n' %
                     (pgl.config['BRANCH'], ))

    return 0
예제 #4
0
파일: qnew.py 프로젝트: nwgh/gitq
def main():
    ap = argparse.ArgumentParser(description='Create a new patch',
        prog='git qnew')
    ap.add_argument('pname', help='Name of patch')
    ap.add_argument('-a', dest='all', help='Add all unstaged changes to patch',
        action='store_true', default=False)
    ap.add_argument('-m', dest='commitmsg', help='Commit message for patch',
        default=None)
    # TODO - handle different username/email
    args = ap.parse_args()

    # Make sure we have all the config we need
    gitq.include_config()

    # Make sure our queue directory is setup
    if not os.path.exists(pgl.config['QUEUE_SERIES']):
        if not os.path.exists(pgl.config['BRANCH_QUEUE']):
            if not os.path.exists(pgl.config['QUEUES']):
                os.mkdir(pgl.config['QUEUES'])
            os.mkdir(pgl.config['BRANCH_QUEUE'])
        file(pgl.config['QUEUE_SERIES'], 'w').close()
    if not os.path.exists(pgl.config['UNAPPLIED_PATCHES']):
        file(pgl.config['UNAPPLIED_PATCHES'], 'w').close()
    if not os.path.exists(pgl.config['SHA_NAME_MAP']):
        file(pgl.config['SHA_NAME_MAP'], 'w').close()

    # Make sure we don't already have a patch named like the one we want
    gitq.load_series()

    # Commit outstanding changes
    if not gitq.update_patch(commit_all=args.all, commitmsg=args.commitmsg,
                             new=True):
        pgl.die('Nothing to make a new patch from!')

    # Do this again here to figure out the base of our new patch
    gitq.include_config()
    patchbase = pgl.config['HEAD_SHA']

    # Update our stored idea of the patch series on disk
    pgl.config['SERIES'].append(patchbase)
    pgl.config['ACTIVE_PATCH'] = patchbase
    pgl.config['NAMES'][patchbase] = args.pname
    gitq.write_series()

    # Done!
    sys.stdout.write('Started new patch on branch %s\n' %
        (pgl.config['BRANCH'],))

    return 0
예제 #5
0
def main():
    # Make sure we have all the config we need
    gitq.include_config()

    gitq.load_series()

    patchbase = pgl.config['ACTIVE_PATCH']

    if not patchbase:
        pgl.die('No patches for this branch!')

    # Make sure we have no uncommitted changes
    if gitq.repo_has_changes():
        pgl.die('Working copy has uncommitted stages. Either qrefresh or '
                'stash them before continuing.')

    # Write the patch to disk using format-patch
    patchdir = os.path.join(pgl.config['BRANCH_QUEUE'], patchbase)
    os.mkdir(patchdir)
    gfp = subprocess.Popen(['git', 'format-patch', '-o', patchdir,
                            '--no-signature', '-n', '--no-stat',
                            '%s~1' % (patchbase,)],
        stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    if gfp.wait():
        pgl.die('Failed to save patch')

    # Reset our working copy to before the patch
    reset_point = '%s~1' % (patchbase,)
    gitreset = subprocess.Popen(['git', 'reset', '--hard', reset_point],
        stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    if gitreset.wait():
        shutil.rmtree(patchdir)
        pgl.die('Failed to pop patch')

    # Move our now-saved patch into the unapplied list and save new state
    pgl.config['SERIES'] = pgl.config['SERIES'][:-1]
    pgl.config['UNAPPLIED'].append(patchbase)

    gitq.write_series()

    return 0
예제 #6
0
파일: qpush.py 프로젝트: nwgh/gitq
def do_cleanup_and_fix_series(patchdir_ref, patchdir, apply_sha, apply_name):
    """Performs cleanup and re-writing of metadata after a qpush succeeds
    """
    # Remove cache of patchdir
    os.unlink(patchdir_ref)

    # Remove saved patches directory
    shutil.rmtree(patchdir)

    # Put our reapplied patch in the series, and save to disk
    gitq.include_config() # Re-read HEAD sha
    pgl.config['SERIES'].append(pgl.config['HEAD_SHA'])
    pgl.config['UNAPPLIED'].remove(apply_sha)

    # Now that we may (or may not) have a new base sha for this patch,
    # update that info, too
    pgl.config['SHAS'][apply_name] = pgl.config['HEAD_SHA']
    del pgl.config['NAMES'][apply_sha]
    pgl.config['NAMES'][pgl.config['HEAD_SHA']] = apply_name

    gitq.write_series()