From 1f6cd0c1cebee497f7fa17c98cf3c08d60b9225b Mon Sep 17 00:00:00 2001 From: Alexey Izbyshev Date: Sat, 9 Dec 2017 04:41:00 +0300 Subject: [PATCH 1/3] bpo-32256: Make patchcheck.py work for out-of-tree builds Set SRCDIR as the current directory for git and hg. --- Tools/scripts/patchcheck.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/Tools/scripts/patchcheck.py b/Tools/scripts/patchcheck.py index 8f7924fe934601..bdb70b502fed76 100755 --- a/Tools/scripts/patchcheck.py +++ b/Tools/scripts/patchcheck.py @@ -49,7 +49,8 @@ def mq_patches_applied(): cmd = 'hg qapplied' with subprocess.Popen(cmd.split(), stdout=subprocess.PIPE, - stderr=subprocess.PIPE) as st: + stderr=subprocess.PIPE, + cwd=SRCDIR) as st: bstdout, _ = st.communicate() return st.returncode == 0 and bstdout @@ -58,7 +59,9 @@ def get_git_branch(): """Get the symbolic name for the current git branch""" cmd = "git rev-parse --abbrev-ref HEAD".split() try: - return subprocess.check_output(cmd, stderr=subprocess.DEVNULL) + return subprocess.check_output(cmd, + stderr=subprocess.DEVNULL, + cwd=SRCDIR) except subprocess.CalledProcessError: return None @@ -70,7 +73,9 @@ def get_git_upstream_remote(): """ cmd = "git remote get-url upstream".split() try: - subprocess.check_output(cmd, stderr=subprocess.DEVNULL) + subprocess.check_output(cmd, + stderr=subprocess.DEVNULL, + cwd=SRCDIR) except subprocess.CalledProcessError: return "origin" return "upstream" @@ -105,7 +110,9 @@ def changed_files(base_branch=None): cmd = 'hg status --added --modified --no-status' if mq_patches_applied(): cmd += ' --rev qparent' - with subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) as st: + with subprocess.Popen(cmd.split(), + stdout=subprocess.PIPE, + cwd=SRCDIR) as st: filenames = [x.decode().rstrip() for x in st.stdout] elif os.path.exists(os.path.join(SRCDIR, '.git')): # We just use an existence check here as: @@ -116,7 +123,9 @@ def changed_files(base_branch=None): else: cmd = 'git status --porcelain' filenames = [] - with subprocess.Popen(cmd.split(), stdout=subprocess.PIPE) as st: + with subprocess.Popen(cmd.split(), + stdout=subprocess.PIPE, + cwd=SRCDIR) as st: for line in st.stdout: line = line.decode().rstrip() status_text, filename = line.split(maxsplit=1) From 03b88632c8651d7573b28cc91a707a0af89da2e0 Mon Sep 17 00:00:00 2001 From: Alexey Izbyshev Date: Wed, 28 Feb 2018 13:18:07 +0300 Subject: [PATCH 2/3] Add NEWS entry --- Misc/NEWS.d/next/Build/2018-02-28-13-17-36.bpo-32256.cT-jhI.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Build/2018-02-28-13-17-36.bpo-32256.cT-jhI.rst diff --git a/Misc/NEWS.d/next/Build/2018-02-28-13-17-36.bpo-32256.cT-jhI.rst b/Misc/NEWS.d/next/Build/2018-02-28-13-17-36.bpo-32256.cT-jhI.rst new file mode 100644 index 00000000000000..4df9e2a46e0b72 --- /dev/null +++ b/Misc/NEWS.d/next/Build/2018-02-28-13-17-36.bpo-32256.cT-jhI.rst @@ -0,0 +1 @@ +Make patchcheck.py work for out-of-tree builds. From 210bc9681d42ac42f591847c74fb230fc935fa80 Mon Sep 17 00:00:00 2001 From: Berker Peksag Date: Fri, 24 Aug 2018 21:08:50 +0300 Subject: [PATCH 3/3] Delete 2018-02-28-13-17-36.bpo-32256.cT-jhI.rst --- Misc/NEWS.d/next/Build/2018-02-28-13-17-36.bpo-32256.cT-jhI.rst | 1 - 1 file changed, 1 deletion(-) delete mode 100644 Misc/NEWS.d/next/Build/2018-02-28-13-17-36.bpo-32256.cT-jhI.rst diff --git a/Misc/NEWS.d/next/Build/2018-02-28-13-17-36.bpo-32256.cT-jhI.rst b/Misc/NEWS.d/next/Build/2018-02-28-13-17-36.bpo-32256.cT-jhI.rst deleted file mode 100644 index 4df9e2a46e0b72..00000000000000 --- a/Misc/NEWS.d/next/Build/2018-02-28-13-17-36.bpo-32256.cT-jhI.rst +++ /dev/null @@ -1 +0,0 @@ -Make patchcheck.py work for out-of-tree builds.