Updated Spanish translation
[anjuta-git-plugin.git] / plugins / subversion / svn-merge-command.c
blobad827458a01156d00f04453742194109ebfcc914
1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
2 /*
3 * anjuta
4 * Copyright (C) James Liggett 2007 <jrliggett@cox.net>
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-merge-command.h"
27 struct _SvnMergeCommandPriv
29 gchar *path1;
30 gchar *path2;
31 glong start_revision;
32 glong end_revision;
33 gchar *target_path;
34 gboolean recursive;
35 gboolean ignore_ancestry;
36 gboolean force;
37 gboolean dry_run;
40 G_DEFINE_TYPE (SvnMergeCommand, svn_merge_command, SVN_TYPE_COMMAND);
42 static void
43 svn_merge_command_init (SvnMergeCommand *self)
45 self->priv = g_new0 (SvnMergeCommandPriv, 1);
48 static void
49 svn_merge_command_finalize (GObject *object)
51 SvnMergeCommand *self;
53 self = SVN_MERGE_COMMAND (object);
55 g_free (self->priv->path1);
56 g_free (self->priv->path2);
57 g_free (self->priv->target_path);
58 g_free (self->priv);
60 G_OBJECT_CLASS (svn_merge_command_parent_class)->finalize (object);
63 static guint
64 svn_merge_command_run (AnjutaCommand *command)
66 SvnMergeCommand *self;
67 SvnCommand *svn_command;
68 svn_opt_revision_t start_revision;
69 svn_opt_revision_t end_revision;
70 svn_error_t *error;
72 self = SVN_MERGE_COMMAND (command);
73 svn_command = SVN_COMMAND (command);
75 if (self->priv->start_revision == SVN_MERGE_REVISION_HEAD)
76 start_revision.kind = svn_opt_revision_head;
77 else
79 start_revision.kind = svn_opt_revision_number;
80 start_revision.value.number = self->priv->start_revision;
83 if (self->priv->end_revision == SVN_MERGE_REVISION_HEAD)
84 end_revision.kind = svn_opt_revision_head;
85 else
87 end_revision.kind = svn_opt_revision_number;
88 end_revision.value.number = self->priv->end_revision;
91 error = svn_client_merge2 (self->priv->path1,
92 &start_revision,
93 self->priv->path2,
94 &end_revision,
95 self->priv->target_path,
96 self->priv->recursive,
97 self->priv->ignore_ancestry,
98 self->priv->force,
99 self->priv->dry_run,
100 NULL,
101 svn_command_get_client_context (svn_command),
102 svn_command_get_pool (svn_command));
104 if (error)
106 svn_command_set_error (svn_command, error);
107 return 1;
110 return 0;
113 static void
114 svn_merge_command_class_init (SvnMergeCommandClass *klass)
116 GObjectClass* object_class = G_OBJECT_CLASS (klass);
117 AnjutaCommandClass* command_class = ANJUTA_COMMAND_CLASS (klass);
119 object_class->finalize = svn_merge_command_finalize;
120 command_class->run = svn_merge_command_run;
123 SvnMergeCommand *
124 svn_merge_command_new (gchar *path1,
125 gchar *path2,
126 glong start_revision,
127 glong end_revision,
128 gchar *target_path,
129 gboolean recursive,
130 gboolean ignore_ancestry,
131 gboolean force,
132 gboolean dry_run)
134 SvnMergeCommand *self;
136 self = g_object_new (SVN_TYPE_MERGE_COMMAND, NULL);
137 self->priv->path1 = g_strdup (path1);
138 self->priv->path2 = g_strdup (path2);
139 self->priv->start_revision = start_revision;
140 self->priv->end_revision = end_revision;
141 self->priv->target_path = g_strdup (target_path);
142 self->priv->recursive = recursive;
143 self->priv->ignore_ancestry = ignore_ancestry;
144 self->priv->force = force;
145 self->priv->dry_run = dry_run;
147 return self;
150 void
151 svn_merge_command_destroy (SvnMergeCommand *self)
153 g_object_unref (self);