comparison upmana/updatemana.py @ 81:65c212e9a5b4 ornery-dev

Controls panel is completed. Users cannot delete branches nicely without a Merc upgrade, so that feature will appear in Pious Paladin. Crash report is being tested on windows.
author sirebral
date Wed, 26 Aug 2009 23:24:45 -0500
parents 51bb772c3609
children f38df4bf9715
comparison
equal deleted inserted replaced
80:51bb772c3609 81:65c212e9a5b4
481 self.sizer.AddGrowableRow(2) 481 self.sizer.AddGrowableRow(2)
482 self.SetSizer(self.sizer) 482 self.SetSizer(self.sizer)
483 self.SetAutoLayout(True) 483 self.SetAutoLayout(True)
484 484
485 self.current = self.repo.dirstate.branch() 485 self.current = self.repo.dirstate.branch()
486 486 self.currev = self.repo.changelog.rev(self.repo.branchtags()[self.current])
487 self.RevInfo(self.current) 487 self.RevInfo(self.currev)
488 self.revlist.Select(self.revlist.FindItem(0, 488 self.revlist.Select(self.revlist.FindItem(0, str(self.currev), 1))
489 str(self.repo.changelog.rev(self.repo.branchtags()[self.current]))),
490 True)
491
492 self.BranchInfo(self.current) 489 self.BranchInfo(self.current)
493 self.Bind(wx.EVT_CHOICE, self.PackageSet) 490 self.Bind(wx.EVT_CHOICE, self.PackageSet)
494 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.PackageSet) 491 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.RevSet)
492 self.Bind(wx.EVT_BUTTON, self.RevUpdate, self.buttons['update'])
493
495 494
496 def PackageSet(self, event): 495 def PackageSet(self, event):
497
498 self.current = self.branches.GetStringSelection() 496 self.current = self.branches.GetStringSelection()
499 branches = self.repo.branchtags() 497 branches = self.repo.branchtags()
500 heads = dict.fromkeys(self.repo.heads(), 1) 498 heads = dict.fromkeys(self.repo.heads(), 1)
501 l = [((n in heads), self.repo.changelog.rev(n), n, t) for t, n in branches.items()] 499 l = [((n in heads), self.repo.changelog.rev(n), n, t) for t, n in branches.items()]
502
503 if self.current != type: 500 if self.current != type:
504 heads = dict.fromkeys(self.repo.heads(), self.repo.branchtags()) 501 heads = dict.fromkeys(self.repo.heads(), self.repo.branchtags())
505 branches = dict.copy(self.repo.branchtags()) 502 branches = dict.copy(self.repo.branchtags())
506 self.BranchInfo(self.current) 503 self.BranchInfo(self.current)
507 self.RevInfo(self.current) 504 self.RevInfo(self.current)
508 505
509 def RevInfo(self, branch): 506 def RevSet(self, event):
507 self.currev = self.revlist.GetItemText( self.revlist.GetFirstSelected() )
508 i = event.GetIndex()
509 self.revlist.Select(i, True)
510 self.revlist.Focus(i)
511 if self.currev != self.revlist.GetItemText( self.revlist.GetFirstSelected() ):
512 self.RevInfo(self.currev)
513
514 def RevInfo(self, rev):
510 self.revlist.DeleteAllItems() 515 self.revlist.DeleteAllItems()
511 for heads in self.repo.changelog.reachable(self.repo.branchtags()[branch]): 516 self.revlist_a = []; self.revlist_b = {}
512 self.revlist.InsertStringItem(0, str(self.repo.changelog.rev(heads)), 0 ) 517 for heads in self.repo.changelog.reachable(self.repo.branchtags()[self.current]):
513 self.revlist.SetStringItem(0, 1, str(self.repo.changectx(heads))) 518 self.revlist_a.append(str(self.repo.changelog.rev(heads)))
519 self.revlist_b[str(self.repo.changelog.rev(heads))] = str(self.repo.changectx(heads))
520 self.revlist_a.sort()
521 for i in self.revlist_a:
522 self.revlist.InsertStringItem(0, str(i), 0 )
523 self.revlist.SetStringItem(0, 1, self.revlist_b[i])
514 self.revlist.SetColumnWidth(0, -1) 524 self.revlist.SetColumnWidth(0, -1)
515 self.revlist.SetColumnWidth(1, -1) 525 self.revlist.SetColumnWidth(1, -1)
516 self.revlist.Refresh() 526 self.revlist.Refresh()
527 self.BranchInfo(self.current)
517 528
518 def BranchInfo(self, branch): 529 def BranchInfo(self, branch):
519 rev = self.revlist.GetItemText( self.revlist.GetFirstSelected() ) 530 rs = self.repo.changectx( self.currev ).changeset()
520 rs = self.repo.changectx( rev ).changeset()
521 self.changelog.SetValue('') 531 self.changelog.SetValue('')
522 changelog = rs[4] 532 changelog = rs[4]
523 self.changelog.AppendText(changelog + '\n') 533 self.changelog.AppendText(changelog + '\n')
524 self.filelist.SetValue('') 534 self.filelist.SetValue('')
525 self.filelist.AppendText("Currently selected branch: " + branch + "\n\nAuthor: "+rs[1]+"\n\n") 535 self.filelist.AppendText("Currently selected branch: " + branch + "\n\nAuthor: "+rs[1]+"\n\n")
526 self.filelist.AppendText("Files Modified (in update): \n") 536 self.filelist.AppendText("Files Modified (in update): \n")
527 for f in rs[3]: self.filelist.AppendText(f+"\n") 537 for f in rs[3]: self.filelist.AppendText(f+"\n")
538
539 def DelBranch(self, event):
540 pass
541
542 def RevUpdate(self, event):
543 filename = 'ignorelist.txt'
544 self.filename = dir_struct["home"] + 'upmana' + os.sep + filename
545 component.get('validate').config_file(filename, "default_ignorelist.txt")
546 self.mana = self.LoadDoc()
547 temp = dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep
548 for ignore in self.ignorelist:
549 shutil.copy(ignore, temp + ignore.split('/')[len(ignore.split('/')) - 1])
550 hg.clean(self.repo, self.currev)
551 for ignore in self.ignorelist:
552 shutil.copyfile(temp + ignore.split('/')[len(ignore.split('/')) - 1], ignore)
553 os.remove(temp + ignore.split('/')[len(ignore.split('/')) - 1])
554 pass
555
556 def LoadDoc(self):
557 ignore = open(self.filename)
558 self.ignorelist = []
559 for i in ignore: self.ignorelist.append(str(i [:len(i)-1]))
560 manifest = ignore.readlines()
561 ignore.close()
528 562
529 def get_packages(self, type=None): 563 def get_packages(self, type=None):
530 #Fixed and ready for Test. Can be cleaner 564 #Fixed and ready for Test. Can be cleaner
531 self.package_list = [] 565 self.package_list = []
532 b = self.repo.branchtags() 566 b = self.repo.branchtags()
615 temp = dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep 649 temp = dir_struct["home"] + 'upmana' + os.sep + 'tmp' + os.sep
616 for ignore in self.ignorelist: 650 for ignore in self.ignorelist:
617 shutil.copy(ignore, temp + ignore.split('/')[len(ignore.split('/')) - 1]) 651 shutil.copy(ignore, temp + ignore.split('/')[len(ignore.split('/')) - 1])
618 hg.clean(self.repo, self.current) 652 hg.clean(self.repo, self.current)
619 for ignore in self.ignorelist: 653 for ignore in self.ignorelist:
620 print ignore.split('/')[len(ignore.split('/')) - 1]
621 shutil.copyfile(temp + ignore.split('/')[len(ignore.split('/')) - 1], ignore) 654 shutil.copyfile(temp + ignore.split('/')[len(ignore.split('/')) - 1], ignore)
622 os.remove(temp + ignore.split('/')[len(ignore.split('/')) - 1]) 655 os.remove(temp + ignore.split('/')[len(ignore.split('/')) - 1])
623 else: print 'No default repository set, skipping Auto Update!' #Add better warning! 656 else: wx.MessageBox('No default Rpository set. Skipping Auto Update!', 'Info')
624 657
625 def LoadDoc(self): 658 def LoadDoc(self):
626 ignore = open(self.filename) 659 ignore = open(self.filename)
627 self.ignorelist = [] 660 self.ignorelist = []
628 for i in ignore: self.ignorelist.append(str(i [:len(i)-1])) 661 for i in ignore: self.ignorelist.append(str(i [:len(i)-1]))