3 Pango = imports.gi.Pango;
4 GLib = imports.gi.GLib;
6 GObject = imports.gi.GObject;
7 GtkSource = imports.gi.GtkSource;
8 WebKit = imports.gi.WebKit;
10 console = imports.console;
11 XObject = imports.XObject.XObject;
15 destroy_event : function (self, event) {
19 response : function (self, id) {
25 if (typeof(this.get('bug').getValue()) != 'object') {
32 //var val = this.get('bug').getValue();
49 //this.el.set_title("Merger - ??? ");
50 // this.el.set_title("Merger - " + this.repo.repopath);
53 Merger.loading = true; // stop change firing on combos.
56 this.get('/historyTreeStore').el.clear();
57 this.get('/changedFilesStore').el.clear();
58 this.get('/patchview').clear();
62 this.get('/workingCombo').load(Merger.repo.branches);
64 this.get('/releaseCombo').load(Merger.repo.branches);
69 Merger.loading = false;
72 //this.get('/ok_button').el.set_sensitive(false);
74 // block until we return.
75 var run_ret = this.el.run();
79 print("RUN RETURN : " + run_ret);
81 //print(JSON.stringify(this.get('bug').getValue()));
82 // return this.get('bug').getValue();
83 //this.success = c.success;
88 pack : function(p,e) {
89 p.el.get_content_area().pack_start(e.el,true,true,0)
94 pack : "pack_start,false,true",
98 label : "Working Branch"
103 changed : function (self) {
104 this.get('/historyTreeStore').loadTree();
109 this.el = new Gtk.ComboBox.with_entry();
112 this.model = new XObject(this.model);
114 this.el.set_model(this.model.el);
115 this.el.set_entry_text_column (0);
116 XObject.prototype.init.call(this);
121 //this.insert(citer,iter,0);
122 this.model.el.clear();
127 for(var i =0 ; i < tr.length; i++) {
128 if (!tr[i].name.length) {
132 this.model.el.append(ret);
133 //print(JSON.stringify(ret,null,4));
134 if (tr[i].name == 'master') {
137 if (tr[i].name == 'working') {
140 this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
141 this.model.el.set_value(ret.iter, 1, '' + tr[i].rev );
145 if (master !== false) {
146 this.el.set_active(master);
148 if (working !== false) {
149 this.el.set_active(working);
154 xtype: Gtk.ListStore,
156 XObject.prototype.init.call(this);
157 this.el.set_column_types ( 3, [
158 GObject.TYPE_STRING, // file
159 GObject.TYPE_STRING, // added
160 GObject.TYPE_STRING, // removed
167 label : "Release Branch"
172 changed : function (self) {
173 this.get('/historyTreeStore').loadTree();
178 this.el = new Gtk.ComboBox.with_entry();
181 this.model = new XObject(this.model);
183 this.el.set_model(this.model.el);
184 this.el.set_entry_text_column (0);
185 XObject.prototype.init.call(this);
190 //this.insert(citer,iter,0);
191 this.model.el.clear();
196 for(var i =0 ; i < tr.length; i++) {
198 if (!tr[i].name.length) {
202 this.model.el.append(ret);
203 //print(JSON.stringify(ret,null,4));
204 if (tr[i].name == 'master') {
207 if (tr[i].name == 'release') {
211 this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
212 this.model.el.set_value(ret.iter, 1, '' + tr[i].rev );
216 if (master !== false) {
217 this.el.set_active(master);
219 if (release !== false) {
220 this.el.set_active(release);
225 xtype: Gtk.ListStore,
227 XObject.prototype.init.call(this);
228 this.el.set_column_types ( 3, [
229 GObject.TYPE_STRING, // file
230 GObject.TYPE_STRING, // added
231 GObject.TYPE_STRING, // removed
240 pack : "pack_end,true,true,0",
249 xtype: Gtk.ScrolledWindow,
251 XObject.prototype.init.call(this);
252 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
258 cursor_changed : function (self) {
260 if (this.el.get_selection().count_selected_rows() < 1) {
264 var model = this.get('/historyTreeStore');
266 var s = this.el.get_selection();
269 var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
270 print("OUT?" + value);// id..
271 // load the list in the right grid..
272 var Repo = imports.Scm.Git.Repo.Repo;
276 if (model.release === false) {
281 var files = Merger.repo.changedFiles('/', 'rev', model.release + '..' + value);
282 this.get('/changedFilesStore').load(files);
289 XObject.prototype.init.call(this);
290 var description = new Pango.FontDescription.c_new();
291 description.set_size(8000);
292 this.el.modify_font(description);
294 this.selection = this.el.get_selection();
295 this.selection.set_mode( Gtk.SelectionMode.SINGLE);
299 781 // is this really needed??
300 782 this.selection.signal['changed'].connect(function() {
301 783 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
302 784 _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
310 xtype: Gtk.TreeStore,
311 id : "historyTreeStore",
315 XObject.prototype.init.call(this);
316 this.el.set_column_types ( 3, [
317 GObject.TYPE_STRING, // title
318 GObject.TYPE_STRING, // rev
321 load : function(tr,iter)
323 //this.insert(citer,iter,0);
328 for(var i =0 ; i < tr.length; i++) {
331 this.el.insert(ret ,iter,-1);
335 //print(JSON.stringify(ret,null,4));
338 this.el.set_value(ret.iter, 0, '' + tr[i].text );
339 this.el.set_value(ret.iter, 1, '' + tr[i].rev );
341 if (tr[i].children && tr[i].children.length) {
342 this.load(tr[i].children, ret.iter);
346 loadTree : function() {
348 this.working = false;
349 if (Merger.loading) {
354 var wid = this.get('/workingCombo').el.get_active();
355 var rid = this.get('/releaseCombo').el.get_active();
356 if (wid < 0 || rid < 0 || rid == wid) {
360 var w = Merger.repo.branches[wid];
361 var r = Merger.repo.branches[rid];
365 var rev = r.name + '..' + w.name;
366 this.release = r.name;
368 // this takes some time, lets. try and dialog it..
373 var msg = new Gtk.MessageDialog( {
374 buttons : Gtk.ButtonsType.NONE,
375 text: "Loading History"
379 msg.set_transient_for(Merger.el);
383 var hist = Merger.repo.dayTree('/', false, 'rev', rev);
392 xtype: Gtk.TreeViewColumn,
393 pack : "append_column",
396 XObject.prototype.init.call(this);
397 this.el.add_attribute(this.items[0].el , 'markup', 0 );
402 xtype: Gtk.CellRendererText,
412 xtype: Gtk.ScrolledWindow,
414 XObject.prototype.init.call(this);
415 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
421 cursor_changed : function (self) {
422 // SEE SELECTION.CHANGED
423 var files = this.files();
424 this.get('/patchview').showDiff(files);
425 //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
426 //print("OUT?" + value);// id..
427 // load the list in the right grid..
433 id : "changedFilesView",
436 if (this.el.get_selection().count_selected_rows() < 1) {
437 //nothing? - clea it?
444 var s = this.el.get_selection();
446 s.selected_foreach(function(model,p,iter) {
448 files.push( model.get_value(iter, 0).value.get_string());
454 XObject.prototype.init.call(this);
455 var description = new Pango.FontDescription.c_new();
456 description.set_size(8000);
457 this.el.modify_font(description);
459 this.selection = this.el.get_selection();
460 this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
462 this.selection.signal['changed'].connect(function() {
463 _this.listeners.cursor_changed.apply(
470 xtype: Gtk.ListStore,
471 id : "changedFilesStore",
474 XObject.prototype.init.call(this);
475 this.el.set_column_types ( 3, [
476 GObject.TYPE_STRING, // file
477 GObject.TYPE_STRING, // added
478 GObject.TYPE_STRING, // removed
483 //this.insert(citer,iter,0);
485 for(var i =0 ; i < tr.length; i++) {
490 //print(JSON.stringify(ret,null,4));
493 this.el.set_value(ret.iter, 0, '' + tr[i].filename );
494 this.el.set_value(ret.iter, 1, '' + tr[i].added );
495 this.el.set_value(ret.iter, 2, '' + tr[i].removed );
502 xtype: Gtk.TreeViewColumn,
505 pack : "append_column",
508 XObject.prototype.init.call(this);
509 this.el.add_attribute(this.items[0].el , 'markup', 0 );
514 xtype: Gtk.CellRendererText,
520 xtype: Gtk.TreeViewColumn,
522 pack : "append_column",
525 XObject.prototype.init.call(this);
526 this.el.add_attribute(this.items[0].el , 'markup', 1 );
531 xtype: Gtk.CellRendererText,
537 xtype: Gtk.TreeViewColumn,
539 pack : "append_column",
542 XObject.prototype.init.call(this);
543 this.el.add_attribute(this.items[0].el , 'markup', 2 );
548 xtype: Gtk.CellRendererText,
560 xtype: Gtk.ListStore,
574 pack : "pack_start,false,false,0",
579 clicked : function (self) {
582 var model = this.get('/historyTreeStore');
584 if (model.release === false) {
589 var files = this.get('/changedFilesView').files();
594 var diff = Merger.repo.diff(files, model.release, model.rev);
600 var history = Merger.repo.history(files, 1, 'rev', model.rev);
602 print("History" + JSON.stringify(history, null,4));
604 Commit = imports.Commit.Commit;
606 Commit.el.set_modal(true);
607 Commit.el.set_transient_for(Merger.el);
609 var ce = Commit.show({
612 release : model.release,
614 author : history[0].changeby,
615 changed : history[0].changed_raw
624 var diff = Merger.repo.diff(files, model.release, model.rev);
627 print(JSON.stringify(ce,null,4));
630 imports.gitlive.monitor.pause();
632 Merger.repo.checkout(model.release);
634 Merger.repo.applyPatch(diff);
636 var author = Merger.repo.parseAuthor(ce.author);
638 // add all the files..
639 Merger.repo.add(files);
642 email : author.email,
644 changed : ce.changed,
649 Merger.repo.checkout(model.working);
651 imports.gitlive.monitor.resume();
662 label : "Commit diff (no merge)"
667 xtype: Gtk.ScrolledWindow,
668 pack : "pack_end,true,true,0",
670 XObject.prototype.init.call(this);
671 this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
675 xtype: WebKit.WebView,
684 var s = "document.body.textContent='';"
686 this.el.execute_script(s);
693 showDiff : function(files) {
697 var model = this.get('/historyTreeStore');
699 if (model.release === false) {
703 var diff = Merger.repo.diff(files, model.release, model.rev);
706 var s = "var pre = document.createElement('pre'); document.body.appendChild(pre);";
707 s += "pre.textContent = " +
708 JSON.stringify(Merger.repo.lastCmd + "\n") + '+ ' +
709 JSON.stringify(diff) + ";";
712 this.el.execute_script(s);
732 pack : "add_action_widget,1"
737 XObject.cache['/Merger'] = Merger;