@@ -116,12 +116,12 @@ def tags(self):
116116 """
117117 return Tag .list_items (self )
118118
119- def blame (self , ref , file ):
119+ def blame (self , rev , file ):
120120 """
121- The blame information for the given file at the given ref .
121+ The blame information for the given file at the given revision .
122122
123- ``ref ``
124- Ref object or Commit
123+ ``rev ``
124+ revision specifier, see git-rev-parse for viable options.
125125
126126 Returns
127127 list: [git.Commit, list: [<line>]]
@@ -199,37 +199,29 @@ def blame(self, ref, file):
199199 # END distinguish hexsha vs other information
200200 return blames
201201
202- def commits (self , start = None , paths = '' , max_count = None , skip = 0 ):
202+ def iter_commits (self , rev = None , paths = '' , ** kwargs ):
203203 """
204204 A list of Commit objects representing the history of a given ref/commit
205205
206- ``start ``
207- is a Ref or Commit to start the commits from. If start is None,
208- the active branch will be used
206+ ``rev ``
207+ revision specifier, see git-rev-parse for viable options.
208+ If None, the active branch will be used.
209209
210210 ``paths``
211211 is an optional path or a list of paths to limit the returned commits to
212212 Commits that do not contain that path or the paths will not be returned.
213-
214- ``max_count``
215- is the maximum number of commits to return (default None)
216-
217- ``skip``
218- is the number of commits to skip (default 0) which will effectively
219- move your commit-window by the given number.
213+
214+ ``kwargs``
215+ Arguments to be passed to git-rev-parse - common ones are
216+ max_count and skip
220217
221218 Returns
222219 ``git.Commit[]``
223220 """
224- options = {'max_count' : max_count ,
225- 'skip' : skip }
226-
227- if max_count is None :
228- options .pop ('max_count' )
229- if start is None :
230- start = self .active_branch
221+ if rev is None :
222+ rev = self .active_branch
231223
232- return Commit .list_items (self , start , paths , ** options )
224+ return Commit .list_items (self , rev , paths , ** kwargs )
233225
234226 def commits_between (self , frm , to , * args , ** kwargs ):
235227 """
@@ -248,50 +240,31 @@ def commits_between(self, frm, to, *args, **kwargs):
248240 return reversed (Commit .list_items (self , "%s..%s" % (frm , to )))
249241
250242
251- def commit (self , id = None , paths = '' ):
243+ def commit (self , rev = None ):
252244 """
253- The Commit object for the specified id
245+ The Commit object for the specified revision
254246
255- ``id``
256- is the SHA1 identifier of the commit or a ref or a ref name
257- if None, it defaults to the active branch
247+ ``rev``
248+ revision specifier, see git-rev-parse for viable options.
258249
259-
260- ``paths``
261- is an optional path or a list of paths,
262- if set the returned commit must contain the path or paths
263-
264250 Returns
265251 ``git.Commit``
266252 """
267- if id is None :
268- id = self .active_branch
269- options = {'max_count' : 1 }
270-
271- commits = Commit .list_items (self , id , paths , ** options )
272-
273- if not commits :
274- raise ValueError , "Invalid identifier %s, or given path '%s' too restrictive" % ( id , path )
275- return commits [0 ]
276-
277- def commit_deltas_from (self , other_repo , ref = 'master' , other_ref = 'master' ):
278- """
279- Returns a list of commits that is in ``other_repo`` but not in self
280-
281- Returns
282- git.Commit[]
283- """
284- repo_refs = self .git .rev_list (ref , '--' ).strip ().splitlines ()
285- other_repo_refs = other_repo .git .rev_list (other_ref , '--' ).strip ().splitlines ()
253+ if rev is None :
254+ rev = self .active_branch
255+
256+ # NOTE: currently we are not checking wheter rev really points to a commit
257+ # If not, the system will barf on access of the object, but we don't do that
258+ # here to safe cycles
259+ c = Commit (self , rev )
260+ return c
286261
287- diff_refs = list (set (other_repo_refs ) - set (repo_refs ))
288- return map (lambda ref : Commit (other_repo , ref ), diff_refs )
289262
290- def tree (self , treeish = None ):
263+ def tree (self , ref = None ):
291264 """
292265 The Tree object for the given treeish reference
293266
294- ``treeish ``
267+ ``ref ``
295268 is a Ref instance defaulting to the active_branch if None.
296269
297270 Examples::
@@ -305,27 +278,42 @@ def tree(self, treeish=None):
305278 A ref is requried here to assure you point to a commit or tag. Otherwise
306279 it is not garantueed that you point to the root-level tree.
307280
308- If you need a non-root level tree, find it by iterating the root tree.
309- """
310- if treeish is None :
311- treeish = self .active_branch
312- if not isinstance (treeish , Ref ):
313- raise ValueError ( "Treeish reference required, got %r" % treeish )
281+ If you need a non-root level tree, find it by iterating the root tree. Otherwise
282+ it cannot know about its path relative to the repository root and subsequent
283+ operations might have unexpected results.
284+ """
285+ if ref is None :
286+ ref = self .active_branch
287+ if not isinstance (ref , Reference ):
288+ raise ValueError ( "Reference required, got %r" % ref )
314289
315290
316291 # As we are directly reading object information, we must make sure
317292 # we truly point to a tree object. We resolve the ref to a sha in all cases
318293 # to assure the returned tree can be compared properly. Except for
319294 # heads, ids should always be hexshas
320- hexsha , typename , size = self .git .get_object_header ( treeish )
295+ hexsha , typename , size = self .git .get_object_header ( ref )
321296 if typename != "tree" :
322- hexsha , typename , size = self .git .get_object_header ( str (treeish )+ '^{tree}' )
297+ # will raise if this is not a valid tree
298+ hexsha , typename , size = self .git .get_object_header ( str (ref )+ '^{tree}' )
323299 # END tree handling
324- treeish = hexsha
300+ ref = hexsha
325301
326302 # the root has an empty relative path and the default mode
327- return Tree (self , treeish , 0 , '' )
303+ return Tree (self , ref , 0 , '' )
304+
305+ def commit_deltas_from (self , other_repo , ref = 'master' , other_ref = 'master' ):
306+ """
307+ Returns a list of commits that is in ``other_repo`` but not in self
328308
309+ Returns
310+ git.Commit[]
311+ """
312+ repo_refs = self .git .rev_list (ref , '--' ).strip ().splitlines ()
313+ other_repo_refs = other_repo .git .rev_list (other_ref , '--' ).strip ().splitlines ()
314+
315+ diff_refs = list (set (other_repo_refs ) - set (repo_refs ))
316+ return map (lambda ref : Commit (other_repo , ref ), diff_refs )
329317
330318 def diff (self , a , b , * paths ):
331319 """
0 commit comments