summaryrefslogtreecommitdiff
path: root/src/mozclient/lib/MozClient/Mercurial.pm
blob: 40f2879717b4cbe947e6d10c477bcc86afe5dce9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# -*- mode: Perl -*-

# Copyright (c) 2007-2008 Fabien Tassin <fta@sofaraway.org>
# Description: MozClient::Mercurial
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation; either version 2, or (at
# your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

############################################################################

package MozClient::Mercurial;

use vars qw(@ISA);
use strict;
use MozClient::VCS;

@ISA = ("MozClient::VCS");

sub get_client {
  my $self = shift;

  $self->LOG("MozClient::Mercurial::get_client()");
  # nothing to do
}

sub convert_revdate {
  my $self = shift;
  my $arg = shift;

  $self->LOG("MozClient::Mercurial::convert_revdate($arg)");
  $arg =~ s,^\d+r,,;
  $arg;
}

sub set_revdate {
  my $self = shift;

  $self->LOG("MozClient::Mercurial::set_revdate()");

  # We can set a revision for hg
  $self->{'mozclient_date'} =
    '-r ' . $self->convert_revdate($self->{'have_date'});
}

sub set_tag {
  my $self = shift;
  my $tag  = shift;

  $self->LOG("MozClient::Mercurial::set_tag($tag)");

  $self->{'co_tag'} = "-r $tag";
}

sub checkout {
  my $self = shift;

  $self->LOG("MozClient:Mercurial::checkout:()");
  $self->chdir($self->work_dir);
  my $modules = [];
  if (defined $self->{'MOZCLIENT_PROJECT'}) {
    push @$modules,
      $self->{'MOZCLIENT_VCS_LOC'} . $self->{'MOZCLIENT_PROJECT'} . "/";
  }
  else {
    for my $module (@{$self->{'MOZCLIENT_MODULES'}}) {
      push @$modules, (sprintf " %s%s/%s", $self->{'MOZCLIENT_VCS_LOC'},
	$self->{'MOZCLIENT_PROJECT'}, $module);
    }
  }
  my $cmd = sprintf "hg clone %s %s", join(" ", @$modules),
    $self->{'MOZCLIENT_MOZDIRNAME'};
  $self->run_system($cmd);
  $self->chdir($self->{'MOZCLIENT_MOZDIRNAME'});
  my $rev =  $self->{'mozclient_date'} ?  $self->{'mozclient_date'} : $self->{'co_tag'};
  $cmd = sprintf "hg update %s", $rev;
  $self->run_system($cmd);
  $self->chdir("../..");
}

sub tar_exclude {
  my $self = shift;

  $self->LOG("MozClient::Mercurial::tar_exclude()");
  [ '--exclude .hg' ];
}

1;