revert bad commits
authorAlan Knowles <alan@akbkhome.com>
Thu, 15 Sep 2011 02:17:17 +0000 (10:17 +0800)
committerAlan Knowles <alan@akbkhome.com>
Thu, 15 Sep 2011 02:17:17 +0000 (10:17 +0800)
Clones.bjs [new file with mode: 0644]
Clones.js [new file with mode: 0644]
Commit.bjs [new file with mode: 0644]
Commit.js [new file with mode: 0644]
Merger.bjs [new file with mode: 0644]
Merger.js [new file with mode: 0644]
Monitor.js [new file with mode: 0644]
Scm/Git/Repo.js [new file with mode: 0644]
Scm/Repo.js [new file with mode: 0644]

diff --git a/Clones.bjs b/Clones.bjs
new file mode 100644 (file)
index 0000000..1f08553
--- /dev/null
@@ -0,0 +1,234 @@
+{
+    "id": "file-gtk-2",
+    "name": "Clones",
+    "parent": "",
+    "title": false,
+    "path": "/home/alan/gitlive/gitlive/Clones.bjs",
+    "items": [
+        {
+            "listeners": {
+                "destroy_event": "function (self, event) {\n      print(\"DESTROY?!\");\n     return true;\n}",
+                "response": "function (self, id) {\n  // hide\n     //if (id < 1) {\n        this.el.hide();\n        return;\n    //}\n    if (typeof(this.get('bug').getValue()) != 'object') {\n        print(\"ERROR\");\n        return;\n    }\n \n    this.el.hide();\n        \n    //var val = this.get('bug').getValue();\n     //   Seed.print(val);\n}"
+            },
+            "border_width": 3,
+            "default_height": 500,
+            "default_width": 600,
+            "title": "Manage Clones",
+            "xtype": "Dialog",
+            "|deletable": "true",
+            "|modal": "true",
+            "|show": "function(c) {\n    \n    if (!this.el) {\n        this.init();\n    }\n    var _this = this;\n    /*[ 'xtype'  ].forEach(function(k) {\n        _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]);\n    });\n\t// shouild set path..\n    */\n    this.el.set_deletable(false);\n    this.el.show_all();\n    // load clones..\n        this.get('/reposStore').load();\n    \n    //this.get('/ok_button').el.set_sensitive(false);\n    \n    // block until we return.\n    var run_ret = this.el.run();\n    if (run_ret < 1 ) {\n        return  \"DONE\";\n    }\n    print(\"RUN RETURN : \" + run_ret);\n    return \"DONE\";\n    //print(JSON.stringify(this.get('bug').getValue()));\n   // return this.get('bug').getValue();\n    //this.success = c.success;\n}\n",
+            "|xns": "Gtk",
+            "items": [
+                {
+                    "id": "Clones",
+                    "xtype": "VBox",
+                    "|pack": " function(p,e) {\n        p.el.get_content_area().pack_start(e.el,true,true,0)\n    }\n",
+                    "|xns": "Gtk",
+                    "items": [
+                        {
+                            "pack": "pack_start,false,true",
+                            "xtype": "HBox",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "listeners": {
+                                        "clicked": "function (self) {\n\n    var rv = this.get('/reposView');\n    var rs = this.get('/reposStore');\n    if (rv.el.get_selection().count_selected_rows() != 1) {\n        //nothing?\n        // error condition.\n        return;\n    }\n    var Remotes =     imports.Remotes.Remotes;\n    \n \n    var ret = {};       \n    var s = rv.el.get_selection();\n    var path = '';\n    s.selected_foreach(function(model,p,iter) {\n                                                    \n       path = model.get_value(iter, 6).value.get_string();\n     \n    }); \n\n    var repo = false;\n    rs.repos.forEach(function(r) {\n        if (r.repopath == path) {\n            repo = r;\n        \n        }\n    \n    });\n    Remotes.repo = repo;\n    Remotes.el.set_transient_for(Clones.el);\n    Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n    Remotes.show();\n    Clones.el.set_title(\"Manage Clones\");\n\n     \n    \n    \n    \n\n       \n    \n    \n}"
+                                    },
+                                    "label": "Remotes / Clones",
+                                    "pack": "add",
+                                    "xtype": "Button",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "listeners": {
+                                        "clicked": "function (self) {\n\n    var rv = this.get('/reposView');\n    var rs = this.get('/reposStore');\n    if (rv.el.get_selection().count_selected_rows() != 1) {\n        //nothing?\n        // error condition.\n        return;\n    }\n    var Branches =     imports.Branches.Branches;\n    \n \n    var ret = {};       \n    var s = rv.el.get_selection();\n    var path = '';\n    s.selected_foreach(function(model,p,iter) {\n                                                    \n       path = model.get_value(iter, 6).value.get_string();\n     \n    }); \n\n    var repo = false;\n    rs.repos.forEach(function(r) {\n        if (r.repopath == path) {\n            repo = r;\n        \n        }\n    \n    });\n    Branches.repo = repo;\n    Branches.el.set_transient_for(Clones.el);\n    Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n    Branches.show();\n    Clones.el.set_title(\"Manage Clones\");\n\n     \n    \n    \n    \n\n       \n    \n    \n}"
+                                    },
+                                    "label": "Branches",
+                                    "pack": "add",
+                                    "xtype": "Button",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "listeners": {
+                                        "clicked": "function (self) {\n\n    var rv = this.get('/reposView');\n    var rs = this.get('/reposStore');\n    if (rv.el.get_selection().count_selected_rows() != 1) {\n        //nothing?\n        // error condition.\n        return;\n    }\n    var Merger =     imports.Merger.Merger;\n    \n \n    var ret = {};       \n    var s = rv.el.get_selection();\n    var path = '';\n    s.selected_foreach(function(model,p,iter) {\n                                                    \n       path = model.get_value(iter, 6).value.get_string();\n     \n    }); \n\n    var repo = false;\n    rs.repos.forEach(function(r) {\n        if (r.repopath == path) {\n            repo = r;\n        \n        }\n    \n    });\n    Merger.repo = repo;\n    Merger.el.set_transient_for(Clones.el);\n    Clones.el.set_title(\"Manage Clones - \" + repo.repopath);\n    Merger.show();\n    Clones.el.set_title(\"Manage Clones\");\n\n    \n    \n\n    \n\n    \n    \n    \n    \n\n       \n    \n    \n}"
+                                    },
+                                    "label": "Run Merger",
+                                    "pack": "add",
+                                    "xtype": "Button",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "listeners": {
+                                        "clicked": "function (self) {\n    \n    \n \n       \n    \n    \n}"
+                                    },
+                                    "label": "Switch Branch",
+                                    "pack": "add",
+                                    "xtype": "Button",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "listeners": {
+                                        "clicked": "function (self) {\n    \n    \n \n       \n    \n    \n}"
+                                    },
+                                    "label": "Pull",
+                                    "pack": "add",
+                                    "xtype": "Button",
+                                    "|xns": "Gtk"
+                                }
+                            ]
+                        },
+                        {
+                            "xtype": "ScrolledWindow",
+                            "|init": "function() {\n    XObject.prototype.init.call(this);\n      this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "listeners": {
+                                        "cursor_changed": "function (self) {\n  // SEE SELECTION.CHANGED\n  \n  \n  return;\n  \n    if (this.el.get_selection().count_selected_rows() < 1) {\n        //nothing? - clea it?\n        return;\n    }\n        var ret = {};         \n    var model = this.get('/changedFilesStore');\n\n     var s = this.el.get_selection();\n     var files = [];\n    s.selected_foreach(function(model,p,iter) {\n    \n       files.push( model.get_value(iter, 0).value.get_string());\n     \n    });\n    this.get('/patchview').showDiff(files); \n    //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();\n     //print(\"OUT?\" + value);// id..\n    // load the list in the right grid..\n     \n    return true;\n\n}"
+                                    },
+                                    "id": "reposView",
+                                    "pack": "add",
+                                    "xtype": "TreeView",
+                                    "|init": "function() {\n    XObject.prototype.init.call(this);\n        var description = new Pango.FontDescription.c_new();\n   description.set_size(10000);\n     this.el.modify_font(description);\n\n     this.selection = this.el.get_selection();\n      this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);\n    var _this = this;\n    \n    \n  this.selection.signal['changed'].connect(function() {\n     _this.listeners.cursor_changed.apply(\n          _this, [ _this, '']\n       );\n             });\n  }\n",
+                                    "|xns": "Gtk",
+                                    "items": [
+                                        {
+                                            "id": "reposStore",
+                                            "pack": "set_model",
+                                            "xtype": "ListStore",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.set_column_types ( 8, [\n       GObject.TYPE_STRING, // repo  \n      GObject.TYPE_STRING, // current branch\n      GObject.TYPE_STRING, // all branch      \n      GObject.TYPE_STRING, // updated\n       GObject.TYPE_BOOLEAN, // auto-commit\n        GObject.TYPE_BOOLEAN, // auto-push\n           GObject.TYPE_STRING, // repopath\n           GObject.TYPE_STRING // color highighling \n  ] );\n}\n",
+                                            "|load": "function()\n{\n    //this.insert(citer,iter,0);\n    print(\"getting list\");\n    this.repos = imports.Scm.Repo.Repo.list();\n    var tr= this.repos;\n    this.el.clear();\n    \n    for(var i =0 ; i < tr.length; i++) {\n        var ret = {  };\n       \n        this.el.append(ret);\n        \n        //print(JSON.stringify(ret,null,4));\n         tr[i].getBranches();\n         var hi;\n         try {\n             //tr[i].debug=1;\n              hi = tr[i].history('/', 1, 'branch', tr[i].currentBranch.name );\n//             print(JSON.stringify(hi,null,4));\n         } catch(e) { print(e);}\n          \n        this.el.set_value(ret.iter, 0, '' +  tr[i].repopath.split('/').pop() );\n        this.el.set_value(ret.iter, 1, '' + tr[i].currentBranch.name   );\n        this.el.set_value(ret.iter, 2, '' + tr[i].branches.map(\n                        function(e) { return e.name; \n                    }).join(', ') \n         );\n        this.el.set_value(ret.iter, 3, '' +  (!hi  ? '??' : hi[0].changed_raw));        \n        this.el.set_value(ret.iter, 4, tr[i].autocommit() );                \n        this.el.set_value(ret.iter, 5, tr[i].autopush() );                        \n        this.el.set_value(ret.iter, 6,  tr[i].repopath );  \n        // highlight color.\n        var cb = tr[i].currentBranch;\n        //print(JSON.stringify(cb,null,4));\n        var col = cb.lastrev == cb.remoterev ? '#ffffff' : '#ff0000';\n        this.el.set_value(ret.iter, 7, col  );      \n        \n    }     \n}",
+                                            "|xns": "Gtk"
+                                        },
+                                        {
+                                            "min_width": 50,
+                                            "pack": "append_column",
+                                            "title": "Auto Commit",
+                                            "xtype": "TreeViewColumn",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'active', 4 );\n    this.items[0].el.set_activatable(true);\n\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "listeners": {
+                                                        "toggled": "function (self, path) {\n    var ret ={} ;\n    var store = this.get('/reposStore');\n    store.el.get_iter_from_string(ret, path);\n                                                                 \n    var value =   store.el.get_value(ret.iter,4).value.get_boolean();\n                                                                 \n    //print(JSON.stringify(value));\n    store.el.set_value(ret.iter,4, !value);\n    \n}"
+                                                    },
+                                                    "pack": "pack_start",
+                                                    "xtype": "CellRendererToggle",
+                                                    "|mode": "Gtk.CellRendererMode.ACTIVATABLE",
+                                                    "|xns": "Gtk"
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            "min_width": 50,
+                                            "pack": "append_column",
+                                            "title": "Auto Push",
+                                            "xtype": "TreeViewColumn",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'active', 5 );\n      this.items[0].el.set_activatable(true);\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "listeners": {
+                                                        "toggled": "function (self, path) {\n    var ret ={} ;\n    var store = this.get('/reposStore');\n    store.el.get_iter_from_string(ret, path);\n                                                                 \n    var value =   store.el.get_value(ret.iter,5).value.get_boolean();\n                                                                 \n    //print(JSON.stringify(value));\n    store.el.set_value(ret.iter,5, !value);\n    \n}"
+                                                    },
+                                                    "pack": "pack_start",
+                                                    "xtype": "CellRendererToggle",
+                                                    "|mode": "Gtk.CellRendererMode.ACTIVATABLE",
+                                                    "|xns": "Gtk"
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            "min_width": 200,
+                                            "pack": "append_column",
+                                            "resizable": true,
+                                            "title": "Repo",
+                                            "xtype": "TreeViewColumn",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 0 );\n\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "pack": "pack_start",
+                                                    "xtype": "CellRendererText",
+                                                    "|xns": "Gtk"
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            "min_width": 50,
+                                            "pack": "append_column",
+                                            "title": "Current Branch",
+                                            "xtype": "TreeViewColumn",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 1 );\n     this.el.add_attribute(this.items[0].el , 'cell-background', 7 );\n\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "pack": "pack_start",
+                                                    "xtype": "CellRendererText",
+                                                    "|xns": "Gtk"
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            "min_width": 50,
+                                            "pack": "append_column",
+                                            "title": "Last updated",
+                                            "xtype": "TreeViewColumn",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 3 );\n\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "pack": "pack_start",
+                                                    "xtype": "CellRendererText",
+                                                    "|xns": "Gtk"
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            "min_width": 50,
+                                            "pack": "append_column",
+                                            "resizable": false,
+                                            "title": "All Branches",
+                                            "xtype": "TreeViewColumn",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 2 );\n\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "pack": "pack_start",
+                                                    "xtype": "CellRendererText",
+                                                    "|xns": "Gtk"
+                                                }
+                                            ]
+                                        }
+                                    ]
+                                },
+                                {
+                                    "|xns": "Gtk",
+                                    "xtype": "TreeView",
+                                    "pack": false,
+                                    "items": [
+                                        {
+                                            "|xns": "Gtk",
+                                            "xtype": "ListStore",
+                                            "pack": false
+                                        }
+                                    ]
+                                }
+                            ]
+                        }
+                    ]
+                },
+                {
+                    "id": "ok_button",
+                    "label": "Close",
+                    "pack": "add_action_widget,1",
+                    "xtype": "Button",
+                    "|xns": "Gtk"
+                }
+            ]
+        }
+    ],
+    "permname": "",
+    "modOrder": ""
+}
\ No newline at end of file
diff --git a/Clones.js b/Clones.js
new file mode 100644 (file)
index 0000000..553a8ad
--- /dev/null
+++ b/Clones.js
@@ -0,0 +1,549 @@
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+Pango = imports.gi.Pango;
+GLib = imports.gi.GLib;
+Gio = imports.gi.Gio;
+GObject = imports.gi.GObject;
+GtkSource = imports.gi.GtkSource;
+WebKit = imports.gi.WebKit;
+Vte = imports.gi.Vte;
+console = imports.console;
+XObject = imports.XObject.XObject;
+Clones=new XObject({
+    xtype: Gtk.Dialog,
+    listeners : {
+        destroy_event : function (self, event) {
+              print("DESTROY?!");
+             return true;
+        },
+        response : function (self, id) {
+          // hide
+             //if (id < 1) {
+                this.el.hide();
+                return;
+            //}
+            if (typeof(this.get('bug').getValue()) != 'object') {
+                print("ERROR");
+                return;
+            }
+         
+            this.el.hide();
+                
+            //var val = this.get('bug').getValue();
+             //   Seed.print(val);
+        }
+    },
+    border_width : 3,
+    default_height : 500,
+    default_width : 600,
+    title : "Manage Clones",
+    deletable : true,
+    modal : true,
+    show : function(c) {
+        
+        if (!this.el) {
+            this.init();
+        }
+        var _this = this;
+        /*[ 'xtype'  ].forEach(function(k) {
+            _this.get(k).setValue(typeof(c[k]) == 'undefined' ? '' : c[k]);
+        });
+       // shouild set path..
+        */
+        this.el.set_deletable(false);
+        this.el.show_all();
+        // load clones..
+            this.get('/reposStore').load();
+        
+        //this.get('/ok_button').el.set_sensitive(false);
+        
+        // block until we return.
+        var run_ret = this.el.run();
+        if (run_ret < 1 ) {
+            return  "DONE";
+        }
+        print("RUN RETURN : " + run_ret);
+        return "DONE";
+        //print(JSON.stringify(this.get('bug').getValue()));
+       // return this.get('bug').getValue();
+        //this.success = c.success;
+    },
+    items : [
+        {
+            xtype: Gtk.VBox,
+            id : "Clones",
+            pack : function(p,e) {
+                    p.el.get_content_area().pack_start(e.el,true,true,0)
+                },
+            items : [
+                {
+                    xtype: Gtk.HBox,
+                    pack : "pack_start,false,true",
+                    items : [
+                        {
+                            xtype: Gtk.Button,
+                            listeners : {
+                                clicked : function (self) {
+                                
+                                    var rv = this.get('/reposView');
+                                    var rs = this.get('/reposStore');
+                                    if (rv.el.get_selection().count_selected_rows() != 1) {
+                                        //nothing?
+                                        // error condition.
+                                        return;
+                                    }
+                                    var Remotes =     imports.Remotes.Remotes;
+                                    
+                                 
+                                    var ret = {};       
+                                    var s = rv.el.get_selection();
+                                    var path = '';
+                                    s.selected_foreach(function(model,p,iter) {
+                                                                                    
+                                       path = model.get_value(iter, 6).value.get_string();
+                                     
+                                    }); 
+                                
+                                    var repo = false;
+                                    rs.repos.forEach(function(r) {
+                                        if (r.repopath == path) {
+                                            repo = r;
+                                        
+                                        }
+                                    
+                                    });
+                                    Remotes.repo = repo;
+                                    Remotes.el.set_transient_for(Clones.el);
+                                    Clones.el.set_title("Manage Clones - " + repo.repopath);
+                                    Remotes.show();
+                                    Clones.el.set_title("Manage Clones");
+                                
+                                     
+                                    
+                                    
+                                    
+                                
+                                       
+                                    
+                                    
+                                }
+                            },
+                            label : "Remotes / Clones",
+                            pack : "add"
+                        },
+                        {
+                            xtype: Gtk.Button,
+                            listeners : {
+                                clicked : function (self) {
+                                
+                                    var rv = this.get('/reposView');
+                                    var rs = this.get('/reposStore');
+                                    if (rv.el.get_selection().count_selected_rows() != 1) {
+                                        //nothing?
+                                        // error condition.
+                                        return;
+                                    }
+                                    var Branches =     imports.Branches.Branches;
+                                    
+                                 
+                                    var ret = {};       
+                                    var s = rv.el.get_selection();
+                                    var path = '';
+                                    s.selected_foreach(function(model,p,iter) {
+                                                                                    
+                                       path = model.get_value(iter, 6).value.get_string();
+                                     
+                                    }); 
+                                
+                                    var repo = false;
+                                    rs.repos.forEach(function(r) {
+                                        if (r.repopath == path) {
+                                            repo = r;
+                                        
+                                        }
+                                    
+                                    });
+                                    Branches.repo = repo;
+                                    Branches.el.set_transient_for(Clones.el);
+                                    Clones.el.set_title("Manage Clones - " + repo.repopath);
+                                    Branches.show();
+                                    Clones.el.set_title("Manage Clones");
+                                
+                                     
+                                    
+                                    
+                                    
+                                
+                                       
+                                    
+                                    
+                                }
+                            },
+                            label : "Branches",
+                            pack : "add"
+                        },
+                        {
+                            xtype: Gtk.Button,
+                            listeners : {
+                                clicked : function (self) {
+                                
+                                    var rv = this.get('/reposView');
+                                    var rs = this.get('/reposStore');
+                                    if (rv.el.get_selection().count_selected_rows() != 1) {
+                                        //nothing?
+                                        // error condition.
+                                        return;
+                                    }
+                                    var Merger =     imports.Merger.Merger;
+                                    
+                                 
+                                    var ret = {};       
+                                    var s = rv.el.get_selection();
+                                    var path = '';
+                                    s.selected_foreach(function(model,p,iter) {
+                                                                                    
+                                       path = model.get_value(iter, 6).value.get_string();
+                                     
+                                    }); 
+                                
+                                    var repo = false;
+                                    rs.repos.forEach(function(r) {
+                                        if (r.repopath == path) {
+                                            repo = r;
+                                        
+                                        }
+                                    
+                                    });
+                                    Merger.repo = repo;
+                                    Merger.el.set_transient_for(Clones.el);
+                                    Clones.el.set_title("Manage Clones - " + repo.repopath);
+                                    Merger.show();
+                                    Clones.el.set_title("Manage Clones");
+                                
+                                    
+                                    
+                                
+                                    
+                                
+                                    
+                                    
+                                    
+                                    
+                                
+                                       
+                                    
+                                    
+                                }
+                            },
+                            label : "Run Merger",
+                            pack : "add"
+                        },
+                        {
+                            xtype: Gtk.Button,
+                            listeners : {
+                                clicked : function (self) {
+                                    
+                                    
+                                 
+                                       
+                                    
+                                    
+                                }
+                            },
+                            label : "Switch Branch",
+                            pack : "add"
+                        },
+                        {
+                            xtype: Gtk.Button,
+                            listeners : {
+                                clicked : function (self) {
+                                    
+                                    
+                                 
+                                       
+                                    
+                                    
+                                }
+                            },
+                            label : "Pull",
+                            pack : "add"
+                        }
+                    ]
+                },
+                {
+                    xtype: Gtk.ScrolledWindow,
+                    init : function() {
+                        XObject.prototype.init.call(this);
+                          this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+                    },
+                    items : [
+                        {
+                            xtype: Gtk.TreeView,
+                            listeners : {
+                                cursor_changed : function (self) {
+                                  // SEE SELECTION.CHANGED
+                                  
+                                  
+                                  return;
+                                  
+                                    if (this.el.get_selection().count_selected_rows() < 1) {
+                                        //nothing? - clea it?
+                                        return;
+                                    }
+                                        var ret = {};         
+                                    var model = this.get('/changedFilesStore');
+                                
+                                     var s = this.el.get_selection();
+                                     var files = [];
+                                    s.selected_foreach(function(model,p,iter) {
+                                    
+                                       files.push( model.get_value(iter, 0).value.get_string());
+                                     
+                                    });
+                                    this.get('/patchview').showDiff(files); 
+                                    //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
+                                     //print("OUT?" + value);// id..
+                                    // load the list in the right grid..
+                                     
+                                    return true;
+                                
+                                }
+                            },
+                            id : "reposView",
+                            pack : "add",
+                            init : function() {
+                                XObject.prototype.init.call(this);
+                                    var description = new Pango.FontDescription.c_new();
+                               description.set_size(10000);
+                                 this.el.modify_font(description);
+                            
+                                 this.selection = this.el.get_selection();
+                                  this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
+                                var _this = this;
+                                
+                                
+                              this.selection.signal['changed'].connect(function() {
+                                 _this.listeners.cursor_changed.apply(
+                                      _this, [ _this, '']
+                                   );
+                                         });
+                              },
+                            items : [
+                                {
+                                    xtype: Gtk.ListStore,
+                                    id : "reposStore",
+                                    pack : "set_model",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.set_column_types ( 8, [
+                                           GObject.TYPE_STRING, // repo  
+                                          GObject.TYPE_STRING, // current branch
+                                          GObject.TYPE_STRING, // all branch      
+                                          GObject.TYPE_STRING, // updated
+                                           GObject.TYPE_BOOLEAN, // auto-commit
+                                            GObject.TYPE_BOOLEAN, // auto-push
+                                               GObject.TYPE_STRING, // repopath
+                                               GObject.TYPE_STRING // color highighling 
+                                      ] );
+                                    },
+                                    load : function()
+                                    {
+                                        //this.insert(citer,iter,0);
+                                        print("getting list");
+                                        this.repos = imports.Scm.Repo.Repo.list();
+                                        var tr= this.repos;
+                                        this.el.clear();
+                                        
+                                        for(var i =0 ; i < tr.length; i++) {
+                                            var ret = {  };
+                                           
+                                            this.el.append(ret);
+                                            
+                                            //print(JSON.stringify(ret,null,4));
+                                             tr[i].getBranches();
+                                             var hi;
+                                             try {
+                                                 //tr[i].debug=1;
+                                                  hi = tr[i].history('/', 1, 'branch', tr[i].currentBranch.name );
+                                    //             print(JSON.stringify(hi,null,4));
+                                             } catch(e) { print(e);}
+                                              
+                                            this.el.set_value(ret.iter, 0, '' +  tr[i].repopath.split('/').pop() );
+                                            this.el.set_value(ret.iter, 1, '' + tr[i].currentBranch.name   );
+                                            this.el.set_value(ret.iter, 2, '' + tr[i].branches.map(
+                                                            function(e) { return e.name; 
+                                                        }).join(', ') 
+                                             );
+                                            this.el.set_value(ret.iter, 3, '' +  (!hi  ? '??' : hi[0].changed_raw));        
+                                            this.el.set_value(ret.iter, 4, tr[i].autocommit() );                
+                                            this.el.set_value(ret.iter, 5, tr[i].autopush() );                        
+                                            this.el.set_value(ret.iter, 6,  tr[i].repopath );  
+                                            // highlight color.
+                                            var cb = tr[i].currentBranch;
+                                            //print(JSON.stringify(cb,null,4));
+                                            var col = cb.lastrev == cb.remoterev ? '#ffffff' : '#ff0000';
+                                            this.el.set_value(ret.iter, 7, col  );      
+                                            
+                                        }     
+                                    }
+                                },
+                                {
+                                    xtype: Gtk.TreeViewColumn,
+                                    min_width : 50,
+                                    pack : "append_column",
+                                    title : "Auto Commit",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.add_attribute(this.items[0].el , 'active', 4 );
+                                        this.items[0].el.set_activatable(true);
+                                    
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.CellRendererToggle,
+                                            listeners : {
+                                                toggled : function (self, path) {
+                                                    var ret ={} ;
+                                                    var store = this.get('/reposStore');
+                                                    store.el.get_iter_from_string(ret, path);
+                                                                                                                 
+                                                    var value =   store.el.get_value(ret.iter,4).value.get_boolean();
+                                                                                                                 
+                                                    //print(JSON.stringify(value));
+                                                    store.el.set_value(ret.iter,4, !value);
+                                                    
+                                                }
+                                            },
+                                            pack : "pack_start",
+                                            mode : Gtk.CellRendererMode.ACTIVATABLE
+                                        }
+                                    ]
+                                },
+                                {
+                                    xtype: Gtk.TreeViewColumn,
+                                    min_width : 50,
+                                    pack : "append_column",
+                                    title : "Auto Push",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.add_attribute(this.items[0].el , 'active', 5 );
+                                          this.items[0].el.set_activatable(true);
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.CellRendererToggle,
+                                            listeners : {
+                                                toggled : function (self, path) {
+                                                    var ret ={} ;
+                                                    var store = this.get('/reposStore');
+                                                    store.el.get_iter_from_string(ret, path);
+                                                                                                                 
+                                                    var value =   store.el.get_value(ret.iter,5).value.get_boolean();
+                                                                                                                 
+                                                    //print(JSON.stringify(value));
+                                                    store.el.set_value(ret.iter,5, !value);
+                                                    
+                                                }
+                                            },
+                                            pack : "pack_start",
+                                            mode : Gtk.CellRendererMode.ACTIVATABLE
+                                        }
+                                    ]
+                                },
+                                {
+                                    xtype: Gtk.TreeViewColumn,
+                                    min_width : 200,
+                                    pack : "append_column",
+                                    resizable : true,
+                                    title : "Repo",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.add_attribute(this.items[0].el , 'markup', 0 );
+                                    
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.CellRendererText,
+                                            pack : "pack_start"
+                                        }
+                                    ]
+                                },
+                                {
+                                    xtype: Gtk.TreeViewColumn,
+                                    min_width : 50,
+                                    pack : "append_column",
+                                    title : "Current Branch",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.add_attribute(this.items[0].el , 'markup', 1 );
+                                         this.el.add_attribute(this.items[0].el , 'cell-background', 7 );
+                                    
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.CellRendererText,
+                                            pack : "pack_start"
+                                        }
+                                    ]
+                                },
+                                {
+                                    xtype: Gtk.TreeViewColumn,
+                                    min_width : 50,
+                                    pack : "append_column",
+                                    title : "Last updated",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.add_attribute(this.items[0].el , 'markup', 3 );
+                                    
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.CellRendererText,
+                                            pack : "pack_start"
+                                        }
+                                    ]
+                                },
+                                {
+                                    xtype: Gtk.TreeViewColumn,
+                                    min_width : 50,
+                                    pack : "append_column",
+                                    resizable : false,
+                                    title : "All Branches",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                        this.el.add_attribute(this.items[0].el , 'markup', 2 );
+                                    
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.CellRendererText,
+                                            pack : "pack_start"
+                                        }
+                                    ]
+                                }
+                            ]
+                        },
+                        {
+                            xtype: Gtk.TreeView,
+                            pack : false,
+                            items : [
+                                {
+                                    xtype: Gtk.ListStore,
+                                    pack : false
+                                }
+                            ]
+                        }
+                    ]
+                }
+            ]
+        },
+        {
+            xtype: Gtk.Button,
+            id : "ok_button",
+            label : "Close",
+            pack : "add_action_widget,1"
+        }
+    ]
+});
+Clones.init();
+XObject.cache['/Clones'] = Clones;
diff --git a/Commit.bjs b/Commit.bjs
new file mode 100644 (file)
index 0000000..b23e066
--- /dev/null
@@ -0,0 +1,161 @@
+{
+    "id": "file-gtk-3",
+    "name": "Commit",
+    "parent": "",
+    "title": false,
+    "path": "/home/alan/gitlive/gitlive/Commit.bjs",
+    "items": [
+        {
+            "listeners": {
+                "destroy_event": "function (self, event) {\n     this.el.hide();\n                return false;\n}",
+                "response": "function (self, id) {\n  // hide\n     //if (id < 1) {\n        this.el.hide();\n        return;\n    //}\n    if (typeof(this.get('bug').getValue()) != 'object') {\n        print(\"ERROR\");\n        return;\n    }\n \n    this.el.hide();\n        \n    //var val = this.get('bug').getValue();\n     //   Seed.print(val);\n}"
+            },
+            " modal": true,
+            "border_width": 3,
+            "default_height": 500,
+            "default_width": 800,
+            "title": "Commit",
+            "xtype": "Dialog",
+            "|deletable": "true",
+            "|modal": "true",
+            "|show": "function(c) {\n    \n    if (!this.el) {\n        this.init();\n    }\n    var _this = this;\n    \n    \n    this.files = c.files;\n    this.release = c.release;\n    this.rev = c.rev;\n    \n    this.repo = c.repo;\n\n    this.get('/commitDate').el.set_text(c.changed);\n    this.get('/commitAuthor').el.set_text(c.author);\n    this.get('/commitMsg').el.get_buffer().set_text('');\n    this.get('/commitPatch').showDiff(c.files);\n    \n    this.el.show_all();\n    \n    var run_ret = this.el.run();\n    if (run_ret < 1 ) {\n        return false;\n    }\n    var buf = this.get('/commitMsg').el.get_buffer();\n    var e = {};\n    var s = {};\n    buf.get_start_iter(s);\n    buf.get_end_iter(e);\n    var ret=  {\n        date :  this.get('/commitDate').el.get_text(),\n        author :  this.get('/commitAuthor').el.get_text(),\n        message : buf.get_text(s.value, e.value1, false)\n    };\n \n    return ret;\n    \n    \n    \n}\n",
+            "|xns": "Gtk",
+            "items": [
+                {
+                    "xtype": "VBox",
+                    "|pack": " function(p,e) {\n        p.el.get_content_area().pack_start(e.el,true,true,10);\n    }\n",
+                    "|xns": "Gtk",
+                    "items": [
+                        {
+                            "pack": "pack_start,false,true,2",
+                            "xtype": "HBox",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "label": "Fixes",
+                                    "pack": "pack_start,false,false,10",
+                                    "width_request": 50,
+                                    "xtype": "Label",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "listeners": {
+                                        "changed": "function (self) {\n   var val = this.el.get_child().get_text();\n   print(JSON.stringify(val));\n   if (!val.length) {\n       return;\n   }\n   \n   var name = this.get('/remoteName').el.get_text();\n   if (name.length) {\n       return;\n   }\n   // fill in name\n   var val = imports.Scm.Git.Repo.Repo.parseURL(val);\n   if ((typeof(val.host) != 'undefined') && val.host.length) {\n       var host = val.host;\n       // need to add github owner...\n        if (host.match(/github.com$/)) {\n          host += '.' + val.path.split('/').shift();\n        }\n   \n   \n        this.get('/remoteName').el.set_text(host);\n   }\n    \n   \n}"
+                                    },
+                                    "id": "commitFixes",
+                                    "xtype": "ComboBox",
+                                    "|init": "function() {\n    this.el = new Gtk.ComboBox.with_entry();\n    \n    \n    this.model  = new XObject(this.model);\n    this.model.init();\n    this.el.set_model(this.model.el);\n    this.el.set_entry_text_column (0);\n     XObject.prototype.init.call(this);\n    \n}\n",
+                                    "|load": "function(tr)\n{\n    //this.insert(citer,iter,0);\n    this.model.el.clear();\n    \n    var master = false;\n    var working = false;\n    \n    for(var i =0 ; i < tr.length; i++) {\n        var ret = {  };\n        this.model.el.append(ret);\n        //print(JSON.stringify(ret,null,4));\n        if (tr[i].name == 'master') {\n            master = i;\n        }\n        if (tr[i].name == 'working') {\n            working = i;\n        }          \n        this.model.el.set_value(ret.iter, 0, '' + tr[i].name );\n        this.model.el.set_value(ret.iter, 1, '' + tr[i].rev  );\n \n        \n    }     \n    if (master !== false) {\n        this.el.set_active(master);\n    }\n    if (working !== false) {\n        this.el.set_active(working);\n    }\n    \n}",
+                                    "|xns": "Gtk",
+                                    "items": [
+                                        {
+                                            "*prop": "model",
+                                            "xtype": "ListStore",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.set_column_types ( 3, [\n           GObject.TYPE_STRING, // file  \n          GObject.TYPE_STRING, // added\n          GObject.TYPE_STRING, // removed\n      ] );\n}\n",
+                                            "|xns": "Gtk"
+                                        }
+                                    ]
+                                }
+                            ]
+                        },
+                        {
+                            "pack": "pack_start,false,true,2",
+                            "xtype": "HBox",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "label": "Date",
+                                    "pack": "pack_start,false,false,10",
+                                    "width_request": 50,
+                                    "xalign": 1,
+                                    "xtype": "Label",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "id": "commitDate",
+                                    "xtype": "Entry",
+                                    "|xns": "Gtk"
+                                }
+                            ]
+                        },
+                        {
+                            "pack": "pack_start,false,true,2",
+                            "xtype": "HBox",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "label": "Author",
+                                    "pack": "pack_start,false,false,10",
+                                    "width_request": 50,
+                                    "xalign": 1,
+                                    "xtype": "Label",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "id": "commitAuthor",
+                                    "xtype": "Entry",
+                                    "|xns": "Gtk"
+                                }
+                            ]
+                        },
+                        {
+                            "pack": "pack_start,false,false,2",
+                            "xtype": "HBox",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "label": "Message",
+                                    "pack": "pack_start,false,false,10",
+                                    "width_request": 50,
+                                    "xalign": 1,
+                                    "xtype": "Label",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "height_request": 100,
+                                    "id": "commitMsg",
+                                    "pack": "add",
+                                    "xtype": "TextView",
+                                    "|xns": "Gtk"
+                                }
+                            ]
+                        },
+                        {
+                            "height_request": 200,
+                            "pack": "pack_end,true,true,0",
+                            "xtype": "ScrolledWindow",
+                            "|init": "function() {\n    XObject.prototype.init.call(this);\n      this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "id": "commitPatch",
+                                    "pack": "add",
+                                    "xtype": "WebView",
+                                    "|clear": "function() {\n    \n    \n    \n     \n   // remove..\n    var s  = \"document.body.textContent='';\"\n        \n    this.el.execute_script(s);\n        \n        \n    \n    \n    \n}\n",
+                                    "|showDiff": "function(files) {\n    this.clear();\n    \n    \n    \n    if (Commit.release === false) {\n        return;\n    }\n    \n    var diff = Commit.repo.diff(files, Commit.release, Commit.rev);\n    \n   // remove..\n    var s  = \"var pre  = document.createElement('pre'); document.body.appendChild(pre);\";\n    s += \"pre.textContent =  \" +\n             JSON.stringify(Commit.repo.lastCmd + \"\\n\") + '+  ' + \n             JSON.stringify(diff) + \";\";\n        \n    this.el.execute_script(s);\n        \n        \n    \n    \n    \n}\n",
+                                    "|xns": "WebKit"
+                                }
+                            ]
+                        }
+                    ]
+                },
+                {
+                    "label": "Cancel",
+                    "pack": "add_action_widget,0",
+                    "xtype": "Button",
+                    "|xns": "Gtk",
+                    "listeners": {}
+                },
+                {
+                    "id": "ok_button",
+                    "label": "Add",
+                    "pack": "add_action_widget,1",
+                    "xtype": "Button",
+                    "|xns": "Gtk"
+                }
+            ]
+        }
+    ],
+    "permname": "",
+    "modOrder": ""
+}
\ No newline at end of file
diff --git a/Commit.js b/Commit.js
new file mode 100644 (file)
index 0000000..3cdd749
--- /dev/null
+++ b/Commit.js
@@ -0,0 +1,312 @@
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+Pango = imports.gi.Pango;
+GLib = imports.gi.GLib;
+Gio = imports.gi.Gio;
+GObject = imports.gi.GObject;
+GtkSource = imports.gi.GtkSource;
+WebKit = imports.gi.WebKit;
+Vte = imports.gi.Vte;
+console = imports.console;
+XObject = imports.XObject.XObject;
+Commit=new XObject({
+    xtype: Gtk.Dialog,
+    listeners : {
+        destroy_event : function (self, event) {
+             this.el.hide();
+                        return false;
+        },
+        response : function (self, id) {
+          // hide
+             //if (id < 1) {
+                this.el.hide();
+                return;
+            //}
+            if (typeof(this.get('bug').getValue()) != 'object') {
+                print("ERROR");
+                return;
+            }
+         
+            this.el.hide();
+                
+            //var val = this.get('bug').getValue();
+             //   Seed.print(val);
+        }
+    },
+    ' modal' : true,
+    border_width : 3,
+    default_height : 500,
+    default_width : 800,
+    title : "Commit",
+    deletable : true,
+    modal : true,
+    show : function(c) {
+        
+        if (!this.el) {
+            this.init();
+        }
+        var _this = this;
+        
+        
+        this.files = c.files;
+        this.release = c.release;
+        this.rev = c.rev;
+        
+        this.repo = c.repo;
+    
+        this.get('/commitDate').el.set_text(c.changed);
+        this.get('/commitAuthor').el.set_text(c.author);
+        this.get('/commitMsg').el.get_buffer().set_text('');
+        this.get('/commitPatch').showDiff(c.files);
+        
+        this.el.show_all();
+        
+        var run_ret = this.el.run();
+        if (run_ret < 1 ) {
+            return false;
+        }
+        var buf = this.get('/commitMsg').el.get_buffer();
+        var e = {};
+        var s = {};
+        buf.get_start_iter(s);
+        buf.get_end_iter(e);
+        var ret=  {
+            date :  this.get('/commitDate').el.get_text(),
+            author :  this.get('/commitAuthor').el.get_text(),
+            message : buf.get_text(s.value, e.value1, false)
+        };
+     
+        return ret;
+        
+        
+        
+    },
+    items : [
+        {
+            xtype: Gtk.VBox,
+            pack : function(p,e) {
+                    p.el.get_content_area().pack_start(e.el,true,true,10);
+                },
+            items : [
+                {
+                    xtype: Gtk.HBox,
+                    pack : "pack_start,false,true,2",
+                    items : [
+                        {
+                            xtype: Gtk.Label,
+                            label : "Fixes",
+                            pack : "pack_start,false,false,10",
+                            width_request : 50
+                        },
+                        {
+                            xtype: Gtk.ComboBox,
+                            listeners : {
+                                changed : function (self) {
+                                   var val = this.el.get_child().get_text();
+                                   print(JSON.stringify(val));
+                                   if (!val.length) {
+                                       return;
+                                   }
+                                   
+                                   var name = this.get('/remoteName').el.get_text();
+                                   if (name.length) {
+                                       return;
+                                   }
+                                   // fill in name
+                                   var val = imports.Scm.Git.Repo.Repo.parseURL(val);
+                                   if ((typeof(val.host) != 'undefined') && val.host.length) {
+                                       var host = val.host;
+                                       // need to add github owner...
+                                        if (host.match(/github.com$/)) {
+                                          host += '.' + val.path.split('/').shift();
+                                        }
+                                   
+                                   
+                                        this.get('/remoteName').el.set_text(host);
+                                   }
+                                    
+                                   
+                                }
+                            },
+                            id : "commitFixes",
+                            init : function() {
+                                this.el = new Gtk.ComboBox.with_entry();
+                                
+                                
+                                this.model  = new XObject(this.model);
+                                this.model.init();
+                                this.el.set_model(this.model.el);
+                                this.el.set_entry_text_column (0);
+                                 XObject.prototype.init.call(this);
+                                
+                            },
+                            load : function(tr)
+                            {
+                                //this.insert(citer,iter,0);
+                                this.model.el.clear();
+                                
+                                var master = false;
+                                var working = false;
+                                
+                                for(var i =0 ; i < tr.length; i++) {
+                                    var ret = {  };
+                                    this.model.el.append(ret);
+                                    //print(JSON.stringify(ret,null,4));
+                                    if (tr[i].name == 'master') {
+                                        master = i;
+                                    }
+                                    if (tr[i].name == 'working') {
+                                        working = i;
+                                    }          
+                                    this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
+                                    this.model.el.set_value(ret.iter, 1, '' + tr[i].rev  );
+                             
+                                    
+                                }     
+                                if (master !== false) {
+                                    this.el.set_active(master);
+                                }
+                                if (working !== false) {
+                                    this.el.set_active(working);
+                                }
+                                
+                            },
+                            model : {
+                                xtype: Gtk.ListStore,
+                                init : function() {
+                                    XObject.prototype.init.call(this);
+                                    this.el.set_column_types ( 3, [
+                                           GObject.TYPE_STRING, // file  
+                                          GObject.TYPE_STRING, // added
+                                          GObject.TYPE_STRING, // removed
+                                      ] );
+                                }
+                            }
+                        }
+                    ]
+                },
+                {
+                    xtype: Gtk.HBox,
+                    pack : "pack_start,false,true,2",
+                    items : [
+                        {
+                            xtype: Gtk.Label,
+                            label : "Date",
+                            pack : "pack_start,false,false,10",
+                            width_request : 50,
+                            xalign : 1
+                        },
+                        {
+                            xtype: Gtk.Entry,
+                            id : "commitDate"
+                        }
+                    ]
+                },
+                {
+                    xtype: Gtk.HBox,
+                    pack : "pack_start,false,true,2",
+                    items : [
+                        {
+                            xtype: Gtk.Label,
+                            label : "Author",
+                            pack : "pack_start,false,false,10",
+                            width_request : 50,
+                            xalign : 1
+                        },
+                        {
+                            xtype: Gtk.Entry,
+                            id : "commitAuthor"
+                        }
+                    ]
+                },
+                {
+                    xtype: Gtk.HBox,
+                    pack : "pack_start,false,false,2",
+                    items : [
+                        {
+                            xtype: Gtk.Label,
+                            label : "Message",
+                            pack : "pack_start,false,false,10",
+                            width_request : 50,
+                            xalign : 1
+                        },
+                        {
+                            xtype: Gtk.TextView,
+                            height_request : 100,
+                            id : "commitMsg",
+                            pack : "add"
+                        }
+                    ]
+                },
+                {
+                    xtype: Gtk.ScrolledWindow,
+                    height_request : 200,
+                    pack : "pack_end,true,true,0",
+                    init : function() {
+                        XObject.prototype.init.call(this);
+                          this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+                    },
+                    items : [
+                        {
+                            xtype: WebKit.WebView,
+                            id : "commitPatch",
+                            pack : "add",
+                            clear : function() {
+                                
+                                
+                                
+                                 
+                               // remove..
+                                var s  = "document.body.textContent='';"
+                                    
+                                this.el.execute_script(s);
+                                    
+                                    
+                                
+                                
+                                
+                            },
+                            showDiff : function(files) {
+                                this.clear();
+                                
+                                
+                                
+                                if (Commit.release === false) {
+                                    return;
+                                }
+                                
+                                var diff = Commit.repo.diff(files, Commit.release, Commit.rev);
+                                
+                               // remove..
+                                var s  = "var pre  = document.createElement('pre'); document.body.appendChild(pre);";
+                                s += "pre.textContent =  " +
+                                         JSON.stringify(Commit.repo.lastCmd + "\n") + '+  ' + 
+                                         JSON.stringify(diff) + ";";
+                                    
+                                this.el.execute_script(s);
+                                    
+                                    
+                                
+                                
+                                
+                            }
+                        }
+                    ]
+                }
+            ]
+        },
+        {
+            xtype: Gtk.Button,
+            label : "Cancel",
+            pack : "add_action_widget,0"
+        },
+        {
+            xtype: Gtk.Button,
+            id : "ok_button",
+            label : "Add",
+            pack : "add_action_widget,1"
+        }
+    ]
+});
+Commit.init();
+XObject.cache['/Commit'] = Commit;
diff --git a/Merger.bjs b/Merger.bjs
new file mode 100644 (file)
index 0000000..4227b3b
--- /dev/null
@@ -0,0 +1,276 @@
+{
+    "id": "file-gtk-5",
+    "name": "Merger",
+    "parent": "",
+    "title": false,
+    "path": "/home/alan/gitlive/gitlive/Merger.bjs",
+    "items": [
+        {
+            "listeners": {
+                "destroy_event": "function (self, event) {\n     this.el.hide();\n                return false;\n}",
+                "response": "function (self, id) {\n  // hide\n     //if (id < 1) {\n        this.el.hide();\n        return;\n    //}\n    if (typeof(this.get('bug').getValue()) != 'object') {\n        print(\"ERROR\");\n        return;\n    }\n \n    this.el.hide();\n        \n    //var val = this.get('bug').getValue();\n     //   Seed.print(val);\n}"
+            },
+            "border_width": 3,
+            "default_height": 700,
+            "default_width": 800,
+            "id": "Merger",
+            "title": "Merger",
+            "xtype": "Dialog",
+            "|deletable": true,
+            "|show": "function(c) {\n    \n    if (!this.el) {\n        this.init();\n    }\n    var _this = this;\n     \n      //this.el.set_title(\"Merger - ??? \");\n//   this.el.set_title(\"Merger - \" + this.repo.repopath);\n\n\n     Merger.loading = true; // stop change firing on combos.\n     /// load up branches\n     \n     this.get('/historyTreeStore').el.clear();\n     this.get('/changedFilesStore').el.clear();\n     this.get('/patchview').clear();\n    \n     \n     \n     this.get('/workingCombo').load(Merger.repo.branches);\n     \n     this.get('/releaseCombo').load(Merger.repo.branches);\n\n\n\n\n     Merger.loading = false;\n\n    this.el.show_all();\n    //this.get('/ok_button').el.set_sensitive(false);\n    \n    // block until we return.\n    var run_ret = this.el.run();\n    if (run_ret < 1 ) {\n        return  \"DONE\";\n    }\n    print(\"RUN RETURN : \" + run_ret);\n    return \"DONE\";\n    //print(JSON.stringify(this.get('bug').getValue()));\n   // return this.get('bug').getValue();\n    //this.success = c.success;\n}\n",
+            "|xns": "Gtk",
+            "items": [
+                {
+                    "xtype": "VBox",
+                    "|pack": " function(p,e) {\n        p.el.get_content_area().pack_start(e.el,true,true,0)\n    }\n",
+                    "|xns": "Gtk",
+                    "items": [
+                        {
+                            "pack": "pack_start,false,true",
+                            "xtype": "HBox",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "label": "Working Branch",
+                                    "xtype": "Label",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "listeners": {
+                                        "changed": "function (self) {\n   this.get('/historyTreeStore').loadTree();\n}"
+                                    },
+                                    "id": "workingCombo",
+                                    "xtype": "ComboBox",
+                                    "|init": "function() {\n    this.el = new Gtk.ComboBox.with_entry();\n    \n    \n    this.model  = new XObject(this.model);\n    this.model.init();\n    this.el.set_model(this.model.el);\n    this.el.set_entry_text_column (0);\n     XObject.prototype.init.call(this);\n    \n}\n",
+                                    "|load": "function(tr)\n{\n    //this.insert(citer,iter,0);\n    this.model.el.clear();\n    \n    var master = false;\n    var working = false;\n    \n    for(var i =0 ; i < tr.length; i++) {\n        if (!tr[i].name.length) {\n            continue;\n        }\n        var ret = {  };\n        this.model.el.append(ret);\n        //print(JSON.stringify(ret,null,4));\n        if (tr[i].name == 'master') {\n            master = i;\n        }\n        if (tr[i].name == 'working') {\n            working = i;\n        }          \n        this.model.el.set_value(ret.iter, 0, '' + tr[i].name );\n        this.model.el.set_value(ret.iter, 1, '' + tr[i].rev  );\n \n        \n    }     \n    if (master !== false) {\n        this.el.set_active(master);\n    }\n    if (working !== false) {\n        this.el.set_active(working);\n    }\n    \n}",
+                                    "|xns": "Gtk",
+                                    "items": [
+                                        {
+                                            "*prop": "model",
+                                            "xtype": "ListStore",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.set_column_types ( 3, [\n           GObject.TYPE_STRING, // file  \n          GObject.TYPE_STRING, // added\n          GObject.TYPE_STRING, // removed\n      ] );\n}\n",
+                                            "|xns": "Gtk"
+                                        }
+                                    ]
+                                },
+                                {
+                                    "label": "Release Branch",
+                                    "xtype": "Label",
+                                    "|xns": "Gtk"
+                                },
+                                {
+                                    "listeners": {
+                                        "changed": "function (self) {\n   this.get('/historyTreeStore').loadTree();\n}"
+                                    },
+                                    "id": "releaseCombo",
+                                    "xtype": "ComboBox",
+                                    "|init": "function() {\n    this.el = new Gtk.ComboBox.with_entry();\n    \n    \n    this.model  = new XObject(this.model);\n    this.model.init();\n    this.el.set_model(this.model.el);\n    this.el.set_entry_text_column (0);\n     XObject.prototype.init.call(this);\n    \n}\n",
+                                    "|load": "function(tr)\n{\n    //this.insert(citer,iter,0);\n    this.model.el.clear();\n    \n    var master = false;\n    var release = false;\n    \n    for(var i =0 ; i < tr.length; i++) {\n        var ret = {  };\n        if (!tr[i].name.length) {\n            continue;\n        }\n        \n        this.model.el.append(ret);\n        //print(JSON.stringify(ret,null,4));\n        if (tr[i].name == 'master') {\n            master = i;\n        }\n        if (tr[i].name == 'release') {\n            release = i;\n        }\n         \n        this.model.el.set_value(ret.iter, 0, '' + tr[i].name );\n        this.model.el.set_value(ret.iter, 1, '' + tr[i].rev  );\n \n        \n    }     \n    if (master !== false) {\n        this.el.set_active(master);\n    }\n    if (release !== false) {\n        this.el.set_active(release);\n    }\n    \n}",
+                                    "|xns": "Gtk",
+                                    "items": [
+                                        {
+                                            "*prop": "model",
+                                            "xtype": "ListStore",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.set_column_types ( 3, [\n           GObject.TYPE_STRING, // file  \n          GObject.TYPE_STRING, // added\n          GObject.TYPE_STRING, // removed\n      ] );\n}\n",
+                                            "|xns": "Gtk"
+                                        }
+                                    ]
+                                }
+                            ]
+                        },
+                        {
+                            "pack": "pack_end,true,true,0",
+                            "position": 400,
+                            "xtype": "VPaned",
+                            "|xns": "Gtk",
+                            "items": [
+                                {
+                                    "pack": "add",
+                                    "position": 200,
+                                    "xtype": "HPaned",
+                                    "|xns": "Gtk",
+                                    "items": [
+                                        {
+                                            "xtype": "ScrolledWindow",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n     this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "listeners": {
+                                                        "cursor_changed": "function (self) {\n\n    if (this.el.get_selection().count_selected_rows() < 1) {\n        //nothing?\n        return;\n    }\n    var model = this.get('/historyTreeStore');\n    var ret = {};        \n     var s = this.el.get_selection();\n    s.get_selected(ret);\n    \n    var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();\n     print(\"OUT?\" + value);// id..\n    // load the list in the right grid..\n    var Repo = imports.Scm.Git.Repo.Repo;\n    \n    \n   \n    if (model.release === false) {\n        return;\n    }\n    model.rev = value;\n   \n    var files = Merger.repo.changedFiles('/',   'rev', model.release + '..' + value);\n    this.get('/changedFilesStore').load(files);\n    return true;\n\n}"
+                                                    },
+                                                    "pack": "add",
+                                                    "xtype": "TreeView",
+                                                    "|init": "function() {\n    XObject.prototype.init.call(this);\n        var description = new Pango.FontDescription.c_new();\n   description.set_size(8000);\n     this.el.modify_font(description);\n\n     this.selection = this.el.get_selection();\n      this.selection.set_mode( Gtk.SelectionMode.SINGLE);\n    var _this = this;\n    /*\n 780                                                                     \n 781                                                                         // is this really needed??\n 782                                                                         this.selection.signal['changed'].connect(function() {\n 783                                                                                 _this.get('/LeftTree.view').listeners.cursor_changed.apply(\n 784                                                                                     _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']\n 785                                                                                 );\n 786                                                                         });\n 787                                                                         \n */\n }\n",
+                                                    "|xns": "Gtk",
+                                                    "items": [
+                                                        {
+                                                            "id": "historyTreeStore",
+                                                            "pack": "set_model",
+                                                            "release": false,
+                                                            "xtype": "TreeStore",
+                                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.set_column_types ( 3, [\n       GObject.TYPE_STRING, // title \n      GObject.TYPE_STRING, // rev \n  ] );\n}\n",
+                                                            "|load": "function(tr,iter)\n{\n    //this.insert(citer,iter,0);\n    if (!iter) {\n        this.el.clear();\n    }\n    \n    for(var i =0 ; i < tr.length; i++) {\n        var ret = {  };\n        if (iter) {\n            this.el.insert(ret ,iter,-1);\n        } else {\n            this.el.append(ret);\n        }\n        //print(JSON.stringify(ret,null,4));\n         \n          \n        this.el.set_value(ret.iter, 0, ''  +  tr[i].text );\n        this.el.set_value(ret.iter, 1, '' + tr[i].rev  );\n \n        if (tr[i].children && tr[i].children.length) {\n            this.load(tr[i].children, ret.iter);\n        }\n    }     \n}",
+                                                            "|loadTree": "function() {\n\n   this.working = false;\n   if (Merger.loading) {\n        return;\n   }\n   \n   \n   var wid = this.get('/workingCombo').el.get_active();\n   var rid = this.get('/releaseCombo').el.get_active();\n   if (wid < 0 || rid < 0 || rid == wid) {\n        return;\n   }\n   \n   var w = Merger.repo.branches[wid];\n   var r = Merger.repo.branches[rid];\n   \n\n\n    var rev = r.name + '..' + w.name;\n    this.release = r.name;\n    \n    // this takes some time, lets. try and dialog it..\n\n    \n    \n    \n    var msg = new Gtk.MessageDialog( {\n        buttons : Gtk.ButtonsType.NONE,\n        text: \"Loading History\"\n        \n    });\n    \n    msg.set_transient_for(Merger.el);\n    msg.set_modal(true);\n    msg.show_all();\n\n    var hist = Merger.repo.dayTree('/', false, 'rev', rev);\n    msg.hide();\n    \n    this.load(hist);\n        \n       \n}\n",
+                                                            "|xns": "Gtk"
+                                                        },
+                                                        {
+                                                            "pack": "append_column",
+                                                            "title": "Changes",
+                                                            "xtype": "TreeViewColumn",
+                                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 0 );\n\n}\n",
+                                                            "|xns": "Gtk",
+                                                            "items": [
+                                                                {
+                                                                    "pack": "pack_start",
+                                                                    "xtype": "CellRendererText",
+                                                                    "|xns": "Gtk"
+                                                                }
+                                                            ]
+                                                        }
+                                                    ]
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            "xtype": "ScrolledWindow",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n      this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "listeners": {
+                                                        "cursor_changed": "function (self) {\n  // SEE SELECTION.CHANGED\n    var files = this.files();\n    this.get('/patchview').showDiff(files); \n    //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();\n     //print(\"OUT?\" + value);// id..\n    // load the list in the right grid..\n     \n    return true;\n\n}"
+                                                    },
+                                                    "id": "changedFilesView",
+                                                    "pack": "add",
+                                                    "xtype": "TreeView",
+                                                    "|files": "function() {\n     if (this.el.get_selection().count_selected_rows() < 1) {\n        //nothing? - clea it?\n        return [];\n    }\n\n    var ret = {};         \n \n\n     var s = this.el.get_selection();\n     var files = [];\n      s.selected_foreach(function(model,p,iter) {\n    \n       files.push( model.get_value(iter, 0).value.get_string());\n     \n    });\n    return files;\n}\n",
+                                                    "|init": "function() {\n    XObject.prototype.init.call(this);\n        var description = new Pango.FontDescription.c_new();\n   description.set_size(8000);\n     this.el.modify_font(description);\n\n     this.selection = this.el.get_selection();\n      this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);\n    var _this = this;\n  this.selection.signal['changed'].connect(function() {\n     _this.listeners.cursor_changed.apply(\n          _this, [ _this, '']\n       );\n             });\n  }\n",
+                                                    "|xns": "Gtk",
+                                                    "items": [
+                                                        {
+                                                            "id": "changedFilesStore",
+                                                            "pack": "set_model",
+                                                            "xtype": "ListStore",
+                                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.set_column_types ( 3, [\n       GObject.TYPE_STRING, // file  \n      GObject.TYPE_STRING, // added\n      GObject.TYPE_STRING, // removed\n  ] );\n}\n",
+                                                            "|load": "function(tr)\n{\n    //this.insert(citer,iter,0);\n    this.el.clear();\n    for(var i =0 ; i < tr.length; i++) {\n        var ret = {  };\n       \n        this.el.append(ret);\n        \n        //print(JSON.stringify(ret,null,4));\n         \n          \n        this.el.set_value(ret.iter, 0, ''  +  tr[i].filename );\n        this.el.set_value(ret.iter, 1, '' + tr[i].added  );\n        this.el.set_value(ret.iter, 2, '' + tr[i].removed  );\n \n        \n    }     \n}",
+                                                            "|xns": "Gtk"
+                                                        },
+                                                        {
+                                                            "resizable": true,
+                                                            "min_width": 200,
+                                                            "pack": "append_column",
+                                                            "title": "Filename",
+                                                            "xtype": "TreeViewColumn",
+                                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 0 );\n\n}\n",
+                                                            "|xns": "Gtk",
+                                                            "items": [
+                                                                {
+                                                                    "pack": "pack_start",
+                                                                    "xtype": "CellRendererText",
+                                                                    "|xns": "Gtk"
+                                                                }
+                                                            ]
+                                                        },
+                                                        {
+                                                            "min_width": 50,
+                                                            "pack": "append_column",
+                                                            "title": "Added",
+                                                            "xtype": "TreeViewColumn",
+                                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 1 );\n\n}\n",
+                                                            "|xns": "Gtk",
+                                                            "items": [
+                                                                {
+                                                                    "pack": "pack_start",
+                                                                    "xtype": "CellRendererText",
+                                                                    "|xns": "Gtk"
+                                                                }
+                                                            ]
+                                                        },
+                                                        {
+                                                            "min_width": 50,
+                                                            "pack": "append_column",
+                                                            "title": "Removed",
+                                                            "xtype": "TreeViewColumn",
+                                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n    this.el.add_attribute(this.items[0].el , 'markup', 2 );\n\n}\n",
+                                                            "|xns": "Gtk",
+                                                            "items": [
+                                                                {
+                                                                    "pack": "pack_start",
+                                                                    "xtype": "CellRendererText",
+                                                                    "|xns": "Gtk"
+                                                                }
+                                                            ]
+                                                        }
+                                                    ]
+                                                },
+                                                {
+                                                    "|xns": "Gtk",
+                                                    "xtype": "TreeView",
+                                                    "pack": false,
+                                                    "items": [
+                                                        {
+                                                            "|xns": "Gtk",
+                                                            "xtype": "ListStore",
+                                                            "pack": false
+                                                        }
+                                                    ]
+                                                }
+                                            ]
+                                        }
+                                    ]
+                                },
+                                {
+                                    "xtype": "VBox",
+                                    "|xns": "Gtk",
+                                    "items": [
+                                        {
+                                            "pack": "pack_start,false,false,0",
+                                            "xtype": "HBox",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "listeners": {
+                                                        "clicked": "function (self) {\n    \n     \n     var model = this.get('/historyTreeStore');\n    \n    if (model.release === false) {\n        return;\n    }\n    \n \n    var files = this.get('/changedFilesView').files();\n    \n     if (!files.length) {\n        return; // error.!\n    }\n    var diff = Merger.repo.diff(files, model.release, model.rev);\n   \n   \n   print(\"history?\");\n   \n    \n    var history =  Merger.repo.history(files, 1, 'rev', model.rev);\n    \n    print(\"History\" + JSON.stringify(history, null,4));\n    \n    Commit = imports.Commit.Commit;\n\n    Commit.el.set_modal(true);\n    Commit.el.set_transient_for(Merger.el);\n\n    var ce = Commit.show({\n        repo : Merger.repo,\n        files : files,\n        release : model.release,\n        rev : model.rev,\n        author : history[0].changeby,\n        changed : history[0].changed_raw\n        \n    \n    });\n    if (ce === false ) {\n        return;\n    }\n    \n    var diff = Merger.repo.diff(files, model.release, model.rev);\n    \n    \n    print(JSON.stringify(ce,null,4));\n    //.... commit!!!\n    \n    imports.gitlive.monitor.pause();\n    \n    Merger.repo.checkout(model.release);\n    \n    Merger.repo.applyPatch(diff);\n    \n    // add all the files..\n    Merger.repo.add(files);\n    Merger.repo.commit({\n        author : ce.author,\n        changed : ce.changed,\n        message : ce.message\n        \n    });\n    \n    Merger.repo.checkout(model.working);\n    \n    imports.gitlive.monitor.resume();\n    \n    \n    \n    \n    \n    \n\n\n}"
+                                                    },
+                                                    "label": "Commit diff (no merge)",
+                                                    "xtype": "Button",
+                                                    "|xns": "Gtk"
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            "pack": "pack_end,true,true,0",
+                                            "xtype": "ScrolledWindow",
+                                            "|init": "function() {\n    XObject.prototype.init.call(this);\n      this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)\n}\n",
+                                            "|xns": "Gtk",
+                                            "items": [
+                                                {
+                                                    "id": "patchview",
+                                                    "pack": "add",
+                                                    "xtype": "WebView",
+                                                    "|clear": "function() {\n    \n    \n    \n     \n   // remove..\n    var s  = \"document.body.textContent='';\"\n        \n    this.el.execute_script(s);\n        \n        \n    \n    \n    \n}\n",
+                                                    "|showDiff": "function(files) {\n    this.clear();\n    \n    \n     var model = this.get('/historyTreeStore');\n    \n    if (model.release === false) {\n        return;\n    }\n    \n    var diff = Merger.repo.diff(files, model.release, model.rev);\n    \n   // remove..\n    var s  = \"var pre  = document.createElement('pre'); document.body.appendChild(pre);\";\n    s += \"pre.textContent =  \" +\n             JSON.stringify(Merger.repo.lastCmd + \"\\n\") + '+  ' + \n           JSON.stringify(diff) + \";\";\n    print(s);\n        \n    this.el.execute_script(s);\n        \n        \n    \n    \n    \n}\n",
+                                                    "|xns": "WebKit"
+                                                }
+                                            ]
+                                        }
+                                    ]
+                                }
+                            ]
+                        }
+                    ]
+                },
+                {
+                    "id": "ok_button",
+                    "label": "Close",
+                    "pack": "add_action_widget,1",
+                    "xtype": "Button",
+                    "|xns": "Gtk"
+                }
+            ]
+        }
+    ],
+    "permname": "",
+    "modOrder": ""
+}
\ No newline at end of file
diff --git a/Merger.js b/Merger.js
new file mode 100644 (file)
index 0000000..95389a7
--- /dev/null
+++ b/Merger.js
@@ -0,0 +1,732 @@
+Gtk = imports.gi.Gtk;
+Gdk = imports.gi.Gdk;
+Pango = imports.gi.Pango;
+GLib = imports.gi.GLib;
+Gio = imports.gi.Gio;
+GObject = imports.gi.GObject;
+GtkSource = imports.gi.GtkSource;
+WebKit = imports.gi.WebKit;
+Vte = imports.gi.Vte;
+console = imports.console;
+XObject = imports.XObject.XObject;
+Merger=new XObject({
+    xtype: Gtk.Dialog,
+    listeners : {
+        destroy_event : function (self, event) {
+             this.el.hide();
+                        return false;
+        },
+        response : function (self, id) {
+          // hide
+             //if (id < 1) {
+                this.el.hide();
+                return;
+            //}
+            if (typeof(this.get('bug').getValue()) != 'object') {
+                print("ERROR");
+                return;
+            }
+         
+            this.el.hide();
+                
+            //var val = this.get('bug').getValue();
+             //   Seed.print(val);
+        }
+    },
+    border_width : 3,
+    default_height : 700,
+    default_width : 800,
+    id : "Merger",
+    title : "Merger",
+    deletable : true,
+    show : function(c) {
+        
+        if (!this.el) {
+            this.init();
+        }
+        var _this = this;
+         
+          //this.el.set_title("Merger - ??? ");
+    //   this.el.set_title("Merger - " + this.repo.repopath);
+    
+    
+         Merger.loading = true; // stop change firing on combos.
+         /// load up branches
+         
+         this.get('/historyTreeStore').el.clear();
+         this.get('/changedFilesStore').el.clear();
+         this.get('/patchview').clear();
+        
+         
+         
+         this.get('/workingCombo').load(Merger.repo.branches);
+         
+         this.get('/releaseCombo').load(Merger.repo.branches);
+    
+    
+    
+    
+         Merger.loading = false;
+    
+        this.el.show_all();
+        //this.get('/ok_button').el.set_sensitive(false);
+        
+        // block until we return.
+        var run_ret = this.el.run();
+        if (run_ret < 1 ) {
+            return  "DONE";
+        }
+        print("RUN RETURN : " + run_ret);
+        return "DONE";
+        //print(JSON.stringify(this.get('bug').getValue()));
+       // return this.get('bug').getValue();
+        //this.success = c.success;
+    },
+    items : [
+        {
+            xtype: Gtk.VBox,
+            pack : function(p,e) {
+                    p.el.get_content_area().pack_start(e.el,true,true,0)
+                },
+            items : [
+                {
+                    xtype: Gtk.HBox,
+                    pack : "pack_start,false,true",
+                    items : [
+                        {
+                            xtype: Gtk.Label,
+                            label : "Working Branch"
+                        },
+                        {
+                            xtype: Gtk.ComboBox,
+                            listeners : {
+                                changed : function (self) {
+                                   this.get('/historyTreeStore').loadTree();
+                                }
+                            },
+                            id : "workingCombo",
+                            init : function() {
+                                this.el = new Gtk.ComboBox.with_entry();
+                                
+                                
+                                this.model  = new XObject(this.model);
+                                this.model.init();
+                                this.el.set_model(this.model.el);
+                                this.el.set_entry_text_column (0);
+                                 XObject.prototype.init.call(this);
+                                
+                            },
+                            load : function(tr)
+                            {
+                                //this.insert(citer,iter,0);
+                                this.model.el.clear();
+                                
+                                var master = false;
+                                var working = false;
+                                
+                                for(var i =0 ; i < tr.length; i++) {
+                                    if (!tr[i].name.length) {
+                                        continue;
+                                    }
+                                    var ret = {  };
+                                    this.model.el.append(ret);
+                                    //print(JSON.stringify(ret,null,4));
+                                    if (tr[i].name == 'master') {
+                                        master = i;
+                                    }
+                                    if (tr[i].name == 'working') {
+                                        working = i;
+                                    }          
+                                    this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
+                                    this.model.el.set_value(ret.iter, 1, '' + tr[i].rev  );
+                             
+                                    
+                                }     
+                                if (master !== false) {
+                                    this.el.set_active(master);
+                                }
+                                if (working !== false) {
+                                    this.el.set_active(working);
+                                }
+                                
+                            },
+                            model : {
+                                xtype: Gtk.ListStore,
+                                init : function() {
+                                    XObject.prototype.init.call(this);
+                                    this.el.set_column_types ( 3, [
+                                           GObject.TYPE_STRING, // file  
+                                          GObject.TYPE_STRING, // added
+                                          GObject.TYPE_STRING, // removed
+                                      ] );
+                                }
+                            }
+                        },
+                        {
+                            xtype: Gtk.Label,
+                            label : "Release Branch"
+                        },
+                        {
+                            xtype: Gtk.ComboBox,
+                            listeners : {
+                                changed : function (self) {
+                                   this.get('/historyTreeStore').loadTree();
+                                }
+                            },
+                            id : "releaseCombo",
+                            init : function() {
+                                this.el = new Gtk.ComboBox.with_entry();
+                                
+                                
+                                this.model  = new XObject(this.model);
+                                this.model.init();
+                                this.el.set_model(this.model.el);
+                                this.el.set_entry_text_column (0);
+                                 XObject.prototype.init.call(this);
+                                
+                            },
+                            load : function(tr)
+                            {
+                                //this.insert(citer,iter,0);
+                                this.model.el.clear();
+                                
+                                var master = false;
+                                var release = false;
+                                
+                                for(var i =0 ; i < tr.length; i++) {
+                                    var ret = {  };
+                                    if (!tr[i].name.length) {
+                                        continue;
+                                    }
+                                    
+                                    this.model.el.append(ret);
+                                    //print(JSON.stringify(ret,null,4));
+                                    if (tr[i].name == 'master') {
+                                        master = i;
+                                    }
+                                    if (tr[i].name == 'release') {
+                                        release = i;
+                                    }
+                                     
+                                    this.model.el.set_value(ret.iter, 0, '' + tr[i].name );
+                                    this.model.el.set_value(ret.iter, 1, '' + tr[i].rev  );
+                             
+                                    
+                                }     
+                                if (master !== false) {
+                                    this.el.set_active(master);
+                                }
+                                if (release !== false) {
+                                    this.el.set_active(release);
+                                }
+                                
+                            },
+                            model : {
+                                xtype: Gtk.ListStore,
+                                init : function() {
+                                    XObject.prototype.init.call(this);
+                                    this.el.set_column_types ( 3, [
+                                           GObject.TYPE_STRING, // file  
+                                          GObject.TYPE_STRING, // added
+                                          GObject.TYPE_STRING, // removed
+                                      ] );
+                                }
+                            }
+                        }
+                    ]
+                },
+                {
+                    xtype: Gtk.VPaned,
+                    pack : "pack_end,true,true,0",
+                    position : 400,
+                    items : [
+                        {
+                            xtype: Gtk.HPaned,
+                            pack : "add",
+                            position : 200,
+                            items : [
+                                {
+                                    xtype: Gtk.ScrolledWindow,
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                         this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.TreeView,
+                                            listeners : {
+                                                cursor_changed : function (self) {
+                                                
+                                                    if (this.el.get_selection().count_selected_rows() < 1) {
+                                                        //nothing?
+                                                        return;
+                                                    }
+                                                    var model = this.get('/historyTreeStore');
+                                                    var ret = {};        
+                                                     var s = this.el.get_selection();
+                                                    s.get_selected(ret);
+                                                    
+                                                    var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
+                                                     print("OUT?" + value);// id..
+                                                    // load the list in the right grid..
+                                                    var Repo = imports.Scm.Git.Repo.Repo;
+                                                    
+                                                    
+                                                   
+                                                    if (model.release === false) {
+                                                        return;
+                                                    }
+                                                    model.rev = value;
+                                                   
+                                                    var files = Merger.repo.changedFiles('/',   'rev', model.release + '..' + value);
+                                                    this.get('/changedFilesStore').load(files);
+                                                    return true;
+                                                
+                                                }
+                                            },
+                                            pack : "add",
+                                            init : function() {
+                                                XObject.prototype.init.call(this);
+                                                    var description = new Pango.FontDescription.c_new();
+                                               description.set_size(8000);
+                                                 this.el.modify_font(description);
+                                            
+                                                 this.selection = this.el.get_selection();
+                                                  this.selection.set_mode( Gtk.SelectionMode.SINGLE);
+                                                var _this = this;
+                                                /*
+                                             780                                                                     
+                                             781                                                                         // is this really needed??
+                                             782                                                                         this.selection.signal['changed'].connect(function() {
+                                             783                                                                                 _this.get('/LeftTree.view').listeners.cursor_changed.apply(
+                                             784                                                                                     _this.get('/LeftTree.view'), [ _this.get('/LeftTree.view'), '']
+                                             785                                                                                 );
+                                             786                                                                         });
+                                             787                                                                         
+                                             */
+                                             },
+                                            items : [
+                                                {
+                                                    xtype: Gtk.TreeStore,
+                                                    id : "historyTreeStore",
+                                                    pack : "set_model",
+                                                    release : false,
+                                                    init : function() {
+                                                        XObject.prototype.init.call(this);
+                                                        this.el.set_column_types ( 3, [
+                                                           GObject.TYPE_STRING, // title 
+                                                          GObject.TYPE_STRING, // rev 
+                                                      ] );
+                                                    },
+                                                    load : function(tr,iter)
+                                                    {
+                                                        //this.insert(citer,iter,0);
+                                                        if (!iter) {
+                                                            this.el.clear();
+                                                        }
+                                                        
+                                                        for(var i =0 ; i < tr.length; i++) {
+                                                            var ret = {  };
+                                                            if (iter) {
+                                                                this.el.insert(ret ,iter,-1);
+                                                            } else {
+                                                                this.el.append(ret);
+                                                            }
+                                                            //print(JSON.stringify(ret,null,4));
+                                                             
+                                                              
+                                                            this.el.set_value(ret.iter, 0, ''  +  tr[i].text );
+                                                            this.el.set_value(ret.iter, 1, '' + tr[i].rev  );
+                                                     
+                                                            if (tr[i].children && tr[i].children.length) {
+                                                                this.load(tr[i].children, ret.iter);
+                                                            }
+                                                        }     
+                                                    },
+                                                    loadTree : function() {
+                                                    
+                                                       this.working = false;
+                                                       if (Merger.loading) {
+                                                            return;
+                                                       }
+                                                       
+                                                       
+                                                       var wid = this.get('/workingCombo').el.get_active();
+                                                       var rid = this.get('/releaseCombo').el.get_active();
+                                                       if (wid < 0 || rid < 0 || rid == wid) {
+                                                            return;
+                                                       }
+                                                       
+                                                       var w = Merger.repo.branches[wid];
+                                                       var r = Merger.repo.branches[rid];
+                                                       
+                                                    
+                                                    
+                                                        var rev = r.name + '..' + w.name;
+                                                        this.release = r.name;
+                                                        
+                                                        // this takes some time, lets. try and dialog it..
+                                                    
+                                                        
+                                                        
+                                                        
+                                                        var msg = new Gtk.MessageDialog( {
+                                                            buttons : Gtk.ButtonsType.NONE,
+                                                            text: "Loading History"
+                                                            
+                                                        });
+                                                        
+                                                        msg.set_transient_for(Merger.el);
+                                                        msg.set_modal(true);
+                                                        msg.show_all();
+                                                    
+                                                        var hist = Merger.repo.dayTree('/', false, 'rev', rev);
+                                                        msg.hide();
+                                                        
+                                                        this.load(hist);
+                                                            
+                                                           
+                                                    }
+                                                },
+                                                {
+                                                    xtype: Gtk.TreeViewColumn,
+                                                    pack : "append_column",
+                                                    title : "Changes",
+                                                    init : function() {
+                                                        XObject.prototype.init.call(this);
+                                                        this.el.add_attribute(this.items[0].el , 'markup', 0 );
+                                                    
+                                                    },
+                                                    items : [
+                                                        {
+                                                            xtype: Gtk.CellRendererText,
+                                                            pack : "pack_start"
+                                                        }
+                                                    ]
+                                                }
+                                            ]
+                                        }
+                                    ]
+                                },
+                                {
+                                    xtype: Gtk.ScrolledWindow,
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                          this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+                                    },
+                                    items : [
+                                        {
+                                            xtype: Gtk.TreeView,
+                                            listeners : {
+                                                cursor_changed : function (self) {
+                                                  // SEE SELECTION.CHANGED
+                                                    var files = this.files();
+                                                    this.get('/patchview').showDiff(files); 
+                                                    //var value = ''+ ret.model.get_value(ret.iter, 1).value.get_string();
+                                                     //print("OUT?" + value);// id..
+                                                    // load the list in the right grid..
+                                                     
+                                                    return true;
+                                                
+                                                }
+                                            },
+                                            id : "changedFilesView",
+                                            pack : "add",
+                                            files : function() {
+                                                 if (this.el.get_selection().count_selected_rows() < 1) {
+                                                    //nothing? - clea it?
+                                                    return [];
+                                                }
+                                            
+                                                var ret = {};         
+                                             
+                                            
+                                                 var s = this.el.get_selection();
+                                                 var files = [];
+                                                  s.selected_foreach(function(model,p,iter) {
+                                                
+                                                   files.push( model.get_value(iter, 0).value.get_string());
+                                                 
+                                                });
+                                                return files;
+                                            },
+                                            init : function() {
+                                                XObject.prototype.init.call(this);
+                                                    var description = new Pango.FontDescription.c_new();
+                                               description.set_size(8000);
+                                                 this.el.modify_font(description);
+                                            
+                                                 this.selection = this.el.get_selection();
+                                                  this.selection.set_mode( Gtk.SelectionMode.MULTIPLE);
+                                                var _this = this;
+                                              this.selection.signal['changed'].connect(function() {
+                                                 _this.listeners.cursor_changed.apply(
+                                                      _this, [ _this, '']
+                                                   );
+                                                         });
+                                              },
+                                            items : [
+                                                {
+                                                    xtype: Gtk.ListStore,
+                                                    id : "changedFilesStore",
+                                                    pack : "set_model",
+                                                    init : function() {
+                                                        XObject.prototype.init.call(this);
+                                                        this.el.set_column_types ( 3, [
+                                                           GObject.TYPE_STRING, // file  
+                                                          GObject.TYPE_STRING, // added
+                                                          GObject.TYPE_STRING, // removed
+                                                      ] );
+                                                    },
+                                                    load : function(tr)
+                                                    {
+                                                        //this.insert(citer,iter,0);
+                                                        this.el.clear();
+                                                        for(var i =0 ; i < tr.length; i++) {
+                                                            var ret = {  };
+                                                           
+                                                            this.el.append(ret);
+                                                            
+                                                            //print(JSON.stringify(ret,null,4));
+                                                             
+                                                              
+                                                            this.el.set_value(ret.iter, 0, ''  +  tr[i].filename );
+                                                            this.el.set_value(ret.iter, 1, '' + tr[i].added  );
+                                                            this.el.set_value(ret.iter, 2, '' + tr[i].removed  );
+                                                     
+                                                            
+                                                        }     
+                                                    }
+                                                },
+                                                {
+                                                    xtype: Gtk.TreeViewColumn,
+                                                    resizable : true,
+                                                    min_width : 200,
+                                                    pack : "append_column",
+                                                    title : "Filename",
+                                                    init : function() {
+                                                        XObject.prototype.init.call(this);
+                                                        this.el.add_attribute(this.items[0].el , 'markup', 0 );
+                                                    
+                                                    },
+                                                    items : [
+                                                        {
+                                                            xtype: Gtk.CellRendererText,
+                                                            pack : "pack_start"
+                                                        }
+                                                    ]
+                                                },
+                                                {
+                                                    xtype: Gtk.TreeViewColumn,
+                                                    min_width : 50,
+                                                    pack : "append_column",
+                                                    title : "Added",
+                                                    init : function() {
+                                                        XObject.prototype.init.call(this);
+                                                        this.el.add_attribute(this.items[0].el , 'markup', 1 );
+                                                    
+                                                    },
+                                                    items : [
+                                                        {
+                                                            xtype: Gtk.CellRendererText,
+                                                            pack : "pack_start"
+                                                        }
+                                                    ]
+                                                },
+                                                {
+                                                    xtype: Gtk.TreeViewColumn,
+                                                    min_width : 50,
+                                                    pack : "append_column",
+                                                    title : "Removed",
+                                                    init : function() {
+                                                        XObject.prototype.init.call(this);
+                                                        this.el.add_attribute(this.items[0].el , 'markup', 2 );
+                                                    
+                                                    },
+                                                    items : [
+                                                        {
+                                                            xtype: Gtk.CellRendererText,
+                                                            pack : "pack_start"
+                                                        }
+                                                    ]
+                                                }
+                                            ]
+                                        },
+                                        {
+                                            xtype: Gtk.TreeView,
+                                            pack : false,
+                                            items : [
+                                                {
+                                                    xtype: Gtk.ListStore,
+                                                    pack : false
+                                                }
+                                            ]
+                                        }
+                                    ]
+                                }
+                            ]
+                        },
+                        {
+                            xtype: Gtk.VBox,
+                            items : [
+                                {
+                                    xtype: Gtk.HBox,
+                                    pack : "pack_start,false,false,0",
+                                    items : [
+                                        {
+                                            xtype: Gtk.Button,
+                                            listeners : {
+                                                clicked : function (self) {
+                                                    
+                                                     
+                                                     var model = this.get('/historyTreeStore');
+                                                    
+                                                    if (model.release === false) {
+                                                        return;
+                                                    }
+                                                    
+                                                 
+                                                    var files = this.get('/changedFilesView').files();
+                                                    
+                                                     if (!files.length) {
+                                                        return; // error.!
+                                                    }
+                                                    var diff = Merger.repo.diff(files, model.release, model.rev);
+                                                   
+                                                   
+                                                   print("history?");
+                                                   
+                                                    
+                                                    var history =  Merger.repo.history(files, 1, 'rev', model.rev);
+                                                    
+                                                    print("History" + JSON.stringify(history, null,4));
+                                                    
+                                                    Commit = imports.Commit.Commit;
+                                                
+                                                    Commit.el.set_modal(true);
+                                                    Commit.el.set_transient_for(Merger.el);
+                                                
+                                                    var ce = Commit.show({
+                                                        repo : Merger.repo,
+                                                        files : files,
+                                                        release : model.release,
+                                                        rev : model.rev,
+                                                        author : history[0].changeby,
+                                                        changed : history[0].changed_raw
+                                                        
+                                                    
+                                                    });
+                                                    if (ce === false ) {
+                                                        return;
+                                                    }
+                                                    
+                                                    var diff = Merger.repo.diff(files, model.release, model.rev);
+                                                    
+                                                    
+                                                    print(JSON.stringify(ce,null,4));
+                                                    //.... commit!!!
+                                                    
+                                                    imports.gitlive.monitor.pause();
+                                                    
+                                                    Merger.repo.checkout(model.release);
+                                                    
+                                                    Merger.repo.applyPatch(diff);
+                                                    
+                                                    // add all the files..
+                                                    Merger.repo.add(files);
+                                                    Merger.repo.commit({
+                                                        author : ce.author,
+                                                        changed : ce.changed,
+                                                        message : ce.message
+                                                        
+                                                    });
+                                                    
+                                                    Merger.repo.checkout(model.working);
+                                                    
+                                                    imports.gitlive.monitor.resume();
+                                                    
+                                                    
+                                                    
+                                                    
+                                                    
+                                                    
+                                                
+                                                
+                                                }
+                                            },
+                                            label : "Commit diff (no merge)"
+                                        }
+                                    ]
+                                },
+                                {
+                                    xtype: Gtk.ScrolledWindow,
+                                    pack : "pack_end,true,true,0",
+                                    init : function() {
+                                        XObject.prototype.init.call(this);
+                                          this.el.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC)
+                                    },
+                                    items : [
+                                        {
+                                            xtype: WebKit.WebView,
+                                            id : "patchview",
+                                            pack : "add",
+                                            clear : function() {
+                                                
+                                                
+                                                
+                                                 
+                                               // remove..
+                                                var s  = "document.body.textContent='';"
+                                                    
+                                                this.el.execute_script(s);
+                                                    
+                                                    
+                                                
+                                                
+                                                
+                                            },
+                                            showDiff : function(files) {
+                                                this.clear();
+                                                
+                                                
+                                                 var model = this.get('/historyTreeStore');
+                                                
+                                                if (model.release === false) {
+                                                    return;
+                                                }
+                                                
+                                                var diff = Merger.repo.diff(files, model.release, model.rev);
+                                                
+                                               // remove..
+                                                var s  = "var pre  = document.createElement('pre'); document.body.appendChild(pre);";
+                                                s += "pre.textContent =  " +
+                                                         JSON.stringify(Merger.repo.lastCmd + "\n") + '+  ' + 
+                                                       JSON.stringify(diff) + ";";
+                                                print(s);
+                                                    
+                                                this.el.execute_script(s);
+                                                    
+                                                    
+                                                
+                                                
+                                                
+                                            }
+                                        }
+                                    ]
+                                }
+                            ]
+                        }
+                    ]
+                }
+            ]
+        },
+        {
+            xtype: Gtk.Button,
+            id : "ok_button",
+            label : "Close",
+            pack : "add_action_widget,1"
+        }
+    ]
+});
+Merger.init();
+XObject.cache['/Merger'] = Merger;
diff --git a/Monitor.js b/Monitor.js
new file mode 100644 (file)
index 0000000..5d4ba1b
--- /dev/null
@@ -0,0 +1,229 @@
+//<Script type="text/javascript">
+var Gio      = imports.gi.Gio;
+var GLib      = imports.gi.GLib;
+
+
+/**
+ * Monitor class - handles monitor managment for a large tree...
+ * 
+ * usage : 
+ * x = new Monitor({
+     change : function () {
+         * ....
+         *}
+  }
+ * x.add('/somepath')
+ * x.stop() // stops all scanning.
+ * x.play(); // starts the scanning
+ * 
+ * 
+ * 
+ * 
+ */
+function Monitor(cfg){
+    for (var i in cfg) {
+        this[i] = cfg[i];
+    }
+    
+    
+    this.monitors = [];
+    
+    this.top = [];
+    
+}
+
+Monitor.prototype = {
+    
+    monitors : false, // Array of GioFileMonitors
+    top : false, // list of top level directories..
+    paused : false,
+    /**
+     * add a directory or file to monitor
+     */
+    add : function(add)
+    {
+        this.top.push(add);
+    },
+    /**
+     * start monitoring
+     */
+    start : function()
+    {
+        this.top.forEach(this.monitor, this);
+    },
+    /**
+     * stop / pause monitoring
+     * 
+     */
+    stop : function()
+    {
+        this.monitors.forEach(function(m) {
+            m.cancel();
+        })
+        this.monitors = [];
+    },
+    /**
+     * pause monitoring - without changing what's monitored 
+     */
+    pause : function()
+    {
+        this.paused = true;
+    },
+    /**
+     * resume monitoring - without changing what's monitored 
+     */
+    resume : function()
+    {
+        this.paused = false;
+    },
+    /**
+     * monitor a file or directory (privatish)
+     *
+     * initially called with ~/gitlive  null 0 (effectvely)
+     * 
+     * 
+     */
+    monitor : function(path, fn, depth)
+    {
+        var _this = this;
+        
+       // print("ADD: " + path)
+        
+        depth = typeof(depth) == 'number'  ? depth *1 : 0;
+        
+        
+        fn = fn || function (fm, f, of, event_type, uh) {
+            _this.onEvent(fm, f, of, event_type, uh);
+        }
+       
+        // if we are not at top level.. and there is a .git directory  (it's a submodule .. ignore) 
+        if (depth > 1 && GLib.file_test(path + '/.git' , GLib.FileTest.IS_DIR)) {
+            return;
+        }
+            
+       
+       
+        
+        var f = Gio.file_new_for_path(path);
+            //var cancel = new Gio.Cancellable ();
+        if (depth > 0) {     
+            var fm = f.monitor(2,null); //Gio.FileMonitorFlags.SEND_MOVED
+            fm.signal.changed.connect(fn);
+            this.monitors.push(fm);
+            // print("ADD path " + depth + ' ' + path);
+        }
+        // iterate children?
+        
+        if (GLib.file_test(path + '/.git' , GLib.FileTest.IS_DIR) && this.initRepo) {
+            
+            this.initRepo(path);
+        }
+        
+        
+        var file_enum = f.enumerate_children(
+            Gio.FILE_ATTRIBUTE_STANDARD_DISPLAY_NAME + ','+ 
+            Gio.FILE_ATTRIBUTE_STANDARD_TYPE,
+            Gio.FileQueryInfoFlags.NONE,
+            null);
+        
+       
+        
+        while ((next_file = file_enum.next_file(null)) != null) {
+         
+            if (next_file.get_file_type() != Gio.FileType.DIRECTORY) {
+                continue;
+            }
+            if (next_file.get_display_name()[0] == '.') {
+                continue;
+            }
+            var sp = path+'/'+next_file.get_display_name();
+            // skip modules.
+           
+            
+            this.monitor(sp, fn, depth + 1)
+        }
+    
+        file_enum.close(null);
+    },
+    
+    
+    onEvent : function(fm, f, of, event_type, uh)
+    {
+        if (this.paused) {
+            return;
+        }
+        var src = {
+            name : f.get_basename(),
+            path : f.get_path(),
+            dir   : GLib.path_get_dirname(f.get_path())
+        };
+        var dest = of ? {
+            name : of.get_basename(),
+            path : of.get_path(),
+            dir   : GLib.path_get_dirname(of.get_path())
+        } : false;
+        
+        
+        for(var i in Gio.FileMonitorEvent) {
+            if (Gio.FileMonitorEvent[i] == event_type) {
+                event_name = i;
+            }
+        }
+        //print ("got event: " +event_name);
+        //print ("got src: " + src.toString());
+        //print ("got event: " + src.toString());
+        try {
+                
+            switch(event_type) {
+                case Gio.FileMonitorEvent.CHANGED:
+                    this.onChanged(src);
+                    return; // ingore thise?? -wait for changes_done_htin?
+                    
+                case Gio.FileMonitorEvent.CHANGES_DONE_HINT:
+                    this.onChangesDoneHint(src);
+                    return;
+                    
+                case Gio.FileMonitorEvent.DELETED:
+                    this.onDeleted(src);
+                    return;
+                    
+                case Gio.FileMonitorEvent.CREATED:
+                    this.onCreated(src);
+                    return;
+                
+                case Gio.FileMonitorEvent.ATTRIBUTE_CHANGED: // eg. chmod/chatt
+                    this.onAttributeChanged(src);
+                    return;
+                
+                case Gio.FileMonitorEvent.MOVED: // eg. chmod/chatt
+                    this.onMoved(src,dest);
+                    return; 
+                
+                // rest are mount related - not really relivant.. maybe add later..
+            } 
+        } catch(e) {
+            print(e);
+        }
+        
+    },
+    
+    /** override these to do stuff.. */
+    initRepo : function(src) { }, // called on startup at the top level repo dir.
+    onChanged : function(src) { },
+    onChangesDoneHint : function(src) { },
+    onDeleted : function(src) { },
+    onCreated : function(src) { },
+    onAttributeChanged : function(src) { },
+    onMoved : function(src) { }
+          
+    
+}
+
+
+
+
+
diff --git a/Scm/Git/Repo.js b/Scm/Git/Repo.js
new file mode 100644 (file)
index 0000000..f365423
--- /dev/null
@@ -0,0 +1,738 @@
+
+const GLib   = imports.gi.GLib;
+
+const XObject = imports.XObject.XObject;
+const Event  = imports.Scm.Git.Event.Event;
+const Spawn  = imports.Spawn.Spawn;
+const File  = imports.File.File;
+
+
+Repo = XObject.define(
+    function(cfg) {
+        // cal parent?
+        XObject.extend(this,cfg);
+        this.gitdir = cfg.repopath + "/.git";
+        
+        if (!File.isDirectory(this.gitdir)) {
+            this.gitdir = this.repopath;
+        }
+        //Repo.superclass.constructor.call(this,cfg);
+        
+    },
+    imports.Scm.Repo.Repo, // or Object
+    {
+        branches : false,
+        currentBranch : false,
+        tags : false,
+        gitdir : false,
+        debug : false,
+        lastCmd : false, 
+        
+        getMetaData : function() {
+            return {
+              name :  'Git',
+              tool : ['git' ]  
+                
+            };
+        },
+        getBranches : function()
+        {
+            if (this.branches !== false) {
+                return this.branches;
+            }
+            this.branches = [];
+            
+            var bl = this.git([ 'branch', {
+                'no-color' : true,
+                'verbose' : true,
+                'no-abbrev'  : true,
+                'a' : true
+            }]).split("\n");
+            var bmap = {};
+            var _this=this;
+            
+            var local = [];
+            var remotes = [];
+            
+            bl.forEach(function(line) {
+                  // * master 61e7e7d oneliner
+                var active = line[0]=='*';
+                if (!line.length) {
+                    return;
+                }
+                line = line.substring(2);
+                
+                //print(JSON.stringify(line));
+                var parts = line.split(/\s+/);
+                if (parts[1] == '->') {
+                    return; // it's an alias like  remotes/origin/HEAD    -> origin/master
+                }
+                var br = {
+                    lastrev :  parts[1],
+                    name :      '',
+                    remote :    '',
+                    remoterev : ''
+                };
+                if (parts[0].match(/^remotes\//)) {
+                    br.remote = parts[0];
+                    bmap[br.remote] = br;
+                    remotes.push(br);
+                } else { 
+                    br.name = parts[0];
+                    bmap[br.name] = br;
+                    local.push(br);
+                }
+                
+                if (active) {
+                    _this.currentBranch = br;
+                }
+            });
+            
+            //print(JSON.stringify(local));
+            //print(JSON.stringify(remotes));
+            //print(JSON.stringify(bmap,null,4));
+
+            
+            // overlay tracking informaion
+            bl = this.git([
+                'for-each-ref',
+                { format :  '%(refname:short):remotes/%(upstream:short)' },
+                'refs/heads'
+            ]).split("\n");
+            //print(this.lastCmd);
+            
+            //print(JSON.stringify(bl,null,4));
+            
+            bl.forEach(function(line) {
+                if (!line.length) {
+                    return;
+                }
+                var ar = line.split(':remotes/');
+                
+                var lname= ar[0];
+                var rname = 'remotes/' + ar[1];
+                //print(rname);
+                // we should always have a local version of it.
+                bmap[lname].remote = rname;
+                if (typeof(bmap[rname]) == 'undefined') {
+                    return;
+                }
+                bmap[lname].remoterev =  bmap[rname].lastrev;
+                // flag it for not adding..
+                
+                bmap[rname].name = lname;
+            });
+            var _this =this;
+            
+            
+            
+            // add any remotes that do not have name..
+            remotes.forEach(function(r) {
+                if (r.name.length) {
+                    return;
+                }
+                
+                // create a tracking branch..
+                var name = r.remote.replace(/^remotes\//, '' ).replace(/^origin\//,'').replace('/', '.');
+                
+                 
+              
+                if (typeof(bmap[name]) != 'undefined') {
+                    // already got aremote of that name.
+                    // skip it...
+                    r.remoterev = r.lastrev;
+                    r.lastrev = '';
+                    local.push(r);
+                    return;
+                }
+                
+                
+                _this.git([ 
+                    'branch',
+                    {
+                        f : true,
+                        track : true
+                    },
+                    name,
+                    r.remote
+                ]);
+                
+                r.remoterev = r.lastrev;
+                r.name = name;
+                local.push(r);
+            });
+            
+            this.branches = local;
+         //    print(JSON.stringify(local,null,4));
+            
+            
+            return this.branches;
+        },
+        _remotes : false,
+        
+        remotes: function(cfg)
+        {
+            
+            if (cfg) {
+                this._remotes = false; // reset so we can query it..
+                
+                var url = Repo.parseURL(cfg.url);
+                if ((url.scheme == 'http://' || url.scheme == 'https://' )
+                    && url.user.length) {
+                    // remove username - as it confuses netrc..
+                    cfg.url = url.scheme + url.host + '/' +url.path;
+                    
+                }
+                
+                
+                this.git([
+                    'remote',
+                    'add',
+                    cfg.name,
+                    cfg.url
+                ]);
+                this.branches = false;
+                
+                this.git([
+                    'fetch',
+                    cfg.name,
+                    { 'a' : true }
+                ]);
+                
+                
+                
+                //print(this.lastCmd);
+
+            }
+            
+            
+            if (this._remotes!== false) {
+                return this._remotes;
+            }
+            this._remotes = [];
+            
+            var bl = this.git([ 'remote', {
+            //    'no-color' : true,
+                'verbose' : true
+            }]).split("\n");
+            
+            var _this=this;
+            bl.forEach(function(line) {
+                if (!line.length) {
+                    return;
+                  // * master 61e7e7d oneliner
+                }
+               // print(JSON.stringify( line));
+                var parts = line.split(/\t/);
+                var type = false;
+                parts[1] = parts[1].replace(/\([a-z]+\)$/, function( a) {
+                    type = a.substr(1,a.length-2);
+                    return '';
+                });
+                
+                _this._remotes.push( {
+                    name: parts[0],
+                    url : parts[1],
+                    type:  type
+                });
+                
+            });
+            return this._remotes;
+        },
+        
+        
+        
+        lastupdated: function() {
+            return 'tbc';
+        },
+        autocommit: function() {
+            return true;
+        },
+        
+        autopush: function() {
+            return true;
+        },
+          /*
+        
+          public function getTags()
+          {
+            if ($this->tags !== null) {
+              return $this->tags;
+            }
+            $this->tags = array();
+            $fp = $this->git('tag');
+            while ($line = fgets($fp)) {
+              $line = trim($line);
+              $this->tags[$line] = $line;
+            }
+            $fp = null;
+            return $this->tags;
+          }
+        
+          public function readdir($path, $object = null, $ident = null)
+          {
+            $res = array();
+        
+            if ($object === null) {
+              $object = 'branch';
+              $ident = 'master';
+            }
+            $rev = $this->resolveRevision(null, $object, $ident);
+        
+            if (strlen($path)) {
+              $path = rtrim($path, '/') . '/';
+            }
+        
+            $fp = $this->git('ls-tree', $rev, $path);
+        
+            $dirs = array();
+            require_once 'MTrack/SCM/Git/File.php';
+            while ($line = fgets($fp)) {
+                // blob = file, tree = dir..
+                list($mode, $type, $hash, $name) = preg_split("/\s+/", $line);
+                //echo '<PRE>';echo $line ."\n</PRE>";
+                $res[] = new MTrack_SCM_Git_File($this, "$name", $rev, $type == 'tree', $hash);
+            }
+            return $res;
+          }
+        
+          public function file($path, $object = null, $ident = null)
+          {
+            if ($object == null) {
+              $branches = $this->getBranches();
+              if (isset($branches['master'])) {
+                $object = 'branch';
+                $ident = 'master';
+              } else {
+                // fresh/empty repo
+                return null;
+              }
+            }
+            $rev = $this->resolveRevision(null, $object, $ident);
+            require_once 'MTrack/SCM/Git/File.php';
+            return new MTrack_SCM_Git_File($this, $path, $rev);
+          }
+       */
+        /**
+         * 
+         * @param  string path (can be empty - eg. '')
+         * @param  {number|date} limit  how many to fetch
+         * @param  {string} object = eg. rev|tag|branch  (use 'rev' here and ident=HASH to retrieve a speific revision
+         * @param  {string} ident = 
+         *
+         * Example:
+         *   - fetch on revision?:  '.',1,'rev','xxxxxxxxxx'
+         *
+         *
+         * range... object ='rev' ident ='master..release'
+         * 
+         */
+        history: function(path, limit , object, ident)
+        {
+            limit = limit || false;
+            object = object || false;
+            ident = ident || false; 
+            var res = [];
+            var args = [ 'log' ];
+             
+            
+            if (object !== false) {
+                rev = this.resolveRevision(false, object, ident); // from scm...
+                args.push( '' + rev);  
+            } else {
+                args.push( "master" );
+            }
+           
+            var arg = {
+                "no-color" : true, 
+            //args.push("--name-status";
+                "raw" : true,
+                 
+                "numstat" : true,
+                "date" : 'iso8601'
+            };
+            if (limit !== false) {
+                if (typeof(limit) == 'number') {
+                    arg['max-count'] =  limit;
+                } else if (typeof(limit) == 'object') {
+                    arg.skip=  limit[0];
+                    arg['max-count']=  limit[1];
+     
+                } else {
+                    arg.since = limit;
+                }
+            }
+            
+            args.push(arg);
+            
+            
+            
+       
+            
+            //echo '<PRE>';print_r($args);echo '</PRE>';
+            
+            
+            
+            args.push({ '' : true });
+            if (typeof(path) == 'string') {
+                path = path[0] == '/' ? path.substring(1) : path;
+                args.push(path);
+            } else {
+                path.forEach(function(p) {
+                     args.push(p);
+                })
+            }
+            
+            
+            //   print_R(array($args, '--' ,$path));exit;
+            var fp = this.git(args).split("\n");
+    
+            var commits = [];
+            var commit = false;
+            while (fp.length) {
+                var line = fp.shift() + "\n";
+                
+                if (line.match(/^commit/)) {
+                    if (commit !== false) {
+                        commits.push( commit );
+                    }
+                    commit = line;
+                    continue;
+                }
+                commit += line ;
+            }
+             
+            if (commit !== false) {
+                commits.push( commit );
+            }
+            var res = [];
+            //print(JSON.stringify(commits,null,4));
+            
+            var _t = this;
+            commits.forEach( function(c) {
+              //       print(typeof(Event)); print(JSON.stringify(c));
+                var ev = new Event( {commit : c, repo: _t });
+                res.push(ev);
+                  
+            });
+            // close 'fp'
+            return res;
+        },
+        diff : function(path, from, to)
+        {
+            to = to || false;
+            from = from || false;
+            
+             
+            
+            
+            /*
+            if ($path instanceof MTrackSCMFile) {
+                if ($from === null) {
+                    $from = $path->rev;
+                }
+                $path = $path->name;
+                
+            }
+            // if it's a file event.. we are even lucker..
+            if ($path instanceof MTrackSCMFileEvent) {
+                return $this->git('log', '--max-count=1', '--format=format:', '--patch', $from, '--', $path->name);
+                
+            }
+            */
+            // diff ignoring white space..
+            args = [ 'diff' , { 'w' : true} ]
+        
+            if (to == false) {
+                to = from;
+                from = from + '^';
+            }
+            
+            args.push(from+'..'+to);
+            args.push( { '' : true });
+            if (typeof(path) != 'string') {
+                path.forEach(function(p) { args.push(p); })
+            }
+            return this.git(args); 
+        },
+        
+        
+        
+        dayTree: function (path, limit , object, ident)
+        {
+            
+            var ar = this.history(path, limit , object, ident);
+            
+            // the point of this is to extract all the revisions, and group them.
+            
+            
+            
+            //echo '<PRE>';print_R($ar);
+            
+            // need to get a 2 dimensional array of
+            // files along top, and commints down.
+            var cfiles = []
+            var rows = [];
+            
+            var days = {};
+            
+            ar.forEach(function( commit) {
+                
+                var files = commit.files;
+                var day = commit.cday;
+                if (typeof(days[day]) == 'undefined') { 
+                    days[day] = {
+                        'text' : day,
+                        'rev' : day,
+                        'children' : {}
+                    }
+                }
+                var time= commit.ctime;
+                if (typeof(days[day]['children'][time]) == 'undefined' ) { 
+                    days[day]['children'][time] = {
+                        'text' : time,
+                        'rev' : day + ' ' + time,
+                        'children' : [] 
+                    };
+                }
+                days[day]['children'][time]['children'].push( {
+                    'text' : commit.changelog,
+                    'rev' : commit.rev,
+                    'leaf' :  true
+                });
+            });
+            var out = [];
+            
+            for(var d in days) {
+                var dr = days[d];
+                dcn = dr['children'];
+                dr['children'] = [];
+                for(var t in dcn) {
+                    var to = dcn[t];
+                    to['rev']  = to['children'][0]['rev'];
+                    dr['children'].push( to);
+                }
+                dr['rev'] = dr['children'][0]['rev'];
+                out.push( dr);
+            }
+            
+            return out;            
+             
+            
+        },
+        
+        
+    
+    
+        changedFiles :function(path,  object, ident)
+        {
+             object = object || false;
+            ident = ident || false; 
+            var res = [];
+            var args = [ 'diff', { 'numstat' : true}  , { 'w' : true } ];
+             
+            
+            if (object !== false) {
+                rev = this.resolveRevision(false, object, ident); // from scm...
+                args.push( '' + rev);  
+            } else {
+                args.push( "master" );
+            }
+            path = path[0] == '/' ? path.substring(1) : path; 
+            
+            args.push({ '' : true });
+            args.push(path);
+              // in theory you could click a number of them and only merge those changes..
+            // need to do a git diff.. and just get a list of files..
+            var rows = [];
+            var res = this.git(args).split("\n"); 
+            res.forEach( function(line) {
+                
+                
+                
+                var ar = line.split("\t"); 
+                if (ar.length !=3 ) {
+                    return;
+                }
+                rows.push({ 
+                    'added' : ar[0],
+                    'removed' : ar[1],
+                    'filename' : ar[2]
+                });
+                
+                
+            });
+            return rows;  
+    
+        },
+        
+        
+        checkout : function(branch)
+        {
+            this.git([' checkout', branch ]);
+        },
+        
+        
+        
+            
+        applyPatch : function( diff )
+        {
+            var sp = new Spawn({
+                cwd : this.repopath,
+                args : [ 'patch' , '-p1' ] ,
+                env :  [  "HOME=" + GLib.get_home_dir() ],
+                debug: false,
+                exceptions : false,
+                async : false,
+                listeners : {
+                    input : function() {
+                        return diff;
+                    }
+                }
+            });
+            sp.run();
+            return sp.output;
+        } ,
+        add : function (files )
+        {
+            // should really find out if these are untracked files each..
+     
+            var _t = this;
+            files.forEach(function(f) {
+                _t.git([ 'add', { '': true }, f ]);
+            });  
+        },
+        commit : function( cfg )
+        {
+            
+            
+        },
+        
+        
+        
+    /*
+        public function getWorkingCopy()
+        {
+            require_once 'MTrack/SCM/Git/WorkingCopy.php';
+            return new MTrack_SCM_Git_WorkingCopy($this);
+        }
+    
+      public function getRelatedChanges($revision) // pretty nasty.. could end up with 1000's of changes..
+      {
+        $parents = array();
+        $kids = array();
+    
+        $fp = $this->git('rev-parse', "$revision^");
+        while (($line = fgets($fp)) !== false) {
+          $parents[] = trim($line);
+        }
+    
+        // Ugh!: http://stackoverflow.com/questions/1761825/referencing-the-child-of-a-commit-in-git
+        $fp = $this->git('rev-list', '--all', '--parents');
+        while (($line = fgets($fp)) !== false) {
+          $hashes = preg_split("/\s+/", $line);
+          $kid = array_shift($hashes);
+          if (in_array($revision, $hashes)) {
+            $kids[] = $kid;
+          }
+        }
+    
+        return array($parents, $kids);
+      } */
+    
+        
+         
+        
+        git: function(args_in)
+        {
+            // convert arguments.
+            
+            //print(JSON.stringify(args_in,null,4));
+            args_in.unshift( {
+                'git-dir' : this.gitdir,
+                'no-pager' : true 
+            });
+            var args = ['git' ];
+            
+            if (this.gitdir != this.repopath) {
+                args_in.unshift( { "work-tree" :  this.repopath } ); 
+            }
+            
+            args_in.forEach(function(arg) { 
+                 if (typeof(arg) == 'string') {
+                    args.push(arg);
+                    return;
+                }
+                if (typeof(arg) == 'object') {
+                    for(var k in arg) {
+                        var v = arg[k];
+                        
+                        args.push(k.length != 1 ? ('--' + k) : ('-' + k));
+                        
+                        if (v === true) {
+                            continue;;
+                        }
+                        args.push(v);
+                    }
+                }
+            });
+            this.lastCmd = args.join(" ");
+            if(this.debug) {
+               
+                print( args.join(" ")); 
+            }
+            
+            var env =  [  "HOME=" + GLib.get_home_dir() ];
+            // do not need to set gitpath..
+            //if (File.exists(this.repo + '/.git/config')) {
+                //env.push("GITPATH=" + this.repo );
+            //}
+            
+            //print(JSON.stringify(args,null,4));  Seed.quit();
+            var sp = new Spawn({
+                cwd : this.repopath,
+                args : args,
+                env : env, // optional
+                debug: this.debug,
+                exceptions : false,
+                async : false
+            });
+            sp.run();
+            //print(JSON.stringify(sp,null,4));  Seed.quit();
+            if (typeof(sp.stderr) == 'string' && sp.stderr.length) {
+                print(this.lastCmd);
+                print(sp.stderr);
+            }
+            //print("GOT: " + output)
+            // parse output for some commands ?
+            return sp.output;
+        }
+  
+   
+});
+
+Repo.parseURL = function(url)
+{
+    
+    // git : git://github.com/roojs/roojs1.git
+    // http https://roojs@github.com/roojs/roojs1.git
+    // ssh  git@github.com:roojs/roojs1.git
+    var ret = {
+       scheme : 'ssh://'
+    }
+    url = url.replace(/^[a-z]+:\/\//, function(v) {
+        ret.scheme = v;
+        return '';
+    });
+    var parts = url.split(ret.scheme == 'ssh://' ? ':' : "/");
+    var login_host  = parts.shift().split('@');
+    var user_pass  = (login_host.length == 2 ? login_host.shift() : '').split(':');
+    ret.user = user_pass[0];
+    ret.pass = user_pass.length == 2 ? user_pass[1] : ''; 
+    
+    ret.host = login_host.shift();
+    ret.path = parts.join('/');
+    return ret;
+    
+    
+}
\ No newline at end of file
diff --git a/Scm/Repo.js b/Scm/Repo.js
new file mode 100644 (file)
index 0000000..9aaca61
--- /dev/null
@@ -0,0 +1,327 @@
+var XObject = imports.XObject.XObject;
+
+var GLib  = imports.gi.GLib;
+var File = imports.File.File;
+// mix of SCM and Repo class from mtrack.
+
+//var SCM = imports.SCM.SCM;
+
+_abstract = function() {
+    throw "abstract function not implemented";
+}
+
+Repo = XObject.define(
+    function(cfg) {
+        // cal parent?
+        if (typeof(cfg) != 'object') {
+            return;
+        } 
+        XObject.extend(cfg);
+         
+    },
+    Object,
+    {
+            
+        id : null,
+         scmtype : null,
+        repopath : null,
+        browserurl : null,
+        browsertype : null,
+        description : null,
+        parent : '',
+        clonedfrom : null,
+        serverurl : null,
+
+    
+        links_to_add : false,
+        links_to_remove : false,
+        links : false,
+        
+        
+        repopath : '',
+        
+       
+        /** Returns an array keyed by possible branch names.
+        * The data associated with the branches is implementation
+        * defined.
+        * If the SCM does not have a concept of first-class branch
+        * objects, this function returns null */
+        getBranches : _abstract,
+        
+        /** Returns an array keyed by possible tag names.
+        * The data associated with the tags is implementation
+        * defined.
+        * If the SCM does not have a concept of first-class tag
+        * objects, this function returns null */
+        getTags : _abstract,
+        
+        /** Enumerates the files/dirs that are present in the specified
+        * location of the repository that match the specified revision,
+        * branch or tag information.  If no revision, branch or tag is
+        * specified, then the appropriate default is assumed.
+        *
+        * The second and third parameters are optional; the second
+        * parameter is one of 'rev', 'branch', or 'tag', and if specifed
+        * the third parameter must be the corresponding revision, branch
+        * or tag identifier.
+        *
+        * The return value is an array of MTrackSCMFile objects present
+        * at that location/revision of the repository.
+        */
+        readdir : _abstract,
+        
+        /** Queries information on a specific file in the repository.
+        *
+        * Parameters are as for readdir() above.
+        *
+        * This function returns a single MTrackSCMFile for the location
+        * in question.
+        */
+        file : _abstract,
+        
+        /** Queries history for a particular location in the repo.
+        *
+        * Parameters are as for readdir() above, except that path can be
+        * left unspecified to query the history for the entire repo.
+        *
+        * The limit parameter limits the number of entries returned; it it is
+        * a number, it specifies the number of events, otherwise it is assumed
+        * to be a date in the past; only events since that date will be returned.
+        *
+        * Returns an array of MTrackSCMEvent objects.
+        */
+        history : _abstract,
+        
+        /** Obtain the diff text representing a change to a file.
+        *
+        * You may optionally provide one or two revisions as context.
+        *
+        * If no revisions are passed in, then the change associated
+        * with the location will be assumed.
+        *
+        * If one revision is passed, then the change associated with
+        * that event will be assumed.
+        *
+        * If two revisions are passed, then the difference between
+        * the two events will be assumed.
+        */
+        diff : _abstract,
+        
+        /** Determine the next and previous revisions for a given
+        * changeset.
+        *
+        * Returns an array: the 0th element is an array of prior revisions,
+        * and the 1st element is an array of successor revisions.
+        *
+        * There will usually be one prior and one successor revision for a
+        * given change, but some SCMs will return multiples in the case of
+        * merges.
+        */
+        getRelatedChanges : _abstract,
+        
+        /** Returns a working copy object for the repo
+        *
+        * The intended purpose is to support wiki page modifications, and
+        * as such, is not meant to be an especially efficient means to do so.
+        */
+        getWorkingCopy : _abstract,
+        
+        /** Returns meta information about the SCM type; this is used in the
+        * UI and tooling to let the user know their options.
+        *
+        * Returns an array with the following keys:
+        * 'name' => 'Mercurial', // human displayable name
+        * 'tools' => array('hg'), // list of tools to find during setup
+        */
+        getSCMMetaData : _abstract,
+        
+        /** Returns the default 'root' location in the repository.
+        * For SCMs that have a concept of branches, this is the empty string.
+        * For SCMs like SVN, this is the trunk dir */
+        getDefaultRoot : function() {
+             return '';
+        },
+
+        
+          
+        
+        /* takes an MTrackSCM as a parameter because in some bootstrapping
+         * cases, we're actually MTrack_Repo and not the end-class.
+         * MTrack_Repo calls the end-class method and passes itself in for
+         * context */
+        reconcileRepoSettings  : _abstract,
+        
+        
+        
+        
+        getBrowseRootName   : _abstract, 
+        /***
+         *
+         * resolve Revision
+         *
+         * @param {string} rev - a fixed revision - always returns this if it is not false;
+         * @param {string} object [rev|branch|tag]- object type
+         * @param {ident} object id (eg. rev nun, branch name, tag name)
+         *
+         *
+         */
+        resolveRevision :function(rev, object, ident)
+        {
+            if (rev !== false) {
+                return rev;
+            }
+            
+            if (object === false) {
+                return false;
+            }
+            
+            switch (object) {
+                case 'rev':
+                    rev = ident;
+                    break;
+                
+                case 'branch':
+                    
+                    // technically we should check it exists..
+                    rev = ident;
+                    break;
+                    //var branches = this.getBranches();
+                    // branches is now an array - not a map.
+                     
+                    //rev = typeof(branches[ident]) == 'undefined' ? false : branches[ident];
+                    //break;
+                
+                case 'tag':
+                    tags = this.getTags();
+                    rev = typeof(tags[ident]) == 'undefined' ? false : tags[ident];
+                    break;
+            }
+            if (rev === false) {
+                throw   "don't know which revision to use (rev,object,ident) got" + object;
+            }
+            return rev;
+        }
+        
+    
+     /*
+    
+    function reconcileRepoSettings()
+    {
+        $c = self::Factory(array('scmtype'=>$this->scmtype));
+        $s->reconcileRepoSettings($this);
+    }
+    
+    function getServerURL()
+    {
+        if ($this->serverurl) {
+            return $this->serverurl;
+        }
+        
+        return null;
+    }
+
+    function getCheckoutCommand() {
+        $url = $this->getServerURL();
+        if (strlen($url)) {
+          return $this->scmtype . ' clone ' . $this->getServerURL();
+        }
+        return null;
+    }
+
+    function canFork() {
+        return false;
+    }
+
+    function getWorkingCopy() {
+         throw new Exception("cannot getWorkingCopy from a generic repo object");
+    }
+    /*
+    function deleteRepo(MTrackChangeset $CS) {
+        MTrackDB::q('delete from repos where repoid = ?', $this->repoid);
+        mtrack_rmdir($this->repopath);
+    }
+     
+  
+
+// these are needed just to implement the abstract interface..
+    function getBranches() {}
+    function getTags() {}
+    function readdir($path, $object = null, $ident = null) {}
+    function file($path, $object = null, $ident = null) {}
+    function history($path, $limit = null, $object = null, $ident = null){}
+    function diff($path, $from = null, $to = null) {}
+    function getRelatedChanges($revision) {}
+    function getSCMMetaData() { return null; }
+    /**
+     *  converts a commit log message (cached locally into a working object..)
+     *  see Browse.php
+     */
+    /*
+    function commitLogToEvent($str) {
+        throw new Exception("no implementation for commitLogToEvent");
+    }
+    */
+});
+
+
+/*
+    static $scms = array();
+    static function factory($ar)
+    {
+        //print_r($ar);
+        $type = ucfirst($ar['scmtype']);
+        $fn = 'MTrack/SCM/'.$type .'/Repo.php';
+        $cls = 'MTrack_SCM_'.$type .'_Repo';
+        require_once $fn;
+        
+        $ret = new $cls($ar);
+        
+        return $ret;
+        
+    }
+    
+    static function getAvailableSCMs()
+    {
+        $ret = array();
+        $ar = scandir(dirname(__FILE__).'/SCM');
+        
+        foreach($ar as $a) {
+            if (empty($a) || $a[0] == '.') {
+                continue;
+            }
+            $fn = dirname(__FILE__).'/SCM/'.$a.'/Repo.php';
+            if (!file_exists($fn)) {
+                continue;
+            } 
+            $ret[$a] = MTrack_Repo::factory(array('scmtype'=> $a));
+            
+        }
+        return $ret;
+    }  
+*/
+
+Repo._list  = false;
+Repo.list = function()
+{
+    
+    if (Repo._list !== false) {
+        return Repo._list;
+    }
+    Repo._list  = [];
+    var dir = GLib.get_home_dir() + '/gitlive';
+    var ar = File.list(dir );
+    print(JSON.stringify(ar));
+    ar.forEach(function(f) {
+        if (File.exists(dir + '/' + f +'/.git')) {
+            Repo._list.push(new imports.Scm.Git.Repo.Repo({repopath : dir  +'/' + f }))
+            
+        }
+        
+    });
+    
+    return Repo._list;
+      
+}
+