comparison upmana/updatemana.py @ 80:51bb772c3609 ornery-dev

Update Manager nearly 100% complete. Buttons on Controls panel need to be implmented. Users can now look over the revisions for each branch / revision.
author sirebral
date Mon, 24 Aug 2009 00:56:09 -0500
parents 57887ab0df51
children 65c212e9a5b4
comparison
equal deleted inserted replaced
79:dd4be4817377 80:51bb772c3609
1 import wx 1 import wx
2 import sys 2 import sys
3 import os #just .sep maybe 3 import os #just .sep maybe
4 import manifest 4 import manifest
5 import shutil 5 import shutil
6
6 from orpg.orpgCore import component 7 from orpg.orpgCore import component
7 from orpg.dirpath import dir_struct 8 from orpg.dirpath import dir_struct
8 from orpg.tools.orpg_log import logger 9 from orpg.tools.orpg_log import logger, crash
9 from orpg.tools.decorators import debugging 10 from orpg.tools.decorators import debugging
10 from upmana.validate import validate 11 from upmana.validate import validate
11 from orpg.dirpath import dir_struct 12 from orpg.dirpath import dir_struct
12 from mercurial import ui, hg, commands, repo, revlog, cmdutil, util 13 from mercurial import ui, hg, commands, repo, revlog, cmdutil, util
13 14
171 branches = dict.copy(self.repo.branchtags()) 172 branches = dict.copy(self.repo.branchtags())
172 self.BranchInfo(self.current) 173 self.BranchInfo(self.current)
173 174
174 def BranchInfo(self, branch): 175 def BranchInfo(self, branch):
175 cs = self.repo.changectx( self.current ).changeset() 176 cs = self.repo.changectx( self.current ).changeset()
176 rev = self.repo.changelog.rev(self.repo.branchtags()[self.current]) #Current revision number. Use in Controls
177 #print self.repo.changelog.reachable(self.repo.branchtags()[self.current])
178 #for heads in self.repo.changelog.reachable(self.repo.branchtags()[self.current]):
179 # print self.repo.changelog.rev(heads)
180 self.changelog.SetValue('') 177 self.changelog.SetValue('')
181 changelog = cs[4] 178 changelog = cs[4]
182 self.changelog.AppendText(changelog + '\n') 179 self.changelog.AppendText(changelog + '\n')
183 self.filelist.SetValue('') 180 self.filelist.SetValue('')
184 self.filelist.AppendText("Currently selected branch: " + branch + "\n\nAuthor: "+cs[1]+"\n\n") 181 self.filelist.AppendText("Currently selected branch: " + branch + "\n\nAuthor: "+cs[1]+"\n\n")
443 self.branches = wx.Choice(branchcp, wx.ID_ANY, choices=self.package_list) 440 self.branches = wx.Choice(branchcp, wx.ID_ANY, choices=self.package_list)
444 self.branch_txt = wx.StaticText(branchcp, wx.ID_ANY, "Branches") 441 self.branch_txt = wx.StaticText(branchcp, wx.ID_ANY, "Branches")
445 self.branchcp.Add(self.branches, (0,0)) 442 self.branchcp.Add(self.branches, (0,0))
446 self.branchcp.Add(self.branch_txt, (0,1), flag=wx.ALIGN_CENTER_VERTICAL) 443 self.branchcp.Add(self.branch_txt, (0,1), flag=wx.ALIGN_CENTER_VERTICAL)
447 branchcp.SetSizer(self.branchcp) 444 branchcp.SetSizer(self.branchcp)
448 self.branchcp.AddGrowableCol(1)
449 branchcp.SetAutoLayout(True) 445 branchcp.SetAutoLayout(True)
450 446
451 revlistcp = wx.Panel(self) 447 revlistcp = wx.Panel(self)
452 self.revlistcp = wx.GridBagSizer(hgap=2, vgap=2) 448 self.revlistcp = wx.GridBagSizer(hgap=2, vgap=2)
453 self.revlist = wx.ListCtrl(revlistcp, -1, wx.DefaultPosition, size=wx.DefaultSize, 449 self.revlist = wx.ListCtrl(revlistcp, -1, wx.DefaultPosition, size=wx.DefaultSize,
454 style=wx.LC_REPORT|wx.SUNKEN_BORDER|wx.LC_HRULES) 450 style=wx.LC_REPORT|wx.SUNKEN_BORDER|wx.LC_HRULES)
455 self.revlist.InsertColumn(0, 'Revs', 145) 451 self.revlist.InsertColumn(0, 'Revs')
456 self.revlist.InsertColumn(1, 'Revs', 145) 452 self.revlist.InsertColumn(1, 'Changeset')
453 self.revlist.SetColumnWidth(0, -1)
454 self.revlist.SetColumnWidth(1, -1)
455 self.revlist.Refresh()
457 self.revlistcp.Add(self.revlist, (0,0), flag=wx.EXPAND) 456 self.revlistcp.Add(self.revlist, (0,0), flag=wx.EXPAND)
458 revlistcp.SetSizer(self.revlistcp) 457 revlistcp.SetSizer(self.revlistcp)
459 self.revlistcp.AddGrowableCol(0) 458 self.revlistcp.AddGrowableCol(0)
460 self.revlistcp.AddGrowableRow(0) 459 self.revlistcp.AddGrowableRow(0)
461 self.revlistcp.AddGrowableRow(1) 460 self.revlistcp.AddGrowableRow(1)
482 self.sizer.AddGrowableRow(2) 481 self.sizer.AddGrowableRow(2)
483 self.SetSizer(self.sizer) 482 self.SetSizer(self.sizer)
484 self.SetAutoLayout(True) 483 self.SetAutoLayout(True)
485 484
486 self.current = self.repo.dirstate.branch() 485 self.current = self.repo.dirstate.branch()
486
487 self.RevInfo(self.current)
488 self.revlist.Select(self.revlist.FindItem(0,
489 str(self.repo.changelog.rev(self.repo.branchtags()[self.current]))),
490 True)
491
487 self.BranchInfo(self.current) 492 self.BranchInfo(self.current)
493 self.Bind(wx.EVT_CHOICE, self.PackageSet)
494 self.Bind(wx.EVT_LIST_ITEM_SELECTED, self.PackageSet)
495
496 def PackageSet(self, event):
497
498 self.current = self.branches.GetStringSelection()
499 branches = self.repo.branchtags()
500 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()]
502
503 if self.current != type:
504 heads = dict.fromkeys(self.repo.heads(), self.repo.branchtags())
505 branches = dict.copy(self.repo.branchtags())
506 self.BranchInfo(self.current)
507 self.RevInfo(self.current)
508
509 def RevInfo(self, branch):
510 self.revlist.DeleteAllItems()
511 for heads in self.repo.changelog.reachable(self.repo.branchtags()[branch]):
512 self.revlist.InsertStringItem(0, str(self.repo.changelog.rev(heads)), 0 )
513 self.revlist.SetStringItem(0, 1, str(self.repo.changectx(heads)))
514 self.revlist.SetColumnWidth(0, -1)
515 self.revlist.SetColumnWidth(1, -1)
516 self.revlist.Refresh()
488 517
489 def BranchInfo(self, branch): 518 def BranchInfo(self, branch):
490 cs = self.repo.changectx( self.current ).changeset() 519 rev = self.revlist.GetItemText( self.revlist.GetFirstSelected() )
491 rev = self.repo.changelog.rev(self.repo.branchtags()[self.current]) #Current revision number. Use in Controls 520 rs = self.repo.changectx( rev ).changeset()
492 #print self.repo.changelog.reachable(self.repo.branchtags()[self.current])
493 #for heads in self.repo.changelog.reachable(self.repo.branchtags()[self.current]):
494 #grabs revision list depending on branch.
495 # print self.repo.changelog.rev(heads)
496 self.changelog.SetValue('') 521 self.changelog.SetValue('')
497 changelog = cs[4] 522 changelog = rs[4]
498 self.changelog.AppendText(changelog + '\n') 523 self.changelog.AppendText(changelog + '\n')
499 self.filelist.SetValue('') 524 self.filelist.SetValue('')
500 self.filelist.AppendText("Currently selected branch: " + branch + "\n\nAuthor: "+cs[1]+"\n\n") 525 self.filelist.AppendText("Currently selected branch: " + branch + "\n\nAuthor: "+rs[1]+"\n\n")
501 self.filelist.AppendText("Files Modified (in update): \n") 526 self.filelist.AppendText("Files Modified (in update): \n")
502 for f in cs[3]: self.filelist.AppendText(f+"\n") 527 for f in rs[3]: self.filelist.AppendText(f+"\n")
503 528
504 def get_packages(self, type=None): 529 def get_packages(self, type=None):
505 #Fixed and ready for Test. Can be cleaner 530 #Fixed and ready for Test. Can be cleaner
506 self.package_list = [] 531 self.package_list = []
507 b = self.repo.branchtags() 532 b = self.repo.branchtags()