File hg-CVE-2016-3069-03-convert_dead_code_removal.patch of Package mercurial.5472

# HG changeset patch
# User Mateusz Kwapich <mitrandir@fb.com>
# Date 1458691511 25200
#      Tue Mar 22 17:05:11 2016 -0700
# Branch stable
# Node ID b732e7f2aba4c4c417278c7c7488006301551855
# Parent  cdda7b96afff3433eafdeeb83ded83a5b25b7a5b
convert: dead code removal - old git calling functions (SEC)

CVE-2016-3069 (3/5)

---
 hgext/convert/git.py |   40 ----------------------------------------
 1 file changed, 40 deletions(-)

--- a/hgext/convert/git.py
+++ b/hgext/convert/git.py
@@ -26,36 +26,6 @@ class submodule(object):
         return "%s %s" % (self.node, self.path)
 
 class convert_git(converter_source, commandline):
-    # Windows does not support GIT_DIR= construct while other systems
-    # cannot remove environment variable. Just assume none have
-    # both issues.
-    if util.safehasattr(os, 'unsetenv'):
-        def gitopen(self, s, err=None):
-            prevgitdir = os.environ.get('GIT_DIR')
-            os.environ['GIT_DIR'] = self.path
-            try:
-                if err == subprocess.PIPE:
-                    (stdin, stdout, stderr) = util.popen3(s)
-                    return stdout
-                elif err == subprocess.STDOUT:
-                    return self.popen_with_stderr(s)
-                else:
-                    return util.popen(s, 'rb')
-            finally:
-                if prevgitdir is None:
-                    del os.environ['GIT_DIR']
-                else:
-                    os.environ['GIT_DIR'] = prevgitdir
-    else:
-        def gitopen(self, s, err=None):
-            if err == subprocess.PIPE:
-                (sin, so, se) = util.popen3('GIT_DIR=%s %s' % (self.path, s))
-                return so
-            elif err == subprocess.STDOUT:
-                    return self.popen_with_stderr(s)
-            else:
-                return util.popen('GIT_DIR=%s %s' % (self.path, s), 'rb')
-
     def _gitcmd(self, cmd, *args, **kwargs):
         return cmd('--git-dir=%s' % self.path, *args, **kwargs)
 
@@ -71,16 +41,6 @@ class convert_git(converter_source, comm
     def gitrunlines(self, *args, **kwargs):
         return self._gitcmd(self.runlines, *args, **kwargs)
 
-    def popen_with_stderr(self, s):
-        p = subprocess.Popen(s, shell=True, bufsize=-1,
-                             close_fds=util.closefds,
-                             stdin=subprocess.PIPE,
-                             stdout=subprocess.PIPE,
-                             stderr=subprocess.STDOUT,
-                             universal_newlines=False,
-                             env=None)
-        return p.stdout
-
     def gitread(self, s):
         fh = self.gitopen(s)
         data = fh.read()