# HG changeset patch # Parent 9f75f82d623e25e1f58665a781cf6d304b6e40b8 diff --git a/Tools/scripts/patchcheck.py b/Tools/scripts/patchcheck.py --- a/Tools/scripts/patchcheck.py +++ b/Tools/scripts/patchcheck.py @@ -28,20 +28,34 @@ def status(message, modal=False, info=No @status("Getting the list of files that have been added/changed", info=lambda x: "%s files" % len(x)) def changed_files(): - """Run ``svn status`` and return a set of files that have been - changed/added.""" - cmd = 'svn status --quiet --non-interactive --ignore-externals' - svn_st = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) - svn_st.wait() - output = [x.decode().rstrip() for x in svn_st.stdout.readlines()] - files = set() + """Get the list of files that have been changed/added.""" + if os.path.isdir('.hg'): + vcs = 'Mercurial' + elif os.path.isdir('.svn'): + vcs = 'Subversion' + else: + sys.exit("can't get the list of modified files without " + "a svn or hg checkout") + + if vcs == 'Mercurial': + cmd = 'hg status --added --modified --no-status' + else: + cmd = 'svn status --quiet --non-interactive --ignore-externals' + status = subprocess.Popen(cmd.split(' '), stdout=subprocess.PIPE) + status.wait() + output = (x.decode().rstrip() for x in status.stdout) + + if vcs == 'Mercurial': + return list(output) + + files = list() for line in output: - if not line[0] in ('A', 'M'): + if not line.startswith(('A', 'M')): continue line_parts = line.split() path = line_parts[-1] if os.path.isfile(path): - files.add(path) + files.append(path) return files @status("Fixing whitespace", info=lambda x: "%s files" % x)