Exemple #1
0
        def onHGrevertall(self, evt):
            dlg = wx.MessageDialog(
                None, 'Do you discard all changes since the last commit?',
                'Revert', wx.OK | wx.CANCEL)
            ret = dlg.ShowModal()
            dlg.Destroy()
            if ret != wx.ID_OK:
                return

            d = self.owndir()
            fpath = os.path.join(d, ".hg_data_hg")
            if not os.path.exists(os.path.join(d, ".hg")):
                return  # not a repo

            ichild = self.get_ichild()

            owndir = self.owndir()
            name = self._name
            parent = self.get_parent()
            repo = hgapi.Repo(owndir)
            # repo.hg_revert(True)
            repo.hg_revert(all)
            self.hg_set_projtreeviewer_status(repo=repo)
            # puting the tree back
            vars = self.getvar().copy()
            self.destroy(clean_owndir=False)
            if not os.path.exists(fpath):
                #
                #  In this case, it makes a containing folder
                #  and gather *.py to make PyScript
                #  I should be handling other files here too?
                #
                print(vars)
                td = handle_pure_file_repo(parent, name, owndir)
                td.setvar(vars)
                load_fpath = False
            else:
                load_fpath = True
            if load_fpath:
                fid = open(fpath, 'rb')
                td, olist, nlist = TreeDict().load(fid, keep_zorder=True)
                fid.close()
                parent.add_child(td._name, td, keep_zorder=True)
            parent.move_child(td.get_ichild(), ichild)
            if load_fpath:
                for obj in td.walk_tree():
                    obj.init_after_load(olist, nlist)

            for item in repo.hg_status()['?']:
                os.remove(os.path.join(d, item))
            ifigure.events.SendFileSystemChangedEvent(parent, reload=True)
            evt.Skip()
Exemple #2
0
       def onHGrevertall(self, evt):
           dlg=wx.MessageDialog(None, 
                                'Do you discard all changes since the last commit?',
                                'Revert',
                                wx.OK|wx.CANCEL)
           ret=dlg.ShowModal()
           dlg.Destroy()
           if ret  != wx.ID_OK: return

           d = self.owndir()
           fpath=os.path.join(d, ".hg_data_hg")
           if not os.path.exists(os.path.join(d, ".hg")): return ## not a repo

           ichild = self.get_ichild()

           owndir = self.owndir()
           name = self._name
           parent = self.get_parent()
           repo = hgapi.Repo(owndir)
           #repo.hg_revert(True)
           repo.hg_revert(all)
           self.hg_set_projtreeviewer_status(repo=repo)
           ## puting the tree back
           vars = self.getvar().copy()
           self.destroy(clean_owndir=False)
           if not os.path.exists(fpath): 
               #
               #  In this case, it makes a containing folder
               #  and gather *.py to make PyScript
               #  I should be handling other files here too?  
               #
               print vars
               td = handle_pure_file_repo(parent, name, owndir)
               td.setvar(vars)
               load_fpath = False
           else:
               load_fpath = True
           if load_fpath:
               fid= open(fpath, 'rb')
               td, olist, nlist = TreeDict().load(fid, keep_zorder=True)
               fid.close()
               parent.add_child(td._name, td, keep_zorder = True)
           parent.move_child(td.get_ichild(), ichild)
           if load_fpath:
               for obj in td.walk_tree():
                   obj.init_after_load(olist, nlist)

           for item in repo.hg_status()['?']:
               os.remove(os.path.join(d, item))
           ifigure.events.SendFileSystemChangedEvent(parent, reload = True)
           evt.Skip()
Exemple #3
0
   def load_repo_treedata(obj):
       parent = obj.get_parent()
       name =  obj._name
       owndir = obj.owndir()
       ichild = obj.get_ichild()
       fpath=os.path.join(owndir, ".tree_data_hg")
       if not os.path.exists(fpath): 
           fpath=os.path.join(owndir, ".tree_data")
#           return False
       else:
           obj.destroy(clean_owndir=False)
           fid= open(fpath, 'rb')
           fid= open(fpath, 'rb')
           td, olist, nlist = TreeDict().load(fid, keep_zorder=True)
           fid.close()
           parent.add_child(name, td, keep_zorder = True)
           parent.move_child(td.get_ichild(), ichild)
#           for obj in td.walk_tree():
#               obj.init_after_load(olist, nlist)

           for name, child in obj.get_children():
               for obj2 in child.walk_tree():
                   if has_repo(obj2):
                       load_repo_treedata(obj2)
Exemple #4
0
    def load_repo_treedata(obj):
        parent = obj.get_parent()
        name = obj._name
        owndir = obj.owndir()
        ichild = obj.get_ichild()
        fpath = os.path.join(owndir, ".tree_data_hg")
        if not os.path.exists(fpath):
            fpath = os.path.join(owndir, ".tree_data")
#           return False
        else:
            obj.destroy(clean_owndir=False)
            fid = open(fpath, 'rb')
            fid = open(fpath, 'rb')
            td, olist, nlist = TreeDict().load(fid, keep_zorder=True)
            fid.close()
            parent.add_child(name, td, keep_zorder=True)
            parent.move_child(td.get_ichild(), ichild)
            #           for obj in td.walk_tree():
            #               obj.init_after_load(olist, nlist)

            for name, child in obj.get_children():
                for obj2 in child.walk_tree():
                    if has_repo(obj2):
                        load_repo_treedata(obj2)
Exemple #5
0
       def onHGupdate(self, evt=None, m=None):
           repo = hgapi.Repo(self.owndir())
           app0 = wx.GetApp().TopWindow
           if m is None:
              latest = repo.revisions(slice(-1,-1))[0].rev
              ret, m = dialog.textentry(app0,
                    "Enter revision #", "Mercurial Update", str(latest))
              if not ret: return None
           status = repo.hg_status()
           for key in status:
               if key == '?': continue
               if len(status[key]) != 0:
                    print(status)
                    ret, m = dialog.message(app0,
                                "Local repo status is not clean. \n(" + 
                                 self.get_full_path()+')', 
                                "Mercurial Update Error")
                    self.hg_set_projtreeviewer_status(repo)
#                    self._status = '!'
                    return None

           repo.hg_update(long(m))

           parent = self.get_parent()
           owndir = self.owndir()
           name = self._name
           ichild = self.get_ichild()
           url, root, path = self.get_mercurial_url()
           
           self.destroy(clean_owndir=False)

           del_old_treedata = False
           load_fpath = True
           
           fpath=os.path.join(owndir, ".tree_data_hg")
           if not os.path.exists(fpath): 
               fpath=os.path.join(owndir, ".tree_data")
               if not os.path.exists(fpath): 
                  print((url, root, path))
                  td = handle_pure_file_repo(parent, name, owndir)
                  load_fpath = False
               else:
                  dlg=wx.MessageDialog(None, 
                                    'HG update succeeded but .tree_data_hg is not found.',
                       'Old style for HG repo',
                                     wx.OK)
                  ret=dlg.ShowModal()
                  dlg.Destroy()
                  fpath=os.path.join(owndir, ".tree_data")
                  del_old_treedata = True
           if load_fpath:
               fid= open(fpath, 'rb')
               td, olist, nlist = TreeDict().load(fid, keep_zorder=True)
               fid.close()
               parent.add_child(name, td, keep_zorder = True)
           parent.move_child(td.get_ichild(), ichild)
           if load_fpath:
               for obj in td.walk_tree():
                   obj.init_after_load(olist, nlist)
           if del_old_treedata:
               os.remove(fpath)

           if url is not None:
               td.set_mercurial_url(root, path)
           if evt is not None:
#               evt.GetEventObject().update_widget_request2()
               ifigure.events.SendFileSystemChangedEvent(parent, reload = True)
               evt.Skip()
           return td
Exemple #6
0
        def onHGupdate(self, evt=None, m=None):
            repo = hgapi.Repo(self.owndir())
            app0 = wx.GetApp().TopWindow
            if m is None:
                latest = repo.revisions(slice(-1, -1))[0].rev
                ret, m = dialog.textentry(app0, "Enter revision #",
                                          "Mercurial Update", str(latest))
                if not ret: return None
            status = repo.hg_status()
            for key in status:
                if key == '?': continue
                if len(status[key]) != 0:
                    print(status)
                    ret, m = dialog.message(
                        app0, "Local repo status is not clean. \n(" +
                        self.get_full_path() + ')', "Mercurial Update Error")
                    self.hg_set_projtreeviewer_status(repo)
                    #                    self._status = '!'
                    return None

            repo.hg_update(long(m))

            parent = self.get_parent()
            owndir = self.owndir()
            name = self._name
            ichild = self.get_ichild()
            url, root, path = self.get_mercurial_url()

            self.destroy(clean_owndir=False)

            del_old_treedata = False
            load_fpath = True

            fpath = os.path.join(owndir, ".tree_data_hg")
            if not os.path.exists(fpath):
                fpath = os.path.join(owndir, ".tree_data")
                if not os.path.exists(fpath):
                    print((url, root, path))
                    td = handle_pure_file_repo(parent, name, owndir)
                    load_fpath = False
                else:
                    dlg = wx.MessageDialog(
                        None,
                        'HG update succeeded but .tree_data_hg is not found.',
                        'Old style for HG repo', wx.OK)
                    ret = dlg.ShowModal()
                    dlg.Destroy()
                    fpath = os.path.join(owndir, ".tree_data")
                    del_old_treedata = True
            if load_fpath:
                fid = open(fpath, 'rb')
                td, olist, nlist = TreeDict().load(fid, keep_zorder=True)
                fid.close()
                parent.add_child(name, td, keep_zorder=True)
            parent.move_child(td.get_ichild(), ichild)
            if load_fpath:
                for obj in td.walk_tree():
                    obj.init_after_load(olist, nlist)
            if del_old_treedata:
                os.remove(fpath)

            if url is not None:
                td.set_mercurial_url(root, path)
            if evt is not None:
                #               evt.GetEventObject().update_widget_request2()
                ifigure.events.SendFileSystemChangedEvent(parent, reload=True)
                evt.Skip()
            return td