Example #1
0
    def savefile(self):
        filenames = self.filelist.getSelectedFiles()
        if not filenames:
            return
        rev = self.ctx.rev()
        for curfile in filenames:
            wfile = util.localpath(curfile)
            wfile, ext = os.path.splitext(os.path.basename(wfile))
            if wfile:
                filename = "%s@%d%s" % (wfile, rev, ext)
            else:
                filename = "%s@%d" % (ext, rev)

            result = QFileDialog.getSaveFileName(parent=self, caption=_("Save file to"),
                                                 directory=filename) 
            if not result:
                continue
            cwd = os.getcwd()
            try:
                os.chdir(self.repo.root)
                try:
                    commands.cat(self.repo.ui, self.repo,
                        curfile,
                        rev = rev,
                        output = hglib.fromunicode(result))
                except (util.Abort, IOError), e:
                    QMessageBox.critical(self, _('Unable to save file'), hglib.tounicode(str(e)))
            finally:
                os.chdir(cwd)
Example #2
0
def savefiles(repo, files, rev, parent=None):
    for curfile in files:
        wfile = util.localpath(curfile)
        wfile, ext = os.path.splitext(os.path.basename(wfile))
        if wfile:
            filename = "%s@%d%s" % (wfile, rev, ext)
        else:
            filename = "%s@%d" % (ext, rev)
        result = QFileDialog.getSaveFileName(
            parent=parent,
            caption=_("Save file to"),
            directory=hglib.tounicode(filename))
        if not result:
            continue
        cwd = os.getcwd()
        try:
            os.chdir(repo.root)
            try:
                commands.cat(repo.ui,
                             repo,
                             curfile,
                             rev=rev,
                             output=hglib.fromunicode(result))
            except (util.Abort, IOError), e:
                QMessageBox.critical(self, _('Unable to save file'),
                                     hglib.tounicode(str(e)))
        finally:
            os.chdir(cwd)
Example #3
0
File: repo.py Project: MrPetru/spam
def cat_multi(proj, assetver):
    """Return the files corresponding to the given asset version in a zip
    archive (ready for http download), retriving them from the mercurial
    repository."""
    if not assetver.asset.is_sequence:
        raise SPAMRepoError('asset %s is not a sequence of files' %
                                                            assetver.asset.id)
    
    repo_path = os.path.join(G.REPOSITORY, proj)
    repo = repo_get(proj)
    
    target_path = assetver.asset.path.replace('#', '*').encode()
    target_filename = os.path.join(repo_path, target_path).encode()
    targets = glob.glob(target_filename)

    ztemp = tempfile.NamedTemporaryFile()
    zfile = zipfile.ZipFile(ztemp.name, 'w')
    for target in targets:
        temp = tempfile.NamedTemporaryFile()
        commands.cat(repo_ui, repo, target, output=temp.name,
                                                            rev=assetver.repoid)
        name = os.path.basename(target)
        name, ext = os.path.splitext(name)
        name, frame = os.path.splitext(name)
        name = name.rstrip('.#')
        verdir = '%s_v%03d' % (name, assetver.ver)
        vername = '%s_v%03d%s%s' % (name, assetver.ver, frame, ext)
        zfile.write(temp.name, os.path.join(verdir, vername))
        temp.close()
    zfile.close()
    return ztemp
Example #4
0
File: repo.py Project: MrPetru/spam
def cat_single(proj, assetver):
    """Return the file corresponding to the given asset version, retriving it
    from the mercurial repository."""
    repo_path = os.path.join(G.REPOSITORY, proj)
    repo = repo_get(proj)
    
    target_file_name = os.path.join(repo_path, assetver.asset.path)
    temp = tempfile.NamedTemporaryFile()
    commands.cat(repo_ui, repo, target_file_name, output=temp.name,
                                                            rev=assetver.repoid)
    return temp
Example #5
0
File: b.py Project: dimo414/b
def _cat(ui, repo, path, todir, rev=None):
    ui.pushbuffer(error=True)
    success = commands.cat(ui, repo, path, rev=rev,
                           output=os.path.join(todir, path))
    msg = ui.popbuffer()
    if success != 0:
        raise IOError(errno.ENOENT,
                      _("Failed to access %s at rev %s\nDetails: %s") % (
                          path, rev, msg))
Example #6
0
def rhcat(ui, repo, file1, *pats, **opts):
    rev = urllib.unquote_plus(opts.pop('rev', None))
    opts['rev'] = rev
    return commands.cat(ui, repo, urllib.unquote_plus(file1), *map(urllib.unquote_plus, pats), **opts)
Example #7
0
def rhcat(ui, repo, file1, *pats, **opts):
    rev = urllib.unquote_plus(opts.pop('rev', None))
    opts['rev'] = rev
    return commands.cat(ui, repo, urllib.unquote_plus(file1),
                        *map(urllib.unquote_plus, pats), **opts)
Example #8
0
def rhcat(ui, repo, file1, *pats, **opts):
    return commands.cat(ui, repo, urllib.unquote_plus(file1), *map(urllib.unquote_plus, pats), **opts)
def rhcat(ui, repo, file1, *pats, **opts):
    return commands.cat(ui, repo, urllib.unquote_plus(file1), *map(urllib.unquote_plus, pats), **opts)
Example #10
0
def _cat(ui, repo, file, todir, rev=None):
    ui.pushbuffer()
    commands.cat(ui, repo, file, rev=rev, output=os.path.join(todir, file))
    ui.popbuffer()
Example #11
0
 def _read_without_encoding(cls, path):
     repo = hg.repository(ui.ui(), 'http://hg.mozilla.org/webtools/mcs/')
     print repo
     text = commands.cat(ui, repo, 'theme/html/index.html')
     #text = client.cat(path, revision=pysvn.Revision( pysvn.opt_revision_kind.head ))
     return text
Example #12
0
def _cat(ui,repo,file,todir,rev=None):
    ui.pushbuffer()
    commands.cat(ui,repo,file,rev=rev,output=os.path.join(todir,file))
    ui.popbuffer()