1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) James Liggett 2008 <jrliggett@cox.net>
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 "subversion-vcs-interface.h"
28 subversion_ivcs_iface_init (IAnjutaVcsIface
*iface
)
30 iface
->add
= subversion_ivcs_add
;
31 iface
->checkout
= subversion_ivcs_checkout
;
32 iface
->diff
= subversion_ivcs_diff
;
33 iface
->query_status
= subversion_ivcs_query_status
;
34 iface
->remove
= subversion_ivcs_remove
;
38 subversion_ivcs_add (IAnjutaVcs
*obj
, GList
*files
, AnjutaAsyncNotify
*notify
,
42 SvnAddCommand
*add_command
;
44 path_list
= anjuta_util_convert_gfile_list_to_path_list (files
);
45 add_command
= svn_add_command_new_list (path_list
, FALSE
, TRUE
);
47 anjuta_util_glist_strings_free (path_list
);
49 g_signal_connect (G_OBJECT (add_command
), "command-finished",
50 G_CALLBACK (g_object_unref
),
55 g_signal_connect_swapped (G_OBJECT (add_command
), "command-finished",
56 G_CALLBACK (anjuta_async_notify_notify_finished
),
60 anjuta_command_start (ANJUTA_COMMAND (add_command
));
65 subversion_ivcs_checkout (IAnjutaVcs
*obj
,
66 const gchar
*repository_location
, GFile
*dest
,
68 AnjutaAsyncNotify
*notify
, GError
**err
)
72 SvnCheckoutCommand
*checkout_command
;
76 g_file_make_directory (dest
, NULL
, &error
);
79 if (error
->code
!= G_IO_ERROR_EXISTS
)
81 g_propagate_error (err
, error
);
87 path
= g_file_get_path (dest
);
88 checkout_command
= svn_checkout_command_new (repository_location
, path
);
89 plugin
= ANJUTA_PLUGIN_SUBVERSION (obj
);
93 create_message_view (plugin
);
95 g_signal_connect (G_OBJECT (checkout_command
), "data-arrived",
96 G_CALLBACK (on_command_info_arrived
),
99 g_signal_connect (G_OBJECT (checkout_command
), "command-finished",
100 G_CALLBACK (g_object_unref
),
105 g_signal_connect_swapped (G_OBJECT (cancel
), "cancelled",
106 G_CALLBACK (anjuta_command_cancel
),
112 g_signal_connect_swapped (G_OBJECT (checkout_command
),
114 G_CALLBACK (anjuta_async_notify_notify_finished
),
118 anjuta_command_start (ANJUTA_COMMAND (checkout_command
));
122 on_diff_command_data_arrived (AnjutaCommand
*command
,
123 IAnjutaVcsDiffCallback callback
)
128 output
= svn_diff_command_get_output (SVN_DIFF_COMMAND (command
));
130 while (g_queue_peek_head (output
))
132 line
= g_queue_pop_head (output
);
133 callback (g_object_get_data (G_OBJECT (command
), "file"), line
,
134 g_object_get_data (G_OBJECT (command
), "user-data"));
140 subversion_ivcs_diff (IAnjutaVcs
*obj
, GFile
* file
,
141 IAnjutaVcsDiffCallback callback
, gpointer user_data
,
142 GCancellable
* cancel
, AnjutaAsyncNotify
*notify
,
146 SvnDiffCommand
*diff_command
;
148 path
= g_file_get_path (file
);
149 diff_command
= svn_diff_command_new (path
, SVN_DIFF_REVISION_NONE
,
150 SVN_DIFF_REVISION_NONE
,
151 ANJUTA_PLUGIN_SUBVERSION (obj
)->project_root_dir
,
156 g_object_set_data_full (G_OBJECT (diff_command
), "file",
158 (GDestroyNotify
) g_object_unref
);
159 g_object_set_data (G_OBJECT (diff_command
), "user-data", user_data
);
161 g_signal_connect (G_OBJECT (diff_command
), "command-finished",
162 G_CALLBACK (g_object_unref
),
165 g_signal_connect (G_OBJECT (diff_command
), "data-arrived",
166 G_CALLBACK (on_diff_command_data_arrived
),
171 g_signal_connect_swapped (G_OBJECT (cancel
), "cancelled",
172 G_CALLBACK (anjuta_command_cancel
),
178 g_signal_connect_swapped (G_OBJECT (diff_command
), "command-finished",
179 G_CALLBACK (anjuta_async_notify_notify_finished
),
183 anjuta_command_start (ANJUTA_COMMAND (diff_command
));
186 /* FIXME: The stuff in subversion-ui-utils.c should be namespaced. */
188 on_ivcs_status_command_data_arrived (AnjutaCommand
*command
,
189 IAnjutaVcsStatusCallback callback
)
191 GQueue
*status_queue
;
196 status_queue
= svn_status_command_get_status_queue (SVN_STATUS_COMMAND (command
));
198 while (g_queue_peek_head (status_queue
))
200 status
= g_queue_pop_head (status_queue
);
201 path
= svn_status_get_path (status
);
202 file
= g_file_new_for_path (path
);
207 svn_status_get_vcs_status (status
),
208 g_object_get_data (G_OBJECT (command
), "user-data"));
210 g_object_unref (file
);
213 svn_status_destroy (status
);
219 subversion_ivcs_query_status (IAnjutaVcs
*obj
, GFile
*file
,
220 IAnjutaVcsStatusCallback callback
,
221 gpointer user_data
, GCancellable
*cancel
,
222 AnjutaAsyncNotify
*notify
, GError
**err
)
225 SvnStatusCommand
*status_command
;
227 path
= g_file_get_path (file
);
228 status_command
= svn_status_command_new (path
, FALSE
, TRUE
);
232 g_object_set_data (G_OBJECT (status_command
), "user-data", user_data
);
234 g_signal_connect (G_OBJECT (status_command
), "data-arrived",
235 G_CALLBACK (on_ivcs_status_command_data_arrived
),
238 g_signal_connect (G_OBJECT (status_command
), "command-finished",
239 G_CALLBACK (g_object_unref
),
244 g_signal_connect_swapped (G_OBJECT (cancel
), "cancelled",
245 G_CALLBACK (anjuta_command_cancel
),
251 g_signal_connect_swapped (G_OBJECT (status_command
), "command-finished",
252 G_CALLBACK (anjuta_async_notify_notify_finished
),
256 anjuta_command_start (ANJUTA_COMMAND (status_command
));
260 subversion_ivcs_remove (IAnjutaVcs
*obj
, GList
*files
,
261 AnjutaAsyncNotify
*notify
, GError
**err
)
264 SvnRemoveCommand
*remove_command
;
266 path_list
= anjuta_util_convert_gfile_list_to_path_list (files
);
267 remove_command
= svn_remove_command_new_list (path_list
, NULL
, FALSE
);
269 anjuta_util_glist_strings_free (path_list
);
271 g_signal_connect (G_OBJECT (remove_command
), "command-finished",
272 G_CALLBACK (g_object_unref
),
277 g_signal_connect_swapped (G_OBJECT (remove_command
), "command-finished",
278 G_CALLBACK (anjuta_async_notify_notify_finished
),
282 anjuta_command_start (ANJUTA_COMMAND (remove_command
));