1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) James Liggett 2007 <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 "svn-revert-command.h"
27 struct _SvnRevertCommandPriv
33 G_DEFINE_TYPE (SvnRevertCommand
, svn_revert_command
, SVN_TYPE_COMMAND
);
36 svn_revert_command_init (SvnRevertCommand
*self
)
38 self
->priv
= g_new0 (SvnRevertCommandPriv
, 1);
42 svn_revert_command_finalize (GObject
*object
)
44 SvnRevertCommand
*self
;
46 self
= SVN_REVERT_COMMAND (object
);
48 svn_command_free_path_list (self
->priv
->paths
);
51 G_OBJECT_CLASS (svn_revert_command_parent_class
)->finalize (object
);
55 svn_revert_command_run (AnjutaCommand
*command
)
57 SvnRevertCommand
*self
;
58 SvnCommand
*svn_command
;
60 apr_array_header_t
*revert_paths
;
63 self
= SVN_REVERT_COMMAND (command
);
64 svn_command
= SVN_COMMAND (command
);
65 current_path
= self
->priv
->paths
;
66 revert_paths
= apr_array_make (svn_command_get_pool (svn_command
),
67 g_list_length (self
->priv
->paths
),
72 /* I just copied this so don't blame me... */
73 (*((const char **) apr_array_push (revert_paths
))) = current_path
->data
;
74 current_path
= g_list_next (current_path
);
77 error
= svn_client_revert (revert_paths
,
78 self
->priv
->recursive
,
79 svn_command_get_client_context (svn_command
),
80 svn_command_get_pool (svn_command
));
84 svn_command_set_error (svn_command
, error
);
92 svn_revert_command_class_init (SvnRevertCommandClass
*klass
)
94 GObjectClass
*object_class
= G_OBJECT_CLASS (klass
);
95 AnjutaCommandClass
*command_class
= ANJUTA_COMMAND_CLASS (klass
);
97 object_class
->finalize
= svn_revert_command_finalize
;
98 command_class
->run
= svn_revert_command_run
;
103 svn_revert_command_new (GList
*paths
, gboolean recursive
)
105 SvnRevertCommand
*self
;
107 self
= g_object_new (SVN_TYPE_REVERT_COMMAND
, NULL
);
108 self
->priv
->paths
= svn_command_copy_path_list (paths
);
109 self
->priv
->recursive
= recursive
;
115 svn_revert_command_destroy (SvnRevertCommand
*self
)
117 g_object_unref (self
);