1 /* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
4 * Copyright (C) James Liggett 2007 <jrliggett@cox.net>
6 * Portions based on the original Subversion plugin
7 * Copyright (C) Johannes Schmid 2005
9 * anjuta is free software.
11 * You may redistribute it and/or modify it under the terms of the
12 * GNU General Public License, as published by the Free Software
13 * Foundation; either version 2 of the License, or (at your option)
16 * anjuta is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 * See the GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with anjuta. If not, write to:
23 * The Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor
25 * Boston, MA 02110-1301, USA.
28 #include "svn-commit-command.h"
30 struct _SvnCommitCommandPriv
37 G_DEFINE_TYPE (SvnCommitCommand
, svn_commit_command
, SVN_TYPE_COMMAND
);
40 on_log_callback (const char **log_msg
,
41 const char **tmp_file
,
42 apr_array_header_t
*commit_items
,
47 SvnCommitCommand
*self
;
49 self
= SVN_COMMIT_COMMAND (baton
);
51 *log_msg
= self
->priv
->log_message
;
58 svn_commit_command_init (SvnCommitCommand
*self
)
60 svn_client_ctx_t
*client_context
;
62 self
->priv
= g_new0 (SvnCommitCommandPriv
, 1);
63 client_context
= svn_command_get_client_context (SVN_COMMAND (self
));
65 client_context
->log_msg_func
= on_log_callback
;
66 client_context
->log_msg_baton
= self
;
71 svn_commit_command_finalize (GObject
*object
)
73 SvnCommitCommand
*self
;
75 self
= SVN_COMMIT_COMMAND (object
);
77 svn_command_free_path_list (self
->priv
->paths
);
78 g_free (self
->priv
->log_message
);
81 G_OBJECT_CLASS (svn_commit_command_parent_class
)->finalize (object
);
85 svn_commit_command_run (AnjutaCommand
*command
)
87 SvnCommitCommand
*self
;
88 SvnCommand
*svn_command
;
90 apr_array_header_t
*commit_paths
;
91 gchar
*revision_message
;
93 svn_commit_info_t
*commit_info
;
95 self
= SVN_COMMIT_COMMAND (command
);
96 svn_command
= SVN_COMMAND (command
);
97 current_path
= self
->priv
->paths
;
98 commit_paths
= apr_array_make (svn_command_get_pool (svn_command
),
99 g_list_length (self
->priv
->paths
),
104 /* I just copied this so don't blame me... */
105 (*((const char **) apr_array_push (commit_paths
))) = current_path
->data
;
106 current_path
= g_list_next (current_path
);
109 error
= svn_client_commit3 (&commit_info
,
111 self
->priv
->recursive
,
113 svn_command_get_client_context (svn_command
),
114 svn_command_get_pool (svn_command
));
118 svn_command_set_error (svn_command
, error
);
124 revision_message
= g_strdup_printf ("Committed revision %ld.",
125 commit_info
->revision
);
126 svn_command_push_info (SVN_COMMAND (command
), revision_message
);
127 g_free (revision_message
);
134 svn_commit_command_class_init (SvnCommitCommandClass
*klass
)
136 GObjectClass
*object_class
= G_OBJECT_CLASS (klass
);
137 AnjutaCommandClass
*command_class
= ANJUTA_COMMAND_CLASS (klass
);
139 object_class
->finalize
= svn_commit_command_finalize
;
140 command_class
->run
= svn_commit_command_run
;
144 svn_commit_command_new (GList
*paths
, gchar
*log_message
,
147 SvnCommitCommand
*self
;
149 self
= g_object_new (SVN_TYPE_COMMIT_COMMAND
, NULL
);
150 self
->priv
->paths
= svn_command_copy_path_list (paths
);
151 self
->priv
->log_message
= g_strdup (log_message
);
152 self
->priv
->recursive
= recursive
;
158 svn_commit_command_destroy (SvnCommitCommand
*self
)
160 g_object_unref (self
);