@@ -170,79 +170,4 @@ def _mode_str_to_int(cls, modestr):
170170 mode += int (char ) << iteration * 3
171171 # END for each char
172172 return mode
173-
174173
175- class Diffable (object ):
176- """
177- Common interface for all object that can be diffed against another object of compatible type.
178-
179- NOTE:
180- Subclasses require a repo member as it is the case for Object instances, for practical
181- reasons we do not derive from Object.
182- """
183- __slots__ = tuple ()
184-
185- # subclasses provide additional arguments to the git-diff comamnd by supplynig
186- # them in this tuple
187- _diff_args = tuple ()
188-
189- def diff (self , other = None , paths = None , create_patch = False , ** kwargs ):
190- """
191- Creates diffs between two items being trees, trees and index or an
192- index and the working tree.
193-
194- ``other``
195- Is the item to compare us with.
196- If None, we will be compared to the working tree.
197-
198- ``paths``
199- is a list of paths or a single path to limit the diff to.
200- It will only include at least one of the givne path or paths.
201-
202- ``create_patch``
203- If True, the returned Diff contains a detailed patch that if applied
204- makes the self to other. Patches are somwhat costly as blobs have to be read
205- and diffed.
206-
207- ``kwargs``
208- Additional arguments passed to git-diff, such as
209- R=True to swap both sides of the diff.
210-
211- Returns
212- git.DiffIndex
213-
214- Note
215- Rename detection will only work if create_patch is True
216- """
217- # import it in a retared fashion to avoid dependency cycle
218- from git .diff import Diff
219-
220- args = list (self ._diff_args [:])
221- args .append ( "--abbrev=40" ) # we need full shas
222- args .append ( "--full-index" ) # get full index paths, not only filenames
223-
224- if create_patch :
225- args .append ("-p" )
226- args .append ("-M" ) # check for renames
227- else :
228- args .append ("--raw" )
229-
230- paths = paths or []
231- if paths :
232- paths .insert (0 , "--" )
233-
234- if other is not None :
235- args .insert (0 , other )
236-
237- args .insert (0 ,self )
238- args .extend (paths )
239-
240- kwargs ['as_process' ] = True
241- proc = self .repo .git .diff (* args , ** kwargs )
242-
243- diff_method = Diff ._index_from_raw_format
244- if create_patch :
245- diff_method = Diff ._index_from_patch_format
246- return diff_method (self .repo , proc .stdout )
247-
248-
0 commit comments