Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/subrepo.py @ 49438:b9fcf54030d7
subrepo: avoid opening console window for non-native subrepos on Windows
Prevent annoying command prompt windows popping up when using TortoiseHG with
Git and SVN subrepos by passing creationflags=subprocess.CREATE_NO_WINDOW to
subprocess.Popen.
author | derekbrowncmu@gmail.com |
---|---|
date | Mon, 18 Jul 2022 03:29:53 -0400 |
parents | 093e5c274f54 |
children | bbe3a65bbd96 |
comparison
equal
deleted
inserted
replaced
49437:5baf873ccb6e | 49438:b9fcf54030d7 |
---|---|
1097 # instead of being per-command, but we need to support 1.4 so | 1097 # instead of being per-command, but we need to support 1.4 so |
1098 # we have to be intelligent about what commands take | 1098 # we have to be intelligent about what commands take |
1099 # --non-interactive. | 1099 # --non-interactive. |
1100 if commands[0] in (b'update', b'checkout', b'commit'): | 1100 if commands[0] in (b'update', b'checkout', b'commit'): |
1101 cmd.append(b'--non-interactive') | 1101 cmd.append(b'--non-interactive') |
1102 if util.safehasattr(subprocess, 'CREATE_NO_WINDOW'): | |
1103 # On Windows, prevent command prompts windows from popping up when | |
1104 # running in pythonw. | |
1105 extrakw['creationflags'] = getattr(subprocess, 'CREATE_NO_WINDOW') | |
1102 cmd.extend(commands) | 1106 cmd.extend(commands) |
1103 if filename is not None: | 1107 if filename is not None: |
1104 path = self.wvfs.reljoin( | 1108 path = self.wvfs.reljoin( |
1105 self._ctx.repo().origroot, self._path, filename | 1109 self._ctx.repo().origroot, self._path, filename |
1106 ) | 1110 ) |
1467 errpipe = pycompat.open(os.devnull, b'w') | 1471 errpipe = pycompat.open(os.devnull, b'w') |
1468 if self.ui._colormode and len(commands) and commands[0] == b"diff": | 1472 if self.ui._colormode and len(commands) and commands[0] == b"diff": |
1469 # insert the argument in the front, | 1473 # insert the argument in the front, |
1470 # the end of git diff arguments is used for paths | 1474 # the end of git diff arguments is used for paths |
1471 commands.insert(1, b'--color') | 1475 commands.insert(1, b'--color') |
1476 extrakw = {} | |
1477 if util.safehasattr(subprocess, 'CREATE_NO_WINDOW'): | |
1478 # On Windows, prevent command prompts windows from popping up when | |
1479 # running in pythonw. | |
1480 extrakw['creationflags'] = getattr(subprocess, 'CREATE_NO_WINDOW') | |
1472 p = subprocess.Popen( | 1481 p = subprocess.Popen( |
1473 pycompat.rapply( | 1482 pycompat.rapply( |
1474 procutil.tonativestr, [self._gitexecutable] + commands | 1483 procutil.tonativestr, [self._gitexecutable] + commands |
1475 ), | 1484 ), |
1476 bufsize=-1, | 1485 bufsize=-1, |
1477 cwd=pycompat.rapply(procutil.tonativestr, cwd), | 1486 cwd=pycompat.rapply(procutil.tonativestr, cwd), |
1478 env=procutil.tonativeenv(env), | 1487 env=procutil.tonativeenv(env), |
1479 close_fds=procutil.closefds, | 1488 close_fds=procutil.closefds, |
1480 stdout=subprocess.PIPE, | 1489 stdout=subprocess.PIPE, |
1481 stderr=errpipe, | 1490 stderr=errpipe, |
1491 **extrakw | |
1482 ) | 1492 ) |
1483 if stream: | 1493 if stream: |
1484 return p.stdout, None | 1494 return p.stdout, None |
1485 | 1495 |
1486 retdata = p.stdout.read().strip() | 1496 retdata = p.stdout.read().strip() |