Class: Circus::Repos::Mercurial
- Inherits:
-
Object
- Object
- Circus::Repos::Mercurial
- Defined in:
- lib/circus/repos/mercurial.rb
Class Method Summary collapse
-
.accepts_dir?(dir_name) ⇒ Boolean
Checks if the current directory (or a parent) are Hg working trees.
- .accepts_id?(key) ⇒ Boolean
- .type_id ⇒ Object
Instance Method Summary collapse
- #current_revision ⇒ Object
-
#initialize(dir) ⇒ Mercurial
constructor
A new instance of Mercurial.
- #repo_url ⇒ Object
- #write_patch(patch_fn) ⇒ Object
Constructor Details
#initialize(dir) ⇒ Mercurial
Returns a new instance of Mercurial.
20 21 22 |
# File 'lib/circus/repos/mercurial.rb', line 20 def initialize(dir) @dir = dir end |
Class Method Details
.accepts_dir?(dir_name) ⇒ Boolean
Checks if the current directory (or a parent) are Hg working trees. Uses a call to hg status to test (which will fail with a non-zero exit if the tree isn’t a valid git tree)
7 8 9 10 |
# File 'lib/circus/repos/mercurial.rb', line 7 def self.accepts_dir? dir_name `hg st >/dev/null 2>/dev/null` $? == 0 end |
.accepts_id?(key) ⇒ Boolean
12 13 14 |
# File 'lib/circus/repos/mercurial.rb', line 12 def self.accepts_id?(key) key == 'hg' || key == 'mercurial' end |
.type_id ⇒ Object
16 17 18 |
# File 'lib/circus/repos/mercurial.rb', line 16 def self.type_id 'hg' end |
Instance Method Details
#current_revision ⇒ Object
31 32 33 |
# File 'lib/circus/repos/mercurial.rb', line 31 def current_revision `(cd #{@dir}; hg id -i)`[0..11] end |
#repo_url ⇒ Object
24 25 26 27 28 29 |
# File 'lib/circus/repos/mercurial.rb', line 24 def repo_url first_path = `(cd #{@dir}; hg paths)`.lines.first return nil unless first_path first_path.split('=', 2)[1].strip end |
#write_patch(patch_fn) ⇒ Object
35 36 37 |
# File 'lib/circus/repos/mercurial.rb', line 35 def write_patch(patch_fn) `(cd #{@dir}; hg diff >#{patch_fn})`.strip end |