Movatterモバイル変換


[0]ホーム

URL:


Skip to content
Search Gists
Sign in Sign up

Instantly share code, notes, and snippets.

@upsuper
CreatedAugust 3, 2018 04:23
    • Star(0)You must be signed in to star a gist
    • Fork(0)You must be signed in to fork a gist
    Save upsuper/dd630d3835f93476d86b7293f8ee2584 to your computer and use it in GitHub Desktop.
    A filter script of `hg transplant` for coordinated landing for Stylo development
    #!/usr/bin/env python
    # - * - coding: UTF-8 - * -
    importsys
    fromsubprocessimportPopen,PIPE
    SERVO_PATH=r'c:\\mozilla-source\\servo'
    msg=sys.argv[1]
    patch=sys.argv[2]
    patch_for_gecko= []
    patch_for_servo= []
    withopen(patch,'rb')asf:
    in_servo_change=False
    forlineinf:
    ifline.startswith('diff --git a/servo/'):
    in_servo_change=True
    elifline.startswith('diff --git a/'):
    in_servo_change=False
    ifin_servo_change:
    patch_for_servo.append(line)
    else:
    patch_for_gecko.append(line)
    defrun_command(cmd,input=None):
    ifinputisNone:
    p=Popen(cmd)
    else:
    p=Popen(cmd,stdin=PIPE)
    input(p.stdin)
    p.stdin.close()
    p.wait()
    ifp.returncode!=0:
    raiseRuntimeError("Fail to execute {}".format(cmd))
    ifpatch_for_servo:
    withopen(patch,'wb')asf:
    f.write(''.join(patch_for_gecko))
    withopen(msg,'rb')asf:
    forlineinf:
    ifnotline.startswith('#'):
    msg=line
    break
    msg=msg.split()
    whileTrue:
    last_part=msg.pop()
    ifnot (last_part.startswith('r?')orlast_part.startswith('r=')):
    msg.append(last_part)
    break
    defwrite_patch(stdin):
    forlineinpatch_for_servo:
    stdin.write(line)
    run_command(['patch','-p2','-d',SERVO_PATH],write_patch)
    run_command(['git','-C',SERVO_PATH,'add','-A'])
    run_command(['git','-C',SERVO_PATH,'commit','-am',' '.join(msg)])
    Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

    [8]ページ先頭

    ©2009-2025 Movatter.jp