Class: Vlad::Mercurial

Inherits:
Object
  • Object
show all
Defined in:
lib/vlad/mercurial.rb

Instance Method Summary collapse

Instance Method Details

#checkout(revision, destination) ⇒ Object

Returns the command that will check out revision from the repository into directory destination



9
10
11
12
13
14
15
# File 'lib/vlad/mercurial.rb', line 9

def checkout(revision, destination)
  revision = 'tip' if revision =~ /^head$/i

  [ "if [ ! -d #{destination}/.hg ]; then hg init -R #{destination}; fi",
    "hg pull -r #{revision} -R #{destination} #{repository}"
  ].join(' && ')
end

#export(revision_or_source, destination) ⇒ Object

Returns the command that will export revision from the repository into the directory destination.



21
22
23
24
25
26
27
28
# File 'lib/vlad/mercurial.rb', line 21

def export(revision_or_source, destination)
  revision_or_source = 'tip' if revision_or_source =~ /^head$/i
  if revision_or_source =~ /^(\d+|tip)$/i then
    "hg archive -r #{revision_or_source} -R #{repository} #{destination}"
  else
    "hg archive -R #{revision_or_source} #{destination}"
  end
end

#revision(revision) ⇒ Object

Returns a command that maps human-friendly revision identifier revision into a subversion revision specification.



34
35
36
# File 'lib/vlad/mercurial.rb', line 34

def revision(revision)
  "`hg identify -R #{repository} | cut -f1 -d\\ `"
end