Class: RevList

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/rev_list.rb

Constant Summary collapse

RANGE =
/^(.*)\.\.(.*)$/
EXCLUDE =
/^\^(.+)$/

Instance Method Summary collapse

Constructor Details

#initialize(repo, revs, options = {}) ⇒ RevList

Returns a new instance of RevList.



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/rev_list.rb', line 13

def initialize(repo, revs, options = {})
  @repo    = repo
  @commits = {}
  @flags   = Hash.new { |hash, oid| hash[oid] = Set.new }
  @queue   = []
  @limited = false
  @prune   = []
  @diffs   = {}
  @output  = []
  @pending = []
  @paths   = {}

  @objects = options.fetch(:objects, false)
  @missing = options.fetch(:missing, false)
  @walk    = options.fetch(:walk, true)

  include_refs(repo.refs.list_all_refs) if options[:all]
  include_refs(repo.refs.list_branches) if options[:branches]
  include_refs(repo.refs.list_remotes)  if options[:remotes]

  revs.each { |rev| handle_revision(rev) }
  handle_revision(Revision::HEAD) if @queue.empty?

  @filter = PathFilter.build(@prune)
end

Instance Method Details

#eachObject



39
40
41
42
43
44
# File 'lib/rev_list.rb', line 39

def each
  limit_list if @limited
  mark_edges_uninteresting if @objects
  traverse_commits { |commit| yield commit }
  traverse_pending { |object| yield object, @paths[object.oid] }
end

#tree_diff(old_oid, new_oid) ⇒ Object



46
47
48
49
# File 'lib/rev_list.rb', line 46

def tree_diff(old_oid, new_oid)
  key = [old_oid, new_oid]
  @diffs[key] ||= @repo.database.tree_diff(old_oid, new_oid, @filter)
end