~taktaktaktaktaktaktaktaktaktak/+junk/monodevelop-hg-2.4

« back to all changes in this revision

Viewing changes to MercurialCommands.cs

  • Committer: Levi Bard
  • Date: 2010-12-17 13:09:12 UTC
  • Revision ID: levi@unity3d.com-20101217130912-xd8ri4zhs7dq6bta
Rebase working.

Show diffs side-by-side

added added

removed removed

Lines of Context:
62
62
                Unbind,
63
63
                Uncommit,
64
64
                Export,
65
 
                Push
 
65
                Push,
 
66
                Rebase
66
67
        }
67
68
 
68
69
        /// <summary>
154
155
                                bsd.Destroy ();
155
156
                        }
156
157
                }// OnPull
 
158
 
 
159
                /// <summary>
 
160
                /// Determines whether a rebase can be performed.
 
161
                /// </summary>
 
162
                [CommandUpdateHandler (MercurialCommands.Rebase)]
 
163
                protected void CanRebase (CommandInfo item)
 
164
                {
 
165
                        CanPull (item);
 
166
                }// CanRebase
 
167
 
 
168
                /// <summary>
 
169
                /// Performs a pull.
 
170
                /// </summary>
 
171
                [CommandHandler (MercurialCommands.Rebase)]
 
172
                protected void OnRebase()
 
173
                {
 
174
                        VersionControlItem vcitem = GetItems ()[0];
 
175
                        MercurialRepository repo = ((MercurialRepository)vcitem.Repository);
 
176
                        Dictionary<string, BranchType> branches = repo.GetKnownBranches (vcitem.Path);
 
177
                        string   defaultBranch = string.Empty,
 
178
                                 localPath = vcitem.IsDirectory? (string)vcitem.Path.FullPath: Path.GetDirectoryName (vcitem.Path.FullPath);
 
179
 
 
180
                        foreach (KeyValuePair<string, BranchType> branch in branches) {
 
181
                                if (BranchType.Parent == branch.Value) {
 
182
                                        defaultBranch = branch.Key;
 
183
                                        break;
 
184
                                }
 
185
                        }// check for parent branch
 
186
 
 
187
                        Dialogs.BranchSelectionDialog bsd = new Dialogs.BranchSelectionDialog (branches.Keys, defaultBranch, localPath, false, true, true, false);
 
188
                        try {
 
189
                                if ((int)Gtk.ResponseType.Ok == bsd.Run () && !string.IsNullOrEmpty (bsd.SelectedLocation)) {
 
190
                                        MercurialTask worker = new MercurialTask ();
 
191
                                        worker.Description = string.Format ("Rebasing on {0}", bsd.SelectedLocation);
 
192
                                        worker.Operation = delegate{ repo.Rebase (bsd.SelectedLocation, vcitem.Path, bsd.SaveDefault, bsd.Overwrite, worker.ProgressMonitor); };
 
193
                                        worker.Start ();
 
194
                                }
 
195
                        } finally {
 
196
                                bsd.Destroy ();
 
197
                        }
 
198
                }// OnRebase
157
199
                
158
200
                /// <summary>
159
201
                /// Determines whether a merge can be performed.