def editSelected(self, path, rev, line): """Open editor to show the specified file""" path = hglib.fromunicode(path) base = visdiff.snapshot(self.repo, [path], self.repo[rev])[0] files = [os.path.join(base, path)] pattern = hglib.fromunicode(self._lastSearch[0]) qtlib.editfiles(self.repo, files, line, pattern, self)
def _editFileAt(self, fds, ctx): repo = self._repoAgentFor(fds[0]).rawRepo() filenames = _lcanonpaths(fds) base, _ = visdiff.snapshot(repo, filenames, ctx) files = [os.path.join(base, filename) for filename in filenames] qtlib.editfiles(repo, files, parent=self.parent())
def _openineditor(repo, path, rev, line=None, pattern=None, parent=None): """Open editor to show the specified file [unicode]""" path = hglib.fromunicode(path) pattern = hglib.fromunicode(pattern) base = visdiff.snapshot(repo, [path], repo[rev])[0] files = [os.path.join(base, path)] qtlib.editfiles(repo, files, line, pattern, parent=self)
def preparefiles(): files = [self.filePath(i) for i in indexes if i.isValid()] if self._rev is not None: base, _fns = visdiff.snapshot(self._repo, files, self._repo[self._rev]) else: # working copy base = self._repo.root return iter(os.path.join(base, e) for e in files)
def editfile(self): if self.path is None: return if self.rev is None: qtlib.editfiles(self._repo, [hglib.fromunicode(self.path)], parent=self) else: base, _ = visdiff.snapshot(self._repo, [hglib.fromunicode(self.path)], self._repo[self.rev]) files = [os.path.join(base, hglib.fromunicode(self.path))] qtlib.editfiles(self._repo, files, parent=self)
def editfile(self): repo, filenames, rev = self._findsub(self._selectedfiles) if not filenames: return if rev is None: qtlib.editfiles(repo, filenames, parent=self.parent()) else: base, _ = visdiff.snapshot(repo, filenames, repo[rev]) files = [os.path.join(base, filename) for filename in filenames] qtlib.editfiles(repo, files, parent=self.parent())
def onViewFileAtRevision(self): rev = self.selection[0] filenames = [self.filerevmodel.graph.filename(rev)] if not filenames: return if rev is None: qtlib.editfiles(self.repo, filenames, parent=self) else: base, _ = visdiff.snapshot(self.repo, filenames, self.repo[rev]) files = [os.path.join(base, filename) for filename in filenames] qtlib.editfiles(self.repo, files, parent=self)
def editfile(self): filenames = self.filelist.getSelectedFiles() if not filenames: return rev = self.ctx.rev() if rev is None: qtlib.editfiles(self.repo, filenames, parent=self) else: base, _ = visdiff.snapshot(self.repo, filenames, self.ctx) files = [os.path.join(base, filename) for filename in filenames] qtlib.editfiles(self.repo, files, parent=self)
def mimeData(self, indexes): files = [self.filePath(i) for i in indexes if i.isValid()] ctx = self._rootentry.ctx if ctx.rev() is not None: repo = self._repoagent.rawRepo() lfiles = map(hglib.fromunicode, files) lbase, _fns = visdiff.snapshot(repo, lfiles, ctx) base = hglib.tounicode(lbase) else: # working copy base = self._repoagent.rootPath() m = QMimeData() m.setUrls([QUrl.fromLocalFile(os.path.join(base, e)) for e in files]) return m
def dragObject(self): if type(self.ctx.rev()) == str: return paths = [] for index in self.selectedRows(): paths.append(self.model().fileFromIndex(index)) if not paths: return if self.ctx.rev() is None: base = self.repo.root else: base, _ = visdiff.snapshot(self.repo, paths, self.ctx) urls = [] for path in paths: urls.append(QUrl.fromLocalFile(os.path.join(base, path))) if urls: d = QDrag(self) m = QMimeData() m.setUrls(urls) d.setMimeData(m) d.start(Qt.CopyAction)
def viewmissing(parent, ui, repo, files): base, _ = visdiff.snapshot(repo, files, repo['.']) edit(parent, ui, repo, [os.path.join(base, f) for f in files])
def viewother(parent, ui, repo, files): wctx = repo[None] assert bool(wctx.p2()) base, _ = visdiff.snapshot(repo, files, wctx.p2()) edit(parent, ui, repo, [os.path.join(base, f) for f in files])