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