~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/ngit/NGit/NGit.Api/SubmoduleUpdateCommand.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
97
97
                        return this;
98
98
                }
99
99
 
100
 
                /// <exception cref="NGit.Api.Errors.JGitInternalException"></exception>
 
100
                /// <summary>Execute the SubmoduleUpdateCommand command.</summary>
 
101
                /// <remarks>Execute the SubmoduleUpdateCommand command.</remarks>
 
102
                /// <returns>a collection of updated submodule paths</returns>
 
103
                /// <exception cref="NGit.Api.Errors.ConcurrentRefUpdateException">NGit.Api.Errors.ConcurrentRefUpdateException
 
104
                ///     </exception>
 
105
                /// <exception cref="NGit.Api.Errors.CheckoutConflictException">NGit.Api.Errors.CheckoutConflictException
 
106
                ///     </exception>
 
107
                /// <exception cref="NGit.Api.Errors.InvalidMergeHeadsException">NGit.Api.Errors.InvalidMergeHeadsException
 
108
                ///     </exception>
 
109
                /// <exception cref="NGit.Api.Errors.InvalidConfigurationException">NGit.Api.Errors.InvalidConfigurationException
 
110
                ///     </exception>
 
111
                /// <exception cref="NGit.Api.Errors.NoHeadException">NGit.Api.Errors.NoHeadException
 
112
                ///     </exception>
 
113
                /// <exception cref="NGit.Api.Errors.NoMessageException">NGit.Api.Errors.NoMessageException
 
114
                ///     </exception>
 
115
                /// <exception cref="NGit.Api.Errors.RefNotFoundException">NGit.Api.Errors.RefNotFoundException
 
116
                ///     </exception>
 
117
                /// <exception cref="NGit.Api.Errors.WrongRepositoryStateException">NGit.Api.Errors.WrongRepositoryStateException
 
118
                ///     </exception>
 
119
                /// <exception cref="NGit.Api.Errors.GitAPIException">NGit.Api.Errors.GitAPIException
 
120
                ///     </exception>
101
121
                public override ICollection<string> Call()
102
122
                {
103
123
                        CheckCallable();
136
156
                                                }
137
157
                                                submoduleRepo = clone.Call().GetRepository();
138
158
                                        }
139
 
                                        RevWalk walk = new RevWalk(submoduleRepo);
140
 
                                        RevCommit commit = walk.ParseCommit(generator.GetObjectId());
141
 
                                        string update = generator.GetConfigUpdate();
142
 
                                        if (ConfigConstants.CONFIG_KEY_MERGE.Equals(update))
143
 
                                        {
144
 
                                                MergeCommand merge = new MergeCommand(submoduleRepo);
145
 
                                                merge.Include(commit);
146
 
                                                merge.Call();
147
 
                                        }
148
 
                                        else
149
 
                                        {
150
 
                                                if (ConfigConstants.CONFIG_KEY_REBASE.Equals(update))
 
159
                                        try
 
160
                                        {
 
161
                                                RevWalk walk = new RevWalk(submoduleRepo);
 
162
                                                RevCommit commit = walk.ParseCommit(generator.GetObjectId());
 
163
                                                string update = generator.GetConfigUpdate();
 
164
                                                if (ConfigConstants.CONFIG_KEY_MERGE.Equals(update))
151
165
                                                {
152
 
                                                        RebaseCommand rebase = new RebaseCommand(submoduleRepo);
153
 
                                                        rebase.SetUpstream(commit);
154
 
                                                        rebase.Call();
 
166
                                                        MergeCommand merge = new MergeCommand(submoduleRepo);
 
167
                                                        merge.Include(commit);
 
168
                                                        merge.Call();
155
169
                                                }
156
170
                                                else
157
171
                                                {
158
 
                                                        // Checkout commit referenced in parent repository's index
159
 
                                                        // as a detached HEAD
160
 
                                                        DirCacheCheckout co = new DirCacheCheckout(submoduleRepo, submoduleRepo.LockDirCache
161
 
                                                                (), commit.Tree);
162
 
                                                        co.SetFailOnConflict(true);
163
 
                                                        co.Checkout();
164
 
                                                        RefUpdate refUpdate = submoduleRepo.UpdateRef(Constants.HEAD, true);
165
 
                                                        refUpdate.SetNewObjectId(commit);
166
 
                                                        refUpdate.ForceUpdate();
 
172
                                                        if (ConfigConstants.CONFIG_KEY_REBASE.Equals(update))
 
173
                                                        {
 
174
                                                                RebaseCommand rebase = new RebaseCommand(submoduleRepo);
 
175
                                                                rebase.SetUpstream(commit);
 
176
                                                                rebase.Call();
 
177
                                                        }
 
178
                                                        else
 
179
                                                        {
 
180
                                                                // Checkout commit referenced in parent repository's
 
181
                                                                // index as a detached HEAD
 
182
                                                                DirCacheCheckout co = new DirCacheCheckout(submoduleRepo, submoduleRepo.LockDirCache
 
183
                                                                        (), commit.Tree);
 
184
                                                                co.SetFailOnConflict(true);
 
185
                                                                co.Checkout();
 
186
                                                                RefUpdate refUpdate = submoduleRepo.UpdateRef(Constants.HEAD, true);
 
187
                                                                refUpdate.SetNewObjectId(commit);
 
188
                                                                refUpdate.ForceUpdate();
 
189
                                                        }
167
190
                                                }
168
191
                                        }
 
192
                                        finally
 
193
                                        {
 
194
                                                submoduleRepo.Close();
 
195
                                        }
169
196
                                        updated.AddItem(generator.GetPath());
170
197
                                }
171
198
                                return updated;
176
203
                        }
177
204
                        catch (ConfigInvalidException e)
178
205
                        {
179
 
                                throw new JGitInternalException(e.Message, e);
180
 
                        }
181
 
                        catch (GitAPIException e)
182
 
                        {
183
 
                                throw new JGitInternalException(e.Message, e);
 
206
                                throw new InvalidConfigurationException(e.Message, e);
184
207
                        }
185
208
                }
186
209
        }