1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) 2008 Ignacio Casal Quinteiro <nacho.resa@gmail.com>
6 * anjuta is free software.
8 * You may redistribute it and/or modify it under the terms of the
9 * GNU General Public License, as published by the Free Software
10 * Foundation; either version 2 of the License, or (at your option)
13 * anjuta is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 * See the GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with anjuta. If not, write to:
20 * The Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor
22 * Boston, MA 02110-1301, USA.
25 #include "svn-checkout-command.h"
27 struct _SvnCheckoutCommandPriv
33 G_DEFINE_TYPE (SvnCheckoutCommand
, svn_checkout_command
, SVN_TYPE_COMMAND
);
36 svn_checkout_command_init (SvnCheckoutCommand
*self
)
38 self
->priv
= g_new0 (SvnCheckoutCommandPriv
, 1);
42 svn_checkout_command_finalize (GObject
*object
)
44 SvnCheckoutCommand
*self
;
46 self
= SVN_CHECKOUT_COMMAND (object
);
48 g_free (self
->priv
->url
);
49 g_free (self
->priv
->path
);
52 G_OBJECT_CLASS (svn_checkout_command_parent_class
)->finalize (object
);
56 svn_checkout_command_run (AnjutaCommand
*command
)
58 SvnCheckoutCommand
*self
;
59 SvnCommand
*svn_command
;
60 svn_opt_revision_t revision
;
61 svn_opt_revision_t peg_revision
;
63 svn_revnum_t revision_number
;
64 gchar
*revision_message
;
66 self
= SVN_CHECKOUT_COMMAND (command
);
67 svn_command
= SVN_COMMAND (command
);
69 revision
.kind
= svn_opt_revision_head
;
70 peg_revision
.kind
= svn_opt_revision_unspecified
;
72 error
= svn_client_checkout3 (&revision_number
,
80 svn_command_get_client_context (svn_command
),
81 svn_command_get_pool (svn_command
));
85 svn_command_set_error (svn_command
, error
);
89 revision_message
= g_strdup_printf ("Checked out revision %ld.",
90 (glong
) revision_number
);
91 svn_command_push_info (SVN_COMMAND (command
), revision_message
);
92 g_free (revision_message
);
98 svn_checkout_command_class_init (SvnCheckoutCommandClass
*klass
)
100 GObjectClass
*object_class
= G_OBJECT_CLASS (klass
);
101 AnjutaCommandClass
*command_class
= ANJUTA_COMMAND_CLASS (klass
);
103 object_class
->finalize
= svn_checkout_command_finalize
;
104 command_class
->run
= svn_checkout_command_run
;
109 svn_checkout_command_new (const gchar
*url
, const gchar
*path
)
111 SvnCheckoutCommand
*self
;
113 self
= g_object_new (SVN_TYPE_CHECKOUT_COMMAND
, NULL
);
115 self
->priv
->url
= svn_command_make_canonical_path (SVN_COMMAND (self
),
117 self
->priv
->path
= svn_command_make_canonical_path (SVN_COMMAND (self
),
124 svn_checkout_command_destroy (SvnCheckoutCommand
*self
)
126 g_object_unref (self
);