def push(self, committer=None, author=None, message=None): """Create a new stash. Args: committer: Optional committer name to use author: Optional author name to use message: Optional commit message """ # First, create the index commit. commit_kwargs = {} if committer is not None: commit_kwargs['committer'] = committer if author is not None: commit_kwargs['author'] = author index = self._repo.open_index() index_tree_id = index.commit(self._repo.object_store) index_commit_id = self._repo.do_commit( ref=None, tree=index_tree_id, message=b"Index stash", merge_heads=[self._repo.head()], **commit_kwargs) # Then, the working tree one. stash_tree_id = commit_tree( self._repo.object_store, iter_fresh_objects( index, self._repo.path, object_store=self._repo.object_store)) if message is None: message = b"A stash on " + self._repo.head() # TODO(jelmer): Just pass parents into do_commit()? self._repo.refs[self._ref] = self._repo.head() cid = self._repo.do_commit( ref=self._ref, tree=stash_tree_id, message=message, merge_heads=[index_commit_id], **commit_kwargs) return cid
def push(self, committer=None, author=None, message=None): """Create a new stash. :param committer: Optional committer name to use :param author: Optional author name to use :param message: Optional commit message """ # First, create the index commit. commit_kwargs = {} if committer is not None: commit_kwargs['committer'] = committer if author is not None: commit_kwargs['author'] = author index = self._repo.open_index() index_tree_id = index.commit(self._repo.object_store) index_commit_id = self._repo.do_commit( ref=None, tree=index_tree_id, message=b"Index stash", merge_heads=[self._repo.head()], **commit_kwargs) # Then, the working tree one. stash_tree_id = commit_tree( self._repo.object_store, iter_fresh_objects( index, self._repo.path, object_store=self._repo.object_store)) if message is None: message = b"A stash on " + self._repo.head() # TODO(jelmer): Just pass parents into do_commit()? self._repo.refs[self._ref] = self._repo.head() cid = self._repo.do_commit( ref=self._ref, tree=stash_tree_id, message=message, merge_heads=[index_commit_id], **commit_kwargs) return cid