GitRepo.vala
[gitlive] / GitRepo.vala
1
2 /**
3  * @class Scm.Git.Repo
4  *
5  * @extends Scm.Repo
6  * 
7  *
8  *
9  */
10 static GitRepo  _GitRepo; 
11  
12 public class GitRepo : Object
13 {
14      
15     public Gee.ArrayList<GitMonitorQueue> cmds;
16
17     public string name;
18     public string gitdir;
19     public string git_working_dir;
20     public bool debug = false;
21     public bool has_local_changes = false;
22     public string git_status;    
23     public string git_diff;        
24     public string ahead_or_behind = "";
25     
26     public Gee.HashMap<string,bool> ignore_files;
27     public GitBranch currentBranch;
28     public Gee.HashMap<string,GitBranch> branches; // accessed in GitBranch..
29         public RooTicket? activeTicket;
30     public  Gee.HashMap<string,GitRepo> cache;
31     
32     
33     
34         public static GitRepo singleton()
35     {
36         if (_GitRepo == null) {
37             _GitRepo = new GitRepo.single();
38             _GitRepo.cache = new Gee.HashMap<string,GitRepo>();
39         }
40         return _GitRepo;
41     }
42  
43     /**
44     * index of.. matching gitpath..
45     */
46     public static int indexOf( Array<GitRepo> repos, string gitpath) {
47         // make a fake object to compare against..
48         var test_repo = GitRepo.get(gitpath);
49         
50         for(var i =0; i < repos.length; i++) {
51             if (repos.index(i).gitdir == test_repo.gitdir) {
52                 return i;
53             }
54         }
55         return -1;
56     
57     }
58     
59
60     
61     
62     
63     public static   Array<GitRepo> list()
64     {
65
66         //if (GitRepo.list_cache !=  null) {
67         //    unowned  Array<GitRepo>    ret = GitRepo.list_cache;
68          //   return ret;
69         //}
70         var cache = GitRepo.singleton().cache;
71         var list_cache = new Array<GitRepo>();
72         
73         var dir = Environment.get_home_dir() + "/gitlive";
74         
75         var f = File.new_for_path(dir);
76         FileEnumerator file_enum;
77         try {
78             file_enum = f.enumerate_children(
79                 FileAttribute.STANDARD_DISPLAY_NAME + ","+ 
80                 FileAttribute.STANDARD_TYPE,
81                 FileQueryInfoFlags.NONE,
82                 null);
83         } catch (Error e) {
84             
85             return list_cache;
86             
87         }
88         
89         FileInfo next_file; 
90         
91         while (true) {
92             
93             try {
94                 next_file = file_enum.next_file(null);
95                 if (next_file == null) {
96                     break;
97                 }
98                 
99             } catch (Error e) {
100                 GLib.debug("Error: %s",e.message);
101                 break;
102             }
103          
104             //print("got a file " + next_file.sudo () + '?=' + Gio.FileType.DIRECTORY);
105             
106             if (next_file.get_file_type() !=  FileType.DIRECTORY) {
107                 next_file = null;
108                 continue;
109             }
110             
111             if (next_file.get_file_type() ==  FileType.SYMBOLIC_LINK) {
112                 next_file = null;
113                 continue;
114             }
115             
116             if (next_file.get_display_name()[0] == '.') {
117                 next_file = null;
118                 continue;
119             }
120             var sp = dir+"/"+next_file.get_display_name();
121            
122             var gitdir = dir + "/" + next_file.get_display_name() + "/.git";
123             
124             if (!FileUtils.test(gitdir, FileTest.IS_DIR)) {
125                 continue;
126             }
127             
128                 var rep =  GitRepo.get(  sp );
129                 list_cache.append_val(rep);             
130             
131         }
132     
133         return list_cache;
134          
135         }
136         
137         public static GitRepo get(string path) 
138         {
139                 var cache = GitRepo.singleton().cache;
140                 if (cache.has_key(path)) {
141                         return cache.get(path);
142                 }
143                 return new GitRepo(path);
144         }
145         
146     private GitRepo.single() {
147                 // used to create the signleton
148         }
149     /**
150      * constructor:
151      * 
152      * @param {Object} cfg - Configuration
153      *     (basically repopath is currently only critical one.)
154      *
155      */
156      
157     private GitRepo(string path) {
158         // cal parent?
159         this.name =   File.new_for_path(path).get_basename();
160         this.ignore_files = new Gee.HashMap<string,bool>();
161         
162         this.git_working_dir = path;
163         this.gitdir = path + "/.git";
164         if (!FileUtils.test(this.gitdir , FileTest.IS_DIR)) {
165             this.gitdir = path; // naked...
166         }
167         this.cmds = new  Gee.ArrayList<GitMonitorQueue> ();
168         
169                 var cache = GitRepo.singleton().cache;
170         //Repo.superclass.constructor.call(this,cfg);
171                 if ( !cache.has_key(path) ) {
172                         cache.set( path, this);
173         }
174         this.loadBranches();
175         this.loadActiveTicket();
176         this.loadStatus();
177     } 
178     
179     public bool is_wip_branch()
180     {
181         return this.currentBranch.name.has_prefix("wip_");
182                 
183     }
184     
185     public bool is_managed()
186     {
187         // is it a roojs origin?
188         var r = this.git({ "remote" , "get-url" , "--push" , "origin"});
189         
190         
191         return FileUtils.test(this.gitdir + "/.gitlive-managed" , FileTest.EXISTS);
192     }
193     
194     
195     public bool is_autocommit ()
196     {
197         return !FileUtils.test(this.gitdir + "/.gitlive-disable-autocommit" , FileTest.EXISTS);
198     }
199     public void set_autocommit(bool val)
200     {
201
202                 var cur = this.is_autocommit();
203                 GLib.debug("SET auto commit : %s <= %s", val ? "ON" : "OFF",  cur  ? "ON" : "OFF");
204                 if (cur == val) {
205                         return; // no change..
206                 }
207                 if (!val) {
208                         FileUtils.set_contents(this.gitdir + "/.gitlive-disable-autocommit" , "x");
209                 } else {
210                         // it exists...
211                         FileUtils.remove(this.gitdir + "/.gitlive-disable-autocommit" ); 
212                 }
213     
214     }
215     
216     public bool is_auto_branch ()
217     {
218         return FileUtils.test(this.gitdir + "/.gitlive-enable-auto-branch" , FileTest.EXISTS);
219     }
220     
221     public void set_auto_branch(bool val)
222     {
223
224                 var cur = this.is_auto_branch();
225                 GLib.debug("SET auto branch : %s <= %s", val ? "ON" : "OFF",  cur  ? "ON" : "OFF");
226                 
227                 if (cur == val) {
228                         return; // no change..
229                 }
230                 if (val) {
231                         FileUtils.set_contents(this.gitdir + "/.gitlive-enable-auto-branch" , "x");
232                 } else {
233                         // it exists...
234                         FileUtils.remove(this.gitdir + "/.gitlive-enable-auto-branch" ); 
235                 }
236     
237     }
238     public bool is_autopush ()
239     {
240         return !FileUtils.test(this.gitdir + "/.gitlive-disable-autopush" , FileTest.EXISTS);
241     }
242     public void set_autopush(bool val)
243     {
244
245                 var cur = this.is_autopush();
246                 GLib.debug("SET auto push : %s <= %s", val ? "ON" : "OFF",  cur  ? "ON" : "OFF");
247                 if (cur == val) {
248                         return; // no change..
249                 }
250                 if (!val) {
251                         FileUtils.set_contents(this.gitdir + "/.gitlive-disable-autopush" , "");
252                 } else {
253                         // it exists...
254                         FileUtils.remove(this.gitdir + "/.gitlive-disable-autopush" ); 
255                 }
256     
257     }
258     
259     
260         public void loadStatus()
261         {
262                 var r = this.git({ "status" , "--porcelain" });
263                 this.git_status = r;
264                 this.has_local_changes = r.length > 0;
265                 
266                 var rs = this.git({ "status" , "-sb" });
267
268                 this.ahead_or_behind = rs.contains("[ahead") ? "A" : (rs.contains("[behind") ? "B" : "");
269                 
270                 
271                 this.git_diff  = this.git({ "diff" , "HEAD", "--no-color" });
272         }    
273
274     
275     public void loadBranches()
276     {
277         GitBranch.loadBranches(this);
278     }
279      
280     
281     
282     
283     public string branchesToString()
284     {
285         var ret = "";
286                 foreach( var br in this.branches.values) {
287                         if (br.name == "") {
288                                 continue; 
289                         }
290                         ret += ret.length > 0 ? "\n"  : "";
291                         ret += br.name;
292                 
293                 }
294                 return ret;
295         
296     }
297      public static void doMerges(string action, string ticket_id, string commit_message)
298     {
299        GitMonitor.gitmonitor.stop();
300        
301        var commitrevs = "";
302        var sucess = true;
303        foreach(var  repo in GitRepo.singleton().cache.values) {
304                if (repo.activeTicket != null && repo.activeTicket.id == ticket_id) {
305                        var res = repo.doMerge(action,ticket_id, commit_message);
306                        if (!res) {
307                                sucess = false;
308                                continue;
309                        }
310                        commitrevs += commitrevs.length > 0 ? " " : "";
311                        commitrevs += repo.currentBranch.lastrev;
312                }
313        }
314        if (sucess && action == "CLOSE") {
315                RooTicket.singleton().getById(ticket_id).close(commitrevs);
316        }
317        GitMonitor.gitmonitor.start();
318     }
319      
320
321     public bool doMerge(string action, string ticket_id, string commit_message)
322     {
323        // in theory we should check to see if other repo's have got the same branch and merge all them at the same time.
324        // also need to decide which branch we will merge into?
325                    var ret = "";
326                    if (action == "CLOSE" || action == "LEAVE") {
327                                    
328                try {
329                    var oldbranch = this.currentBranch.name;
330                    this.setActiveTicket(null, "master");
331                            string [] cmd = { "merge",   "--squash",  oldbranch };
332                            this.git( cmd );
333                            cmd = { "commit",   "-a" , "-m",  commit_message };
334                            this.git( cmd );
335                            this.push();
336                            this.loadBranches(); // updates lastrev..
337                
338                        var notification = new Notify.Notification(
339                                "Merged branch %s to master".printf(oldbranch),
340                                "",
341                                 "dialog-information"
342                                
343                        );
344
345                        notification.set_timeout(5);
346                        notification.show();   
347                
348                // close ticket..
349                return true; 
350                
351            } catch (Error e) {
352
353                GitMonitor.gitmonitor.pauseError(e.message);
354                return false;
355            }
356            // error~?? -- show the error dialog...
357                    return false;
358        }
359        if (action == "MASTER") {
360                // merge master into ours..
361                        try {
362                        string[] cmd = { "merge",  "master" };
363                        this.git( cmd );
364                        var notification = new Notify.Notification(
365                                        "Merged code from master to %s".printf(this.currentBranch.name),
366                                        "",
367                                         "dialog-information"
368                                        
369                                );
370                                notification.set_timeout(5);
371                                notification.show();   
372                       
373                        return true;
374                        } catch (Error e) {
375                        GitMonitor.gitmonitor.pauseError(e.message);
376                        return false;
377                    }
378            }
379        if (action == "EXIT") {
380                        try {
381                        var oldbranch  = this.currentBranch.name;
382                          this.setActiveTicket(null, "master");
383                        this.loadBranches();
384                        var notification = new Notify.Notification(
385                                        "Left branch %s".printf(oldbranch),
386                                        "",
387                                         "dialog-information"
388                                        
389                                );
390                                notification.set_timeout(5);
391                                notification.show();   
392                        
393                        return true;
394                    } catch (Error e) {
395                        GitMonitor.gitmonitor.pauseError(e.message);
396
397                        return false;                   
398                    }
399                    // error~?? -- show the error dialog...
400
401        }
402        return false;
403     }
404         
405     public void loadActiveTicket()
406     {
407         this.activeTicket = null;
408         if (!FileUtils.test(this.gitdir + "/.gitlive-active-ticket" , FileTest.EXISTS)) {
409                 return;
410         }
411         string ticket_id;
412         FileUtils.get_contents(this.gitdir + "/.gitlive-active-ticket" , out ticket_id);  
413         if (ticket_id.length < 1) {
414                 return;
415                 }
416                 this.activeTicket = RooTicket.singleton().getById(ticket_id.strip());
417         
418         
419     }
420     
421     
422     
423     public bool setActiveTicket(RooTicket? ticket, string branchname)
424     {
425         if (!this.createBranchNamed(branchname)) {
426                 return false;
427                 }
428                 if (ticket != null) {
429                 FileUtils.set_contents(this.gitdir + "/.gitlive-active-ticket" , ticket.id);
430         } else {
431                 FileUtils.remove(this.gitdir + "/.gitlive-active-ticket" );
432         }
433         this.activeTicket = ticket;
434         return true;
435     }
436     
437     public bool createBranchNamed(string branchname)
438     {   
439                 
440
441                      if (this.branches.has_key(branchname)) {
442                         this.switchToExistingBranchNamed(branchname);
443                     
444                     } else {
445                                  this.createNewBranchNamed(branchname); 
446                             
447                     }
448                        var notification = new Notify.Notification(
449                        "Changed to branch %s".printf(branchname),
450                        "",
451                         "dialog-information"
452                        
453                );
454
455                notification.set_timeout(5);
456                notification.show();   
457        
458          
459          this.loadBranches(); // update branch list...
460          //GitMonitor.gitmonitor.runQueue(); // no point - we have hidden the queue..
461          return true;
462     }
463      bool switchToExistingBranchNamed(string branchname)
464      {
465                 var stash = false;
466                                          // this is where it get's tricky...
467                 string files = "";
468                 try {                   
469                                 string[] cmd = { "ls-files" ,  "-m" };                   // list the modified files..
470                                 files = this.git(cmd);
471                                 stash = files.length> 1 ;
472                                 
473                                 
474                                 cmd = { "stash" };                      
475                                 if (stash) { this.git(cmd); }
476                                 
477                                 this.pull();
478                                 
479                                 cmd = { "checkout", branchname  };
480                                 this.git(cmd);
481                   } catch(Error e) {
482                                 GitMonitor.gitmonitor.pauseError(e.message);
483                                 return false;           
484                   }
485                 try {
486                    if (branchname != "master") {
487                        string[] cmd = { "merge", "master"  };
488                             this.git(cmd);
489                             this.push();
490                        
491                     }
492                     
493                 } catch(Error e) {
494                     string[] cmd = { "checkout", "master"  };
495                     this.git(cmd);
496                         GitMonitor.gitmonitor.pauseError(
497                                 "Use\n\na) git checkout %s\nb) git mergetool\nc) git commit\nd) git push\n d) stash pop \ne) start gitlive again\n".printf(
498                                         branchname)
499                                  + e.message
500                         );
501                         return false;           
502                  
503                 }
504                 try {                                   
505                     string[]  cmd = { "stash", "pop"  };
506                     if (stash) { 
507                         this.git(cmd); 
508                         var fl = files.split("\n");
509                         cmd = { "commit", "-m" , "Changed " + string.joinv("",fl) };
510                         foreach(var f in fl) {
511                                 if (f.length < 1) continue;
512                                 cmd += f;
513                         }
514                         this.git(cmd);                              
515                 }
516              
517
518                    
519                 } catch(Error ee) {
520                         GitMonitor.gitmonitor.pauseError(ee.message);
521                         return false;           
522                 }
523        this.push();
524        return true;                             
525                  
526      }
527     
528     
529     
530      bool createNewBranchNamed(string branchname)
531      {
532                 var stash = false;
533                  try {                                  
534                                 string[] cmd = { "ls-files" ,  "-m" };                   // list the modified files..
535                                 var files = this.git(cmd);
536                                 stash = files.length> 1 ;
537                         
538                          cmd = { "checkout", "-b" , branchname  };
539                         this.git(cmd);
540
541                cmd = { "push", "-u" , "origin" ,"HEAD"  };
542                         this.git(cmd);
543                                 if (stash) { 
544
545                                 var fl = files.split("\n");
546                                 cmd = { "commit", "-m" , "Changed " + string.joinv("",fl) };
547                                 foreach(var f in fl) {
548                                         if (f.length < 1) continue;
549                                         cmd += f;
550                                 }
551                                 this.git(cmd);  
552                                 this.push();                        
553                         }
554
555              
556                 } catch(Error ee) {
557                                 GitMonitor.gitmonitor.pauseError(ee.message);
558                                 return false;           
559                         }
560                         return true;
561      
562      }
563     
564     
565     
566     /**
567      * add:
568      * add files to track.
569      *
570      * @argument {Array} files the files to add.
571      */
572     public string add ( Gee.ArrayList<GitMonitorQueue> files ) throws Error, SpawnError
573     {
574         // should really find out if these are untracked files each..
575         // we run multiple versions to make sure that if one failes, it does not ignore the whole lot..
576         // not sure if that is how git works.. but just be certian.
577         var ret = "";
578         for (var i = 0; i < files.size;i++) {
579             var f = files.get(i).vname;
580             try {
581                 string[] cmd = { "add",    f  };
582                 this.git( cmd );
583             } catch (Error e) {
584                 ret += e.message  + "\n";
585             }        
586
587         }
588         return ret;
589     }
590         
591     public bool is_ignore(string fname) throws Error, SpawnError
592     {
593                 if (fname == ".gitignore") {
594                         this.ignore_files.clear();
595                 }
596                 
597                 if (this.ignore_files.has_key(fname)) {
598                         return this.ignore_files.get(fname);
599                 }
600                 
601                 try {
602                         var ret = this.git( { "check-ignore" , fname } );
603                         this.ignore_files.set(fname, ret.length >  0);
604                         return ret.length > 0;
605                 } catch (SpawnError e) {
606                         this.ignore_files.set(fname, false);
607                         return false;
608                 }
609                  
610     } 
611     
612     
613       /**
614      * remove:
615      * remove files to track.
616      *
617      * @argument {Array} files the files to add.
618      */
619     public string remove  ( Gee.ArrayList<GitMonitorQueue> files ) throws Error, SpawnError
620     {
621         // this may fail if files do not exist..
622         // should really find out if these are untracked files each..
623         // we run multiple versions to make sure that if one failes, it does not ignore the whole lot..
624         // not sure if that is how git works.. but just be certian.
625         var ret = "";
626
627         for (var i = 0; i < files.size;i++) {
628             var f = files.get(i).vname;
629             try {
630                 string[] cmd = { "rm",  "-f" ,  f  };
631                 this.git( cmd );
632             } catch (Error e) {
633                 ret += e.message  + "\n";
634             }        
635         }
636
637         return ret;
638
639     }
640     
641     
642     /**
643      * commit:
644      * perform a commit.
645      *
646      * @argument {Object} cfg commit configuration
647      * 
648      * @property {String} name (optional)
649      * @property {String} email (optional)
650      * @property {String} changed (date) (optional)
651      * @property {String} reason (optional)
652      * @property {Array} files - the files that have changed. 
653      * 
654      */
655      
656     public string commit ( string message, Gee.ArrayList<GitMonitorQueue> files  ) throws Error, SpawnError
657     {
658         
659
660         /*
661         var env = [];
662
663         if (typeof(cfg.name) != 'undefined') {
664             args.push( {
665                 'author' : cfg.name + ' <' + cfg.email + '>'
666             });
667             env.push(
668                 "GIT_COMMITTER_NAME" + cfg.name,
669                 "GIT_COMMITTER_EMAIL" + cfg.email
670             );
671         }
672
673         if (typeof(cfg.changed) != 'undefined') {
674             env.push("GIT_AUTHOR_DATE= " + cfg.changed )
675             
676         }
677         */
678         string[] args = { "commit", "-m" };
679         args +=  (message.length > 0  ? message : "Changed" );
680         for (var i = 0; i< files.size ; i++ ) {
681             args += files.get(i).vname; // full path?
682         }
683          
684         return this.git(args);
685     }
686     
687     /**
688      * pull:
689      * Fetch and merge remote repo changes into current branch..
690      *
691      * At present we just need this to update the current working branch..
692      * -- maybe later it will have a few options and do more stuff..
693      *
694      */
695     public string pull () throws Error, SpawnError
696     {
697         // should probably hand error conditions better... 
698         string[] cmd = { "pull" , "--no-edit" };
699         return this.git( cmd );
700
701         
702     }
703     
704     public delegate void GitAsyncCallback (GitRepo repo, int err, string str);
705     public void pull_async(GitAsyncCallback cb) 
706     {
707     
708          string[] cmd = { "pull" , "--no-edit" };
709          this.git_async( cmd , cb);
710          
711     
712     }
713     
714     /**
715      * push:
716      * Send local changes to remote repo(s)
717      *
718      * At present we just need this to push the current branch.
719      * -- maybe later it will have a few options and do more stuff..
720      *
721      */
722     public string push () throws Error, SpawnError
723     {
724         // should 
725         return this.git({ "push"  });
726         
727     }
728     
729     
730     
731      /**
732      * git:
733      * The meaty part.. run spawn.. with git..
734      *
735      *
736      */
737     
738     public string git(string[] args_in ) throws Error, SpawnError
739     {
740         // convert arguments.
741         
742         string[]  args = { "git" };
743         //args +=  "--git-dir";
744         //args +=  this.gitdir;
745         args +=  "--no-pager";
746  
747  
748         //if (this.gitdir != this.repopath) {
749         //    args +=   "--work-tree";
750          //   args += this.repopath; 
751         //}
752         for (var i = 0; i < args_in.length;i++) {
753             args += args_in[i];
754         }            
755
756         //this.lastCmd = args.join(" ");
757         //if(this.debug) {
758             GLib.debug( "CWD=%s",  this.git_working_dir ); 
759             GLib.debug( "cmd: %s", string.joinv (" ", args)); 
760         //}
761
762         string[]   env = {};
763         string  home = "HOME=" + Environment.get_home_dir() ;
764         env +=  home ;
765         // do not need to set gitpath..
766         //if (File.exists(this.repo + '/.git/config')) {
767             //env.push("GITPATH=" + this.repo );
768         //}
769           
770         var cfg = new SpawnConfig(this.git_working_dir , args , env);
771         //cfg.debug = true;
772
773        // may throw error...
774         var sp = new Spawn(cfg);
775       
776         // diff output is a bit big..
777                 if (args_in[0] != "diff") {
778                 GLib.debug( "GOT: %s" , sp.output);
779         }
780         // parse output for some commands ?
781         return sp.output;
782     }
783         
784    unowned GitAsyncCallback git_async_on_callback;
785         public void  git_async( string[] args_in,   GitAsyncCallback cb ) throws Error, SpawnError
786     {
787         // convert arguments.
788        this.git_async_on_callback = cb;
789         string[]  args = { "git" };
790         //args +=  "--git-dir";
791         //args +=  this.gitdir;
792         args +=  "--no-pager";
793  
794  
795         //if (this.gitdir != this.repopath) {
796         //    args +=   "--work-tree";
797          //   args += this.repopath; 
798         //}
799         for (var i = 0; i < args_in.length;i++) {
800             args += args_in[i];
801         }            
802
803         //this.lastCmd = args.join(" ");
804         //if(this.debug) {
805             GLib.debug( "CWD=%s",  this.git_working_dir ); 
806             //print( "cmd: %s\n", string.joinv (" ", args)); 
807         //}
808
809         string[]   env = {};
810         string  home = "HOME=" + Environment.get_home_dir() ;
811         env +=  home ;
812         // do not need to set gitpath..
813         //if (File.exists(this.repo + '/.git/config')) {
814             //env.push("GITPATH=" + this.repo );
815         //}
816         
817
818         var cfg = new SpawnConfig(this.git_working_dir , args , env);
819         cfg.async = true;
820        
821
822        // may throw error...
823         var sp = new Spawn(cfg);
824                 //sp.ref();
825         //this.ref();
826         sp.run(this.git_async_on_complete); 
827          
828     }
829     
830     void git_async_on_complete(int err, string output)
831     {
832                 GLib.debug("GOT %d : %s", err, output);
833                 this.git_async_on_callback(this, err, output);
834 //              this.unref();   
835         //      sp.unref();             
836     
837     
838     }
839     
840  
841          
842     
843  
844     public void update_async(GitAsyncCallback cb) 
845     {
846          string[] cmd = { "fetch" , "--all" };
847          this.git_async( cmd , cb);
848          
849     }
850     
851     
852     static uint update_all_total = 0;
853     static string update_all_after = "";
854      
855     public static void updateAll(string after)
856     {
857                         update_all_after = after;
858                 var tr =  GitRepo.singleton().cache;
859                 
860             
861            update_all_total = tr.size;
862            foreach(var repo  in tr.values) {
863                    repo.update_async(updateAllCallback); 
864             } 
865
866     }
867     public static void  updateAllCallback(GitRepo repo, int err, string res)
868     {
869         repo.loadBranches();
870         repo.loadStatus();
871         
872         update_all_total--;
873         if (update_all_total > 0 ) {
874                 return;
875                 }
876                 switch (update_all_after) {
877                         case "show_clones":
878                                 Clones.singleton().show();
879                                 break;
880                         default:
881                                 break;
882                 }
883                 return;
884     }
885     
886     
887     
888 }