Updated Spanish translation
[anjuta.git] / plugins / subversion / svn-checkout-command.c
blob2d0146f41492017bd4509e00c94d7091b68960a6
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * anjuta
4 * Copyright (C) 2008 Ignacio Casal Quinteiro <nacho.resa@gmail.com>
5 *
6 * anjuta is free software.
7 *
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)
11 * any later version.
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
29 gchar *url;
30 gchar *path;
33 G_DEFINE_TYPE (SvnCheckoutCommand, svn_checkout_command, SVN_TYPE_COMMAND);
35 static void
36 svn_checkout_command_init (SvnCheckoutCommand *self)
38 self->priv = g_new0 (SvnCheckoutCommandPriv, 1);
41 static void
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);
50 g_free (self->priv);
52 G_OBJECT_CLASS (svn_checkout_command_parent_class)->finalize (object);
55 static guint
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;
62 svn_error_t *error;
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,
73 self->priv->url,
74 self->priv->path,
75 &peg_revision,
76 &revision,
77 svn_depth_unknown,
78 TRUE,
79 FALSE,
80 svn_command_get_client_context (svn_command),
81 svn_command_get_pool (svn_command));
83 if (error)
85 svn_command_set_error (svn_command, error);
86 return 1;
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);
94 return 0;
97 static void
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;
108 SvnCheckoutCommand *
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),
116 (gchar*) url);
117 self->priv->path = svn_command_make_canonical_path (SVN_COMMAND (self),
118 (gchar*) path);
120 return self;
123 void
124 svn_checkout_command_destroy (SvnCheckoutCommand *self)
126 g_object_unref (self);