611 self._ctx = ctx |
611 self._ctx = ctx |
612 self._relpath = path |
612 self._relpath = path |
613 self._path = ctx._repo.wjoin(path) |
613 self._path = ctx._repo.wjoin(path) |
614 self._ui = ctx._repo.ui |
614 self._ui = ctx._repo.ui |
615 |
615 |
616 def _gitcommand(self, commands, stream=False): |
616 def _gitcommand(self, commands, env=None, stream=False): |
617 return self._gitdir(commands, stream=stream)[0] |
617 return self._gitdir(commands, env=env, stream=stream)[0] |
618 |
618 |
619 def _gitdir(self, commands, stream=False): |
619 def _gitdir(self, commands, env=None, stream=False): |
620 commands = ['--no-pager'] + commands |
620 commands = ['--no-pager'] + commands |
621 return self._gitnodir(commands, stream=stream, cwd=self._path) |
621 return self._gitnodir(commands, env=env, stream=stream, cwd=self._path) |
622 |
622 |
623 def _gitnodir(self, commands, stream=False, cwd=None): |
623 def _gitnodir(self, commands, env=None, stream=False, cwd=None): |
624 """Calls the git command |
624 """Calls the git command |
625 |
625 |
626 The methods tries to call the git command. versions previor to 1.6.0 |
626 The methods tries to call the git command. versions previor to 1.6.0 |
627 are not supported and very probably fail. |
627 are not supported and very probably fail. |
628 """ |
628 """ |
629 cmd = ['git'] + commands |
629 cmd = ['git'] + commands |
630 cmd = [util.shellquote(arg) for arg in cmd] |
630 cmd = [util.shellquote(arg) for arg in cmd] |
631 cmd = util.quotecommand(' '.join(cmd)) |
631 cmd = util.quotecommand(' '.join(cmd)) |
632 |
632 |
633 # print git's stderr, which is mostly progress and useful info |
633 # print git's stderr, which is mostly progress and useful info |
634 p = subprocess.Popen(cmd, shell=True, bufsize=-1, cwd=cwd, |
634 p = subprocess.Popen(cmd, shell=True, bufsize=-1, cwd=cwd, env=env, |
635 close_fds=util.closefds, |
635 close_fds=util.closefds, |
636 stdout=subprocess.PIPE) |
636 stdout=subprocess.PIPE) |
637 if stream: |
637 if stream: |
638 return p.stdout, None |
638 return p.stdout, None |
639 |
639 |
787 # a real merge would be required, just checkout the revision |
787 # a real merge would be required, just checkout the revision |
788 rawcheckout() |
788 rawcheckout() |
789 |
789 |
790 def commit(self, text, user, date): |
790 def commit(self, text, user, date): |
791 cmd = ['commit', '-a', '-m', text] |
791 cmd = ['commit', '-a', '-m', text] |
|
792 env = os.environ.copy() |
792 if user: |
793 if user: |
793 cmd += ['--author', user] |
794 cmd += ['--author', user] |
794 if date: |
795 if date: |
795 # git's date parser silently ignores when seconds < 1e9 |
796 # git's date parser silently ignores when seconds < 1e9 |
796 # convert to ISO8601 |
797 # convert to ISO8601 |
797 cmd += ['--date', util.datestr(date, '%Y-%m-%dT%H:%M:%S %1%2')] |
798 env['GIT_AUTHOR_DATE'] = util.datestr(date, |
798 self._gitcommand(cmd) |
799 '%Y-%m-%dT%H:%M:%S %1%2') |
|
800 self._gitcommand(cmd, env=env) |
799 # make sure commit works otherwise HEAD might not exist under certain |
801 # make sure commit works otherwise HEAD might not exist under certain |
800 # circumstances |
802 # circumstances |
801 return self._gitstate() |
803 return self._gitstate() |
802 |
804 |
803 def merge(self, state): |
805 def merge(self, state): |