예제 #1
0
def merge_blobs(o_base, o_HEAD, o_other):
    with Temp() as f_base, Temp() as f_HEAD, Temp() as f_other:

        # Write blobs to files
        for oid, f in ((o_base, f_base), (o_HEAD, f_HEAD), (o_other, f_other)):
            if oid:
                f.write(data.get_object(oid))
                f.flush()

        with subprocess.Popen([
                'diff3',
                '-m',
                '-L',
                'HEAD',
                f_HEAD.name,
                '-L',
                'BASE',
                f_base.name,
                '-L',
                'MERGE_HEAD',
                f_other.name,
        ],
                              stdout=subprocess.PIPE) as proc:
            output, _ = proc.communicate()
            assert proc.returncode in (0, 1)

        return output
예제 #2
0
def merge_blobs(o_base, o_HEAD, o_other):
    with Temp() as f_base, Temp() as f_HEAD, Temp() as f_other:

        # Write blobs to files
        for oid, f in ((o_base, f_base), (o_HEAD, f_HEAD), (o_other, f_other)):
            if oid:
                f.write(data.get_object(oid))
                f.flush()

        with subprocess.Popen(
            [
                "diff3",
                "-m",
                "-L",
                "HEAD",
                f_HEAD.name,
                "-L",
                "BASE",
                f_base.name,
                "-L",
                "MERGE_HEAD",
                f_other.name,
            ],
                stdout=subprocess.PIPE,
        ) as proc:
            output, _ = proc.communicate()

        if proc.returncode not in (0, 1):
            raise Exception(
                f"Incorrect proc code from diff3 {proc.returncode}")

        return output
예제 #3
0
def diff_blobs(o_from, o_to, path="blob"):
    with Temp() as f_from, Temp()  as f_to:
        for oid, f in ((o_from, f_from), (o_to, f_to)):
            if oid:
                f.write(data.get_object(oid))
                f.flush()
        with subprocess.Popen(
                ['diff', '--unified', '--show-c-function', '--label', f'a/{path}', f_from.name, '--label', f'b/{path}', f_to.name],
                stdout=subprocess.PIPE) as proc:
            output, _ = proc.communicate()
        return output
예제 #4
0
파일: diff.py 프로젝트: jay51/ugit
def diff_blob(o_from, o_to, path="blob"):
    with Temp() as f_from, Temp() as f_to:
        for oid, f in ((o_from, f_from), (o_to, f_to)):
            if oid:
                f.write(data.get_object(oid))
                f.flush()

        with subprocess.Popen([
            "diff", "--unified", "--show-c-function",
            "--label", f"a/{path}", f_from.name,
            "--label", f"b/{path}", f_to.name],
            # "--label", f".ugit/objects/{o_from}", f_from.name, # also works but
            # "--label", f".ugit/objects/{o_to}", f_to.name],
            stdout=subprocess.PIPE
        ) as proc:
            output, _ = proc.communicate ()
    return output
예제 #5
0
파일: diff.py 프로젝트: jay51/ugit
def merge_blobs(o_base, o_HEAD, o_other):
    with Temp() as f_base, Temp() as f_HEAD, Temp() as f_other:
        # write blobs to temp files
        for oid, f in ((o_base, f_base), (o_HEAD, f_HEAD), (o_other, f_other)):
            if oid:
                f.write(data.get_object(oid))
                f.flush()

        with subprocess.Popen ([
            "diff3", "-m",
            "-L", "HEAD", f_HEAD.name,
            "-L", "BASE", f_base.name,
            "-L", "MERGE_HEAD", f_other.name,
        ], stdout=subprocess.PIPE) as proc:
            output, _ = proc.communicate ()
            assert proc.returncode in (0, 1)

        return output
예제 #6
0
def download_file(url, files):
    """ Downloads a file at url and returns the adds the filename to files
    """

    log.debug('Downloading ' + url)
    with urllib.request.urlopen(url, files) as font:
        with Temp(delete=False, prefix='font' + str(os.getpid())) as temp:
            shutil.copyfileobj(font, temp)
            files.append(temp)