cpython: d1b706e57fbe (original) (raw)
Mercurial > cpython
changeset 95785:d1b706e57fbe
Issue #24031: make patchcheck now supports git checkouts, too. [#24031]
Christian Heimes christian@python.org | |
---|---|
date | Thu, 23 Apr 2015 11:25:41 +0200 |
parents | f60f65507d8e(current diff)0f9c43fb189d(diff) |
children | bd656916586f |
files | Misc/NEWS |
diffstat | 2 files changed, 29 insertions(+), 9 deletions(-)[+] [-] Misc/NEWS 4 Tools/scripts/patchcheck.py 34 |
line wrap: on
line diff
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -41,6 +41,10 @@ Documentation
- Issue #24029: Document the name binding behavior for submodule imports. +Tools/Demos +----------- + +- Issue #24031: make patchcheck now supports git checkouts, too. What's New in Python 3.5.0 alpha 4? ===================================
--- a/Tools/scripts/patchcheck.py +++ b/Tools/scripts/patchcheck.py @@ -49,15 +49,31 @@ def mq_patches_applied(): @status("Getting the list of files that have been added/changed", info=lambda x: n_files_str(len(x))) def changed_files():
- """Get the list of changed or added files from Mercurial."""
- if not os.path.isdir(os.path.join(SRCDIR, '.hg')):
sys.exit('need a checkout to get modified files')[](#l2.9)
- cmd = 'hg status --added --modified --no-status'
- if mq_patches_applied():
cmd += ' --rev qparent'[](#l2.13)
- with subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) as st:
return [x.decode().rstrip() for x in st.stdout][](#l2.15)
- """Get the list of changed or added files from Mercurial or git."""
- if os.path.isdir(os.path.join(SRCDIR, '.hg')):
cmd = 'hg status --added --modified --no-status'[](#l2.18)
if mq_patches_applied():[](#l2.19)
cmd += ' --rev qparent'[](#l2.20)
with subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) as st:[](#l2.21)
return [x.decode().rstrip() for x in st.stdout][](#l2.22)
- elif os.path.isdir(os.path.join(SRCDIR, '.git')):
cmd = 'git status --porcelain'[](#l2.24)
filenames = [][](#l2.25)
with subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) as st:[](#l2.26)
for line in st.stdout:[](#l2.27)
line = line.decode().rstrip()[](#l2.28)
status = set(line[:2])[](#l2.29)
# modified, added or unmerged files[](#l2.30)
if not status.intersection('MAU'):[](#l2.31)
continue[](#l2.32)
filename = line[3:][](#l2.33)
if ' -> ' in filename:[](#l2.34)
# file is renamed[](#l2.35)
filename = filename.split(' -> ', 2)[1].strip()[](#l2.36)
filenames.append(filename)[](#l2.37)
return filenames[](#l2.38)
- else:
sys.exit('need a Mercurial or git checkout to get modified files')[](#l2.40)