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-merge-command.h"
27 struct _SvnMergeCommandPriv
35 gboolean ignore_ancestry
;
40 G_DEFINE_TYPE (SvnMergeCommand
, svn_merge_command
, SVN_TYPE_COMMAND
);
43 svn_merge_command_init (SvnMergeCommand
*self
)
45 self
->priv
= g_new0 (SvnMergeCommandPriv
, 1);
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
);
60 G_OBJECT_CLASS (svn_merge_command_parent_class
)->finalize (object
);
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
;
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
;
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
;
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
,
95 self
->priv
->target_path
,
96 self
->priv
->recursive
,
97 self
->priv
->ignore_ancestry
,
101 svn_command_get_client_context (svn_command
),
102 svn_command_get_pool (svn_command
));
106 svn_command_set_error (svn_command
, error
);
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
;
124 svn_merge_command_new (const gchar
*path1
,
126 glong start_revision
,
128 const gchar
*target_path
,
130 gboolean ignore_ancestry
,
134 SvnMergeCommand
*self
;
136 self
= g_object_new (SVN_TYPE_MERGE_COMMAND
, NULL
);
137 self
->priv
->path1
= svn_command_make_canonical_path (SVN_COMMAND (self
),
139 self
->priv
->path2
= svn_command_make_canonical_path (SVN_COMMAND (self
),
141 self
->priv
->start_revision
= start_revision
;
142 self
->priv
->end_revision
= end_revision
;
143 self
->priv
->target_path
= svn_command_make_canonical_path (SVN_COMMAND (self
),
145 self
->priv
->recursive
= recursive
;
146 self
->priv
->ignore_ancestry
= ignore_ancestry
;
147 self
->priv
->force
= force
;
148 self
->priv
->dry_run
= dry_run
;
154 svn_merge_command_destroy (SvnMergeCommand
*self
)
156 g_object_unref (self
);