def export(self, callback=None): self._begin() dirwin = self.dirwin url = self.path path = get_path(dirwin.pref.version_control_export_path) self.pref.version_control_export_path = path self.pref.save() if not path: return export_path = os.path.join(path, os.path.basename(url)) if os.path.exists(export_path): dlg = wx.MessageDialog( dirwin, tr("The directory [%s] is existed, \ndo you want to overwrite it?" ) % export_path, tr("Export"), wx.YES_NO | wx.ICON_QUESTION) answer = dlg.ShowModal() dlg.Destroy() if answer != wx.ID_YES: return force = True else: force = False def callback(): common.showmessage(tr('Export completed!')) def f(): client = self.get_client([]) client.export(url, export_path, force) wrap_run(f, callback)
def checkout(self, callback=None): self._begin() dlg = CheckoutDialog() value = None if dlg.ShowModal() == wx.ID_OK: value = dlg.GetValue() dlg.Destroy() if not value: return if value["revision"]: r = value["revision"] else: r = self.svn.Revision(self.svn.opt_revision_kind.head) self.result = ResultDialog(self) self.result.Show() def f(): client = self.get_client() client.checkout(value["url"], value["dir"], revision=r) if self.result: self.result.finish() wrap_run(f, callback, result=self.result)
def export(self, callback=None): self._begin() dirwin = self.dirwin url = self.path path = get_path(dirwin.pref.version_control_export_path) self.pref.version_control_export_path = path self.pref.save() if not path: return export_path = os.path.join(path, os.path.basename(url)) if os.path.exists(export_path): dlg = wx.MessageDialog( dirwin, tr("The directory [%s] is existed, \ndo you want to overwrite it?") % export_path, tr("Export"), wx.YES_NO | wx.ICON_QUESTION, ) answer = dlg.ShowModal() dlg.Destroy() if answer != wx.ID_YES: return force = True else: force = False def callback(): common.showmessage(tr("Export completed!")) def f(): client = self.get_client([]) client.export(url, export_path, force) wrap_run(f, callback)
def init(self): def f(): from SvnSettings import get_global_ignore ignore = [x[1:] for x in get_global_ignore().split()] import pysvn client = pysvn.Client() r = client.status(self.path) files = {} for node in r: files[node['path']] = node['is_versioned'] if os.path.isfile(self.path) and not files.get(self.path, False): wx.CallAfter(self.list.addline, [os.path.basename(self.path)], flag=True) self.path = os.path.dirname(self.path) else: if not files.get(self.path, False): wx.CallAfter(self.list.addline, ['.'], flag=True) _len = len(self.path) for curpath, dirs, fs in os.walk(self.path): if '.svn' in curpath: continue for fname in fs: ext = os.path.splitext(fname)[1] if ext in ignore: continue filename = os.path.join(curpath, fname) if not files.get(filename, False): wx.CallAfter(self.list.addline, [filename[_len+1:]], flag=True) wrap_run(f)
def diff(self, callback): self._begin() def f(): client = self.get_client([]) r = client.diff(wx.StandardPaths.Get().GetTempDir(), self.path) wx.CallAfter(show_in_message_win, r) wrap_run(f, callback)
def init(self): self.filelist = [] def f(): import pysvn client = pysvn.Client() r = client.status(self.path, ignore=True) if os.path.isfile(self.path): self.path = os.path.dirname(self.path) _len = len(self.path) for node in r: status = str(node['text_status']) fname = node['path'][_len+1:] if not fname: fname = '.' if status != 'normal': self.filelist.append((node['is_versioned'], fname, node['path'], status)) if not self.filelist: wx.CallAfter(common.showmessage, tr("No files need to process.")) return self.load_data(self.chkShowUnVersion.GetValue()) wrap_run(f)
def delete(self, callback): self._begin() def f(): client = self.get_client([]) client.remove(self.path) wrap_run(f, callback)
def status(self, callback=None): self._begin() def f(): client = self.get_client() r = client.status(self.path, ignore=True) s = [] fmt = "%(path)-60s %(text_status)-20s" s.append(fmt % {'path':'Filename', 'text_status':'Status'}) for node in r: t = fmt % node s.append(t) wx.CallAfter(show_in_message_win, '\n'.join(s)) wrap_run(f, callback)
def update(self, callback): self._begin() self.result = ResultDialog(self) self.result.Show() def f(): client = self.get_client() client.update(self.path) if self.result: self.result.finish() wrap_run(f, callback, result=self.result)
def list(self, callback=None): self._begin() def f(): client = self.get_client() r = client.list(self.path) s = [] fmt = "%(path)-60s %(last_author)-20s %(size)-10s" s.append(fmt % {'path':'Filename', 'last_author':'Last Author', 'size':'Size'}) for node, flag in r: t = fmt % node s.append(t) wx.CallAfter(show_in_message_win, '\n'.join(s)) wrap_run(f, callback)
def rename(self, callback): self._begin() dir = os.path.dirname(self.path) dlg = wx.TextEntryDialog(Globals.mainframe, tr('New name'), tr('Rename'), os.path.basename(self.path)) newname = '' if dlg.ShowModal() == wx.ID_OK: newname = os.path.join(dir, dlg.GetValue()) dlg.Destroy() if newname: def f(): client = self.get_client([]) client.move(self.path, os.path.join(dir, newname)) wrap_run(f, callback)
def status(self, callback=None): self._begin() def f(): client = self.get_client() r = client.status(self.path, ignore=True) s = [] fmt = "%(path)-60s %(text_status)-20s" s.append(fmt % {'path': 'Filename', 'text_status': 'Status'}) for node in r: t = fmt % node s.append(t) wx.CallAfter(show_in_message_win, '\n'.join(s)) wrap_run(f, callback)
def list(self, callback=None): self._begin() def f(): client = self.get_client() r = client.list(self.path) s = [] fmt = "%(path)-60s %(last_author)-20s %(size)-10s" s.append(fmt % {"path": "Filename", "last_author": "Last Author", "size": "Size"}) for node, flag in r: t = fmt % node s.append(t) wx.CallAfter(show_in_message_win, "\n".join(s)) wrap_run(f, callback)
def init(self): def f(): import pysvn client = pysvn.Client() r = client.status(self.path) if os.path.isfile(self.path): self.path = os.path.dirname(self.path) _len = len(self.path) for node in r: status = str(node['text_status']) if status in ('modified', 'added', 'deleted'): fname = node['path'][_len+1:] if not fname: fname = '.' wx.CallAfter(self.list.addline, [fname, status], flag=True) wrap_run(f)
def add(self, callback): self._begin() dlg = AddDialog(Globals.mainframe, tr('Add'), self.path) values = [] if dlg.ShowModal() == wx.ID_OK: values = dlg.GetValue() dlg.Destroy() if values: self.result = ResultDialog(self) self.result.Show() def f(): client = self.get_client() client.add(values, False) if self.result: self.result.finish() wrap_run(f, callback, result=self.result)
def revert(self, callback): self._begin() dlg = RevertDialog(tr('Revert'), self.path) values = [] if dlg.ShowModal() == wx.ID_OK: values = dlg.GetValue() dlg.Destroy() if values: self.result = ResultDialog(self) self.result.Show() def f(): client = self.get_client() client.revert(values, False) if self.result: self.result.finish() wrap_run(f, callback, result=self.result)
def list(self, callback=None): self._begin() def f(): client = self.get_client() r = client.list(self.path) s = [] fmt = "%(path)-60s %(last_author)-20s %(size)-10s" s.append(fmt % { 'path': 'Filename', 'last_author': 'Last Author', 'size': 'Size' }) for node, flag in r: t = fmt % node s.append(t) wx.CallAfter(show_in_message_win, '\n'.join(s)) wrap_run(f, callback)
def log(self, callback): self._begin() def f(): import time client = self.get_client() r = client.log(self.path) s = [] fmt = ("%(message)s\n" + '-'*70 + "\nr%(revision)d | %(author)s | %(date)s\n") for node in r: node['revision'] = node['revision'].number node['date'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(node['date'])) if not node['author']: node['author'] = tr('<No Author>') t = fmt % node s.append(t) wx.CallAfter(show_in_message_win, '\n'.join(s)) wrap_run(f, callback)
def log(self, callback): self._begin() def f(): import time client = self.get_client() r = client.log(self.path) s = [] fmt = "%(message)s\n" + "-" * 70 + "\nr%(revision)d | %(author)s | %(date)s\n" for node in r: node["revision"] = node["revision"].number node["date"] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(node["date"])) if not node["author"]: node["author"] = tr("<No Author>") t = fmt % node s.append(t) wx.CallAfter(show_in_message_win, "\n".join(s)) wrap_run(f, callback)
def init(self): def f(): from SvnSettings import get_global_ignore ignore = [x[1:] for x in get_global_ignore().split()] import pysvn client = pysvn.Client() r = client.status(self.path) files = {} for node in r: files[node['path']] = node['is_versioned'] if os.path.isfile(self.path) and not files.get(self.path, False): wx.CallAfter(self.list.addline, [os.path.basename(self.path)], flag=True) self.path = os.path.dirname(self.path) else: if not files.get(self.path, False): wx.CallAfter(self.list.addline, ['.'], flag=True) _len = len(self.path) def get_path(base, path): p = os.path.join(base, path) for f in os.listdir(p): if '.svn' == f: continue filename = os.path.join(p, f) if os.path.isdir(filename): yield filename+'/' for x in get_path(base, os.path.join(path, f)): yield x else: ext = os.path.splitext(filename)[1] if ext in ignore: continue yield os.path.join(path, f).replace('\\', '/') for f in get_path(self.path, ''): filename = os.path.join(self.path, f) if not files.get(filename, False): wx.CallAfter(self.list.addline, [filename[_len+1:]], flag=True) wrap_run(f)
def commit(self, callback): self._begin() dlg = CommitDialog(tr('Commit'), self.path) values = None if dlg.ShowModal() == wx.ID_OK: values = dlg.GetValue() dlg.Destroy() if values and values['add_files'] + values['files']: self.result = ResultDialog(self) self.result.Show() def f(): client = self.get_client() if values['add_files']: client.add(values['add_files'], False) client.checkin(values['add_files'] + values['files'], values['message']) client.update('.', False) if self.result: self.result.finish() wrap_run(f, callback, result=self.result)
def log(self, callback): self._begin() def f(): import time client = self.get_client() r = client.log(self.path) s = [] fmt = ("%(message)s\n" + '-' * 70 + "\nr%(revision)d | %(author)s | %(date)s\n") for node in r: node['revision'] = node['revision'].number node['date'] = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime(node['date'])) if not node['author']: node['author'] = tr('<No Author>') t = fmt % node s.append(t) wx.CallAfter(show_in_message_win, '\n'.join(s)) wrap_run(f, callback)
def checkout(self, callback=None): self._begin() dlg = CheckoutDialog() value = None if dlg.ShowModal() == wx.ID_OK: value = dlg.GetValue() dlg.Destroy() if not value: return if value['revision']: r = value['revision'] else: r = self.svn.Revision(self.svn.opt_revision_kind.head) self.result = ResultDialog(self) self.result.Show() def f(): client = self.get_client() client.checkout(value['url'], value['dir'], revision=r) if self.result: self.result.finish() wrap_run(f, callback, result=self.result)