예제 #1
0
 def changelist(entries, **x):
     for i in entries():
         i['date'] = getdate(i['date'])
         i['email'] = utils.filter(i['author'], 'email')
         if shortlog:
             i['desc'] = utils.filter(i['desc'], 'firstline')
             i['author'] = utils.filter(i['author'], 'person')
         yield i
예제 #2
0
파일: ext.py 프로젝트: PMR2/pmr2.mercurial
 def fulllist(**map):
     for i in dirlist():
         # remove first slash
         i['file'] = i['path'][1:]
         i['permissions'] = 'drwxr-xr-x'
         yield i
     for i in filelist():
         i['date'] = utils.filter(i['date'], datefmt)
         i['permissions'] = utils.filter(i['permissions'], 'permissions')
         yield i
예제 #3
0
 def fileinfo(self, path):
     data = self.storage.fileinfo(self.rev, path).next()
     ctx = self.storage._ctx
     fctx = ctx.filectx(data['file'])
     data['date'] = filter(data['date'], self.datefmtfilter)
     data['size'] = fctx.size()
     data['path'] = path  # we use full path here
     data['contents'] = lambda: self.file(data['file'])
     return self.format(**data)
예제 #4
0
    def log(self, rev=None, branch=None, shortlog=False, 
            datefmt=None, maxchanges=None, *a, **kw):
        """\
        This method returns the history of the repository.

        rev -
            specifies which revision to start the history from.
        branch -
            specifies which branch to check the logs on.

        This method is implemented as a wrapper around hgweb.changelog(),
        so the value return is actually an iterator, and the structure
        will likely change when this class is migrated to a common
        interface.

        This method will not cause the internal context to change.
        """

        # XXX maybe move this into the hgweb_ext
        def changelist(entries, **x):
            for i in entries():
                i['date'] = getdate(i['date'])
                i['email'] = utils.filter(i['author'], 'email')
                if shortlog:
                    i['desc'] = utils.filter(i['desc'], 'firstline')
                    i['author'] = utils.filter(i['author'], 'person')
                yield i

        hw = hgweb(self._repo)
        hw.refresh()

        if maxchanges is not None:
            hw.maxchanges = hw.maxshortchanges = maxchanges

        # This is kind of silly.
        if shortlog and datefmt is None:
            datefmt = 'age'
        elif datefmt is None:
            datefmt = 'isodate'

        getdate = lambda i: utils.filter(i, datefmt)

        # only looking, not changing.
        ctx = self._getctx(rev)
        result = ext.changelog(hw, ctx, _t, shortlog)
        for i in result:
            i['orig_entries'] = i['entries']
            i['entries'] = lambda **x: changelist(i['orig_entries'], **x)
            yield i
예제 #5
0
        def listdir():

            if not path == '':
                yield self.format(**{
                    'permissions': 'drwxr-xr-x',
                    'contenttype': None,
                    'node': self.rev,
                    'date': '',
                    'size': '',
                    'path': '%s..' % path,
                    'desc': '',
                    'contents': '',  # XXX
                    # 'emptydirs': '/'.join(emptydirs),
                })
                
            for n, v in sorted(subrepos):
                p = ''
                url, rev, repotype = v
                if v[0] is None:
                    # can't really link it anywhere...
                    p = '%s%s' % (path, n)
                else:
                    # XXX 'file' is specific to PMR2, bitbucket uses
                    # 'src' to access the human friendly view.
                    p = '%s/file/%s' % (url, rev)
                result = self.format(**{
                    'permissions': 'lrwxrwxrwx',
                    'contenttype': repotype,
                    'node': self.rev,
                    'date': '',
                    'size': '',
                    'path': p,
                    'desc': '',
                    'contents': '',  # XXX
                    # 'emptydirs': '/'.join(emptydirs),
                })
                
                # need to "fix" some values
                result['basename'] = n  # name
                result['fullpath'] = p  # full url
                yield result

            for d in sorted(dirs):
                emptydirs = []
                h = dirs[d]
                while isinstance(h, dict) and len(h) == 1:
                    k, v = h.items()[0]
                    if v:
                        emptydirs.append(k)
                    h = v

                p = '%s%s' % (path, d)
                yield self.format(**{
                    'permissions': 'drwxr-xr-x',
                    'contenttype': 'folder',
                    'node': self.rev,
                    'date': '',
                    'size': '',
                    'path': p,
                    'desc': '',
                    'contents': '',  # XXX
                    # 'emptydirs': '/'.join(emptydirs),
                })

            for f in sorted(files):
                full = files[f]
                fctx = ctx.filectx(full)
                yield self.format(**{
                    'permissions': '-rw-r--r--',
                    'contenttype': 'file',
                    'node': self.rev,
                    'date': filter(fctx.date(), self.datefmtfilter),
                    'size': str(fctx.size()),
                    'path': full,
                    'desc': fctx.description(),
                    # XXX if self.rev changes, this can result in inconsistency
                    'contents': lambda: self.file(p),
                })
예제 #6
0
 def shortrev(self):
     return filter(self.rev, 'short')