| Class | RSCM::Perforce |
| In: |
lib/rscm/scm/perforce.rb
|
| Parent: | Base |
| DATE_FORMAT | = | "%Y/%m/%d:%H:%M:%S" | ||
| CHANGELIST_PATTERN | = | /^Change \d+ by (.*)@.* on (.*)\n\n(.*)\n\nAffected files ...\n\n(.*)/m | Doesn‘t work for empty messages, (Like 21358 in Aslak’s P4 repo) | |
| CHANGELIST_PATTERN_NO_MSG | = | /^Change \d+ by (.*)@.* on (.*)\n\nAffected files ...\n\n(.*)/m | But this one does | |
| STATES | = | { "add" => RevisionFile::ADDED, "edit" => RevisionFile::MODIFIED, "delete" => RevisionFile::DELETED |
| password | [RW] | |
| username | [RW] | |
| view | [RW] |
# File lib/rscm/scm/perforce.rb, line 117
117: def destroy_working_copy(options={})
118: execute("p4 #{p4_opts(false)} client -d #{client_name}", options)
119: end
# File lib/rscm/scm/perforce.rb, line 129
129: def diff
130: #p4 diff2 //depot/trunk/build.xml@26405 //depot/trunk/build.xml@26409
131: end
# File lib/rscm/scm/perforce.rb, line 33
33: def installed?
34: begin
35: execute("p4 info", {})
36: true
37: rescue
38: false
39: end
40: end
# File lib/rscm/scm/perforce.rb, line 121
121: def open(revision_file, options={}, &block)
122: path = @view.gsub(/\.\.\./, revision_file.path) # + "@" + revision_file.native_revision_identifier
123: cmd = "p4 #{p4_opts(false)} print -q #{path}"
124: execute(cmd, options) do |io|
125: block.call io
126: end
127: end
# File lib/rscm/scm/perforce.rb, line 42
42: def revisions(from_identifier=Time.new.utc, options={})
43: raise "from_identifer cannot be nil" if from_identifier.nil?
44: set_utc_offset(options)
45: view_as_regexp = "^" + @view.gsub(/\.\.\./, "(.*)")
46: relative_path_pattern = Regexp.new(view_as_regexp)
47:
48: from_identifier = Time.epoch unless from_identifier
49: from_identifier = Time.epoch if (from_identifier.is_a? Time and from_identifier < Time.epoch)
50: from = revision_spec(from_identifier + 1) # We have to add 1 because of the contract of this method.
51:
52: to_identifier = options[:to_identifier] ? options[:to_identifier] : Time.infinity
53: to = revision_spec(to_identifier - 1) # We have to subtract 1 because of the contract of this method.
54:
55: cmd = "p4 #{p4_opts(false)} changes #{@view}@#{from},#{to}"
56: revisions = Revisions.new
57: revisions.cmd = cmd if store_revisions_command?
58:
59: changes = execute(cmd, options) do |io|
60: io.read
61: end
62:
63: changes.each do |line|
64: revision = nil
65: identifier = line.match(/^Change (\d+)/)[1].to_i
66:
67: execute("p4 #{p4_opts(false)} describe -s #{identifier}", options) do |io|
68: log = io.read
69:
70: if log =~ CHANGELIST_PATTERN
71: developer, time, message, files = $1, $2, $3, $4
72: elsif log =~ CHANGELIST_PATTERN_NO_MSG
73: developer, time, files = $1, $2, $3
74: else
75: puts "PARSE ERROR:"
76: puts log
77: puts "\nDIDN'T MATCH:"
78: puts CHANGELIST_PATTERN
79: end
80:
81: # The parsed time doesn't have timezone info. We'll tweak it.
82: time = Time.parse(time + " UTC") - @utc_offset
83:
84: files.each_line do |line|
85: if line =~ /^\.\.\. (\/\/.+)#(\d+) (.+)/
86: depot_path = $1
87: file_identifier = $2.to_i
88: state = $3.strip
89: if(STATES[state])
90: if(depot_path =~ relative_path_pattern)
91: relative_path = $1
92:
93: if revision.nil?
94: revision = Revision.new
95: revision.identifier = identifier
96: revision.developer = developer
97: revision.message = message
98: revision.time = time
99: revisions.add revision
100: end
101:
102: file = RevisionFile.new
103: file.path = relative_path
104: file.native_revision_identifier = file_identifier
105: file.previous_native_revision_identifier = file.native_revision_identifier-1
106: file.status = STATES[state]
107: revision.add file
108: end
109: end
110: end
111: end
112: end
113: end
114: revisions
115: end
# File lib/rscm/scm/perforce.rb, line 135
135: def checkout_silent(to_identifier, options)
136: checkout_dir = PathConverter.filepath_to_nativepath(@checkout_dir, false)
137: FileUtils.mkdir_p(@checkout_dir)
138:
139: ensure_client(options)
140: execute("p4 #{p4_opts} sync #{@view}@#{to_identifier}", options)
141: end