コード例 #1
0
ファイル: base.py プロジェクト: drtagkim/GitPython
 def entry_key(cls, *entry):
     return entry_key(*entry)
コード例 #2
0
ファイル: base.py プロジェクト: binarydud/GitPython
	def entry_key(cls, *entry):
		return entry_key(*entry)
コード例 #3
0
ファイル: base.py プロジェクト: drtagkim/GitPython
    def reset(self,
              commit='HEAD',
              working_tree=False,
              paths=None,
              head=False,
              **kwargs):
        """Reset the index to reflect the tree at the given commit. This will not
        adjust our HEAD reference as opposed to HEAD.reset by default.

        :param commit:
            Revision, Reference or Commit specifying the commit we should represent.
            If you want to specify a tree only, use IndexFile.from_tree and overwrite
            the default index.

        :param working_tree:
            If True, the files in the working tree will reflect the changed index.
            If False, the working tree will not be touched
            Please note that changes to the working copy will be discarded without
            warning !
            
        :param head:
            If True, the head will be set to the given commit. This is False by default,
            but if True, this method behaves like HEAD.reset.
            
        :param paths: if given as an iterable of absolute or repository-relative paths,
            only these will be reset to their state at the given commit'ish.
            The paths need to exist at the commit, otherwise an exception will be 
            raised.

        :param kwargs:
            Additional keyword arguments passed to git-reset
            
        .. note:: IndexFile.reset, as opposed to HEAD.reset, will not delete anyfiles
            in order to maintain a consistent working tree. Instead, it will just
            checkout the files according to their state in the index.
            If you want git-reset like behaviour, use *HEAD.reset* instead.

        :return: self """
        # what we actually want to do is to merge the tree into our existing
        # index, which is what git-read-tree does
        new_inst = type(self).from_tree(self.repo, commit)
        if not paths:
            self.entries = new_inst.entries
        else:
            nie = new_inst.entries
            for path in paths:
                path = self._to_relative_path(path)
                try:
                    key = entry_key(path, 0)
                    self.entries[key] = nie[key]
                except KeyError:
                    # if key is not in theirs, it musn't be in ours
                    try:
                        del (self.entries[key])
                    except KeyError:
                        pass
                    # END handle deletion keyerror
                # END handle keyerror
            # END for each path
        # END handle paths
        self.write()

        if working_tree:
            self.checkout(paths=paths, force=True)
        # END handle working tree

        if head:
            self.repo.head.set_commit(self.repo.commit(commit),
                                      logmsg="%s: Updating HEAD" % commit)
        # END handle head change

        return self
コード例 #4
0
ファイル: base.py プロジェクト: binarydud/GitPython
	def reset(self, commit='HEAD', working_tree=False, paths=None, head=False, **kwargs):
		"""Reset the index to reflect the tree at the given commit. This will not
		adjust our HEAD reference as opposed to HEAD.reset by default.

		:param commit:
			Revision, Reference or Commit specifying the commit we should represent.
			If you want to specify a tree only, use IndexFile.from_tree and overwrite
			the default index.

		:param working_tree:
			If True, the files in the working tree will reflect the changed index.
			If False, the working tree will not be touched
			Please note that changes to the working copy will be discarded without
			warning !
			
		:param head:
			If True, the head will be set to the given commit. This is False by default,
			but if True, this method behaves like HEAD.reset.
			
		:param paths: if given as an iterable of absolute or repository-relative paths,
			only these will be reset to their state at the given commit'ish.
			The paths need to exist at the commit, otherwise an exception will be 
			raised.

		:param kwargs:
			Additional keyword arguments passed to git-reset
			
		.. note:: IndexFile.reset, as opposed to HEAD.reset, will not delete anyfiles
			in order to maintain a consistent working tree. Instead, it will just
			checkout the files according to their state in the index.
			If you want git-reset like behaviour, use *HEAD.reset* instead.

		:return: self """
		# what we actually want to do is to merge the tree into our existing
		# index, which is what git-read-tree does
		new_inst = type(self).from_tree(self.repo, commit)
		if not paths:
			self.entries = new_inst.entries
		else:
			nie = new_inst.entries
			for path in paths:
				path = self._to_relative_path(path)
				try:
					key = entry_key(path, 0)
					self.entries[key] = nie[key]
				except KeyError:
					# if key is not in theirs, it musn't be in ours
					try:
						del(self.entries[key])
					except KeyError:
						pass
					# END handle deletion keyerror
				# END handle keyerror
			# END for each path
		# END handle paths
		self.write()
		
		if working_tree:
			self.checkout(paths=paths, force=True)
		# END handle working tree
		
		if head:
			self.repo.head.set_commit(self.repo.commit(commit), logmsg="%s: Updating HEAD" % commit)
		# END handle head change

		return self