Class: Blastr::SourceControl::Mercurial
- Inherits:
-
Object
- Object
- Blastr::SourceControl::Mercurial
- Defined in:
- lib/scm/hg.rb
Class Method Summary collapse
Instance Method Summary collapse
- #as_revision(arg) ⇒ Object
- #commits_since(revision) ⇒ Object
- #hg_log_entries(output) ⇒ Object
-
#initialize(repo_url) ⇒ Mercurial
constructor
A new instance of Mercurial.
- #latest_revision ⇒ Object
- #name ⇒ Object
Constructor Details
#initialize(repo_url) ⇒ Mercurial
Returns a new instance of Mercurial.
36 37 38 |
# File 'lib/scm/hg.rb', line 36 def initialize(repo_url) @repo_url = $1 if repo_url =~ /hg:(.*)/ end |
Class Method Details
.understands_url?(url) ⇒ Boolean
32 33 34 |
# File 'lib/scm/hg.rb', line 32 def self.understands_url?(url) url.index("hg:") == 0 end |
Instance Method Details
#as_revision(arg) ⇒ Object
40 41 42 43 |
# File 'lib/scm/hg.rb', line 40 def as_revision(arg) raise "Invalid revision: #{arg}" unless arg =~ /^(tip)|([\d\w:-]+)$/ MercurialRevision.new(arg) end |
#commits_since(revision) ⇒ Object
51 52 53 54 55 |
# File 'lib/scm/hg.rb', line 51 def commits_since(revision) with_clone do hg_log(revision.to_s) end end |
#hg_log_entries(output) ⇒ Object
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/scm/hg.rb', line 57 def hg_log_entries(output) entries = [] current_changeset = {} output.split(/-{69,71}/).each do |entry| if entry =~ /^changeset (\d+):(.+) by (.+):\n(.*)/mu entries << LogEntry.new(as_revision($1), $3, $4.strip) end end entries end |
#latest_revision ⇒ Object
45 46 47 48 49 |
# File 'lib/scm/hg.rb', line 45 def latest_revision commits = commits_since(as_revision("tip")) return as_revision("tip") unless commits.size > 0 MercurialRevision.new(commits.last.revision.to_s) end |
#name ⇒ Object
30 |
# File 'lib/scm/hg.rb', line 30 def name; "Mercurial"; end |