'''Create development branch environment''' # Copyright (c) 2006 Qualcomm # Miki Tebeka <mtebeka@qualcomm.com> # Will create (assuming integration branch is //depot/mary/main): # * Developmet branch //depot/mary/users/miki/foo from //depot/mary/main # * Development workspace //depot/mary/users/miki/foo/... //client-name/... # * Integration branch //depot/mary/main/... //depot/mary/users/miki/foo/... import wx from wx.lib.filebrowsebutton import DirBrowseButton from wx.lib.dialogs import ScrolledMessageDialog from p4v_common import P4VAddin, P4, make_error, optparser, gen_p4, \ fix_path, new_client, client_exists, branch_exists, new_branch, \ new_change, P4Error # Integration branch: _____________ # Development branch: _____________ # Branch Name: ____________________ # Development Workspace: __________ # Development Workspace Root: _____ [...] # [Create] [Quit] error = make_error("Create Development Branch") class MakeDev(P4VAddin): def __init__(self, p4, integ): P4VAddin.__init__(self, "Create Development Branch") self.p4 = p4 sizer = wx.BoxSizer(wx.VERTICAL) fsizer = wx.FlexGridSizer(4, 2) # Rows, cols def add(name): fsizer.Add(wx.StaticText(self, -1, "%s:" % name), 0, wx.WEST|wx.ALIGN_CENTER_VERTICAL, 5) t = wx.TextCtrl(self, -1, size=(500, -1)) fsizer.Add(t, 0, wx.EXPAND) return t # Integration branch: _______ self._integration = add("Integration Branch") self._integration.SetValue(integ) # Development branch: _______ self._development = add("Development Branch") # Guess name of development branch devpath = integ[:integ.rfind("/")] devpath += "/users/%s/" % p4.user self._development.SetValue(devpath) # Branch Spec: ___________ self._branch = add("Branch Name") self._branch.SetValue("%s-XXX-integ" % p4.user) # Development Workspace: __________ self._dev_workspace = add("Development Workspace") self._dev_workspace.SetValue("%s-XXX" % p4.user) sizer.Add(fsizer, 1, wx.EXPAND) # Development Workspace Root: ___________ self._dev_workspace_root = \ DirBrowseButton(self, -1, newDirectory=1, labelText="Development Workspace Root Directory:", dialogTitle="Select root directory") sizer.Add(self._dev_workspace_root, 0, wx.EXPAND) # [Create] [Quit] hsizer = wx.BoxSizer(wx.HORIZONTAL) b = wx.Button(self, -1, "Create") self.Bind(wx.EVT_BUTTON, self.OnCreate, b) hsizer.Add(b) hsizer.Add(wx.Button(self, wx.ID_CANCEL, "Quit")) sizer.Add(hsizer, 0, wx.EXPAND) self.SetSizer(sizer) sizer.Fit(self) self.CenterOnScreen() def OnCreate(self, evt): try: integration = self.getval(self._integration, "Integration") development = self.getval(self._development, "Development") branch = self.getval(self._branch, "Branch") workspace = self.getval(self._dev_workspace, "Workspace") workspace_root = self.getval(self._dev_workspace_root, "Workspace root") except ValueError, e: error("%s can't be empty" % e) return integration = fix_path(integration) development = fix_path(development) if integration.lower() == development.lower(): error("Integration and development branches are the same") return try: self.create(integration, development, branch, workspace, workspace_root) except P4Error, e: error("Error creating development branch\n%s" % e) return def create(self, integration, development, branch, workspace, workspace_root): p4 = self.p4 # Create development client if not client_exists(p4, workspace): new_client(p4, workspace, workspace_root, ["%s //%s/..." % (development, workspace)], "%s development client" % p4.user) p4.client = workspace # Integrete files to development branch change = new_change(p4, "Create development branch") p4.run_integrate("-v", "-c", change, integration, development) p4.run_submit("-c", change) # Create integration branch if not branch_exists(p4, branch): new_branch(p4, branch, integration, development, "integration branch for %s" % p4.user) # Show what's been done msg = '''Development branch created Branch Location: %(development)s Client name: %(workspace)s Branch name: %(branch)s Use "integrate using branch spec (%(branch)s)" to update Use "integrate using branch spec (%(branch)s - reverse)" to publish ''' % locals() dlg = ScrolledMessageDialog(self, msg, "Development Branch Created") dlg.ShowModal() dlg.Destroy() def main(argv = None): if argv is None: import sys argv = sys.argv app = wx.PySimpleApp() parser = optparser("usage: %prog [options] INTEGRATION_BRANCH") opts, args = parser.parse_args(argv[1:]) if len(args) != 1: err_msg = "Wrong number of arguments" error(err_msg) raise SystemExit(err_msg) p4 = gen_p4(opts) dlg = MakeDev(p4, args[0]) try: try: dlg.ShowModal() except Exception, e: error(e) finally: dlg.Destroy() if __name__ == "__main__": main()
# | Change | User | Description | Committed | |
---|---|---|---|---|---|
#1 | 5665 | Robert Cowham | Initial branch | ||
//guest/miki_tebeka/p4vaddins/main/make-dev-branch.py | |||||
#3 | 5486 | Miki Tebeka |
* Release 0.8.0 * Fixed bug in "Create Development Branch" * Unix support |
||
#2 | 5382 | Miki Tebeka |
* Start of UNIX - File format and #! * getvalue returns string (not unicode in some cases) |
||
#1 | 5280 | Miki Tebeka | Initial checkin of project |