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-log-command.h"
27 struct _SvnLogCommandPriv
30 GQueue
*log_entry_queue
;
33 G_DEFINE_TYPE (SvnLogCommand
, svn_log_command
, SVN_TYPE_COMMAND
);
36 svn_log_command_init (SvnLogCommand
*self
)
38 self
->priv
= g_new0 (SvnLogCommandPriv
, 1);
39 self
->priv
->log_entry_queue
= g_queue_new ();
43 svn_log_command_finalize (GObject
*object
)
46 GList
*current_log_entry
;
48 self
= SVN_LOG_COMMAND (object
);
50 g_free (self
->priv
->path
);
52 current_log_entry
= self
->priv
->log_entry_queue
->head
;
54 while (current_log_entry
)
56 svn_log_entry_destroy (current_log_entry
->data
);
57 current_log_entry
= g_list_next (current_log_entry
);
60 g_queue_free (self
->priv
->log_entry_queue
);
63 G_OBJECT_CLASS (svn_log_command_parent_class
)->finalize (object
);
67 log_callback (void *baton
,
68 apr_hash_t
*changed_paths
,
69 svn_revnum_t revision
,
76 SvnLogEntry
*log_entry
;
78 const gchar
*human_date
;
80 apr_time_t entry_time
;
83 self
= SVN_LOG_COMMAND (baton
);
85 /* Libsvn docs say author, date, and message might be NULL. */
87 entry_author
= g_strdup (author
);
89 entry_author
= g_strdup ("(none)");
93 svn_time_from_cstring (&entry_time
, date
,
94 svn_command_get_pool (SVN_COMMAND (self
)));
95 human_date
= svn_time_to_human_cstring (entry_time
,
96 svn_command_get_pool (SVN_COMMAND (self
)));
97 entry_date
= g_strdup (human_date
);
100 entry_date
= g_strdup ("(none)");
103 entry_message
= g_strdup (message
);
105 entry_message
= g_strdup ("empty log message"); /* Emulate ViewCVS */
107 log_entry
= svn_log_entry_new (entry_author
, entry_date
, revision
,
110 anjuta_async_command_lock (ANJUTA_ASYNC_COMMAND (self
));
111 g_queue_push_head (self
->priv
->log_entry_queue
, log_entry
);
112 anjuta_async_command_unlock (ANJUTA_ASYNC_COMMAND (self
));
114 anjuta_command_notify_data_arrived (ANJUTA_COMMAND (self
));
120 svn_log_command_run (AnjutaCommand
*command
)
123 SvnCommand
*svn_command
;
124 apr_array_header_t
*log_path
;
125 svn_opt_revision_t peg_revision
;
126 svn_opt_revision_t start_revision
;
127 svn_opt_revision_t end_revision
;
130 self
= SVN_LOG_COMMAND (command
);
131 svn_command
= SVN_COMMAND (command
);
132 log_path
= apr_array_make (svn_command_get_pool (SVN_COMMAND (command
)),
134 /* I just copied this so don't blame me... */
135 (*((const char **) apr_array_push (log_path
))) = self
->priv
->path
;
136 peg_revision
.kind
= svn_opt_revision_unspecified
;
137 start_revision
.kind
= svn_opt_revision_number
;
138 start_revision
.value
.number
= 1; /* Initial revision */
139 end_revision
.kind
= svn_opt_revision_head
;
141 error
= svn_client_log3 (log_path
,
150 svn_command_get_client_context (svn_command
),
151 svn_command_get_pool (svn_command
));
155 svn_command_set_error (svn_command
, error
);
163 svn_log_command_class_init (SvnLogCommandClass
*klass
)
165 GObjectClass
*object_class
= G_OBJECT_CLASS (klass
);
166 AnjutaCommandClass
*command_class
= ANJUTA_COMMAND_CLASS (klass
);
168 object_class
->finalize
= svn_log_command_finalize
;
169 command_class
->run
= svn_log_command_run
;
173 svn_log_command_new (gchar
*path
)
177 self
= g_object_new (SVN_TYPE_LOG_COMMAND
, NULL
);
178 self
->priv
->path
= g_strdup (path
);
184 svn_log_command_destroy (SvnLogCommand
*self
)
186 g_object_unref (self
);
190 svn_log_command_get_entry_queue (SvnLogCommand
*self
)
192 return self
->priv
->log_entry_queue
;