perforce_bulk_load.patch

George Gensure, 2009-04-20 22:29

Download (2.96 KB)

View differences:

app/models/repository/perforce.rb 2009-04-20 10:28:09.956752000 -0400
52 52
      if db_revision < scm_revision
53 53
        logger.debug "Fetching changesets for repository #{url}" if logger && logger.debug?
54 54
        identifier_from = db_revision + 1
55
        while (identifier_from <= scm_revision)
56
          # loads changesets by batches of 200
57
          identifier_to = [identifier_from + 199, scm_revision].min
58
          revisions = scm.revisions('', identifier_to, identifier_from, :with_paths => true)
59
          transaction do
60
            revisions.reverse_each do
61
              |revision|
62
              changeset = Changeset.create(:repository => self,
63
                :revision => revision.identifier,
64
                :committer => revision.author,
65
                :committed_on => revision.time,
66
                :comments => revision.message)
67
              
68
              revision.paths.each do
69
                |change|
55
        identifier_to = scm_revision
56
        revisions = scm.revisions('', identifier_to, identifier_from, :with_paths => true)
57
        transaction do
58
          revisions.reverse_each do
59
            |revision|
60
            changeset = Changeset.create(:repository => self,
61
              :revision => revision.identifier,
62
              :committer => revision.author,
63
              :committed_on => revision.time,
64
              :comments => revision.message)
65
            
66
            revision.paths.each do
67
              |change|
70 68

  
71
                revpath = '/' + scm.relative_path( change.depot_file )
72
                action = ( change.action )
73
                revaction = case action
74
                  when "add" then "A"
75
                  when "delete" then "D"
76
                  when "edit" then "M"
77
                  when "branch" then "B"
78
                  #when "integrate" then "I"
79
                  #when "import" then "E"
80
                end
81

  
82
                Change.create(:changeset => changeset,
83
                  :action => revaction,
84
                  :path =>  revpath,
85
                  :revision => '#' + ( change.revno.to_s + '/' + change.head.to_s ))
69
              revpath = '/' + scm.relative_path( change.depot_file )
70
              action = ( change.action )
71
              revaction = case action
72
                when "add" then "A"
73
                when "delete" then "D"
74
                when "edit" then "M"
75
                when "branch" then "B"
76
                #when "integrate" then "I"
77
                #when "import" then "E"
86 78
              end
79

  
80
              Change.create(:changeset => changeset,
81
                :action => revaction,
82
                :path =>  revpath,
83
                :revision => '#' + ( change.revno.to_s + '/' + change.head.to_s ))
87 84
            end
88
          end unless revisions.nil?
89
          identifier_from = identifier_to + 1
90
        end
85
          end
86
        end unless revisions.nil?
91 87
      end
92 88
    end
93 89
  end