def name(self):
     """
     Returns name of the node so if its path
     then only last part is returned.
     """
     org = safe_unicode(self.path.rstrip('/').split('/')[-1])
     return u'%s @ %s' % (org, self.commit.short_id)
 def tags(self):
     tags = [
         safe_unicode(name)
         for name, commit_id in self.repository.tags.iteritems()
         if commit_id == self.raw_id
     ]
     return tags
 def dir_path(self):
     """
     Returns name of the directory from full path of this vcs node. Empty
     string is returned if there's no directory in the path
     """
     _parts = self.path.rstrip('/').rsplit('/', 1)
     if len(_parts) == 2:
         return safe_unicode(_parts[0])
     return u''
    def content(self):
        """
        Returns lazily content of the `FileNode`. If possible, would try to
        decode content from UTF-8.
        """
        content = self._get_content()

        if bool(content and '\0' in content):
            return content
        return safe_unicode(content)
Exemple #5
0
    def _get_bookmarks(self):
        if self.is_empty():
            return {}

        def get_name(ctx):
            return ctx[0]

        _bookmarks = [(safe_unicode(n), hexlify(h))
                      for n, h in self._remote.bookmarks().items()]

        return OrderedDict(sorted(_bookmarks, key=get_name))
    def _get_refs_entry(self, value, reverse):
        if self.is_empty():
            return {}

        def get_name(ctx):
            return ctx[0]

        _branches = [
            (safe_unicode(x[0]), x[1][0])
            for x in self._parsed_refs.iteritems() if x[1][1] == value]
        return OrderedDict(sorted(_branches, key=get_name, reverse=reverse))
Exemple #7
0
    def _get_tags(self):
        if self.is_empty():
            return {}

        def get_name(ctx):
            return ctx[0]

        _tags = [(
            safe_unicode(n),
            hexlify(h),
        ) for n, h in self._remote.tags().items()]

        return OrderedDict(sorted(_tags, key=get_name, reverse=True))
def _get_commit_dict(filename,
                     op,
                     new_revision=None,
                     old_revision=None,
                     raw_diff=None,
                     stats=None):
    if stats is None:
        stats = {"added": None, "binary": None, "deleted": None}
    return {
        "filename": safe_unicode(filename),
        "op": op,

        # extra details
        "new_revision": new_revision,
        "old_revision": old_revision,
        "raw_diff": raw_diff,
        "stats": stats
    }
    def _set_bulk_properties(self, pre_load):
        if not pre_load:
            return
        pre_load = [
            entry for entry in pre_load if entry not in self._filter_pre_load
        ]
        if not pre_load:
            return

        result = self._remote.bulk_request(self.raw_id, pre_load)
        for attr, value in result.items():
            if attr in ["author", "message"]:
                if value:
                    value = safe_unicode(value)
            elif attr == "date":
                value = utcdate_fromtimestamp(*value)
            elif attr == "parents":
                value = self._make_commits(value)
            self.__dict__[attr] = value
Exemple #10
0
    def _get_branches(self, active=True, closed=False):
        """
        Gets branches for this repository
        Returns only not closed active branches by default

        :param active: return also active branches
        :param closed: return also closed branches

        """
        if self.is_empty():
            return {}

        def get_name(ctx):
            return ctx[0]

        _branches = [(
            safe_unicode(n),
            hexlify(h),
        ) for n, h in self._remote.branches(active, closed).items()]

        return OrderedDict(sorted(_branches, key=get_name, reverse=False))
    def _tags_or_branches(self, config_section):
        found_items = {}

        if self.is_empty():
            return {}

        for pattern in self._patterns_from_section(config_section):
            pattern = vcspath.sanitize(pattern)
            tip = self.get_commit()
            try:
                if pattern.endswith('*'):
                    basedir = tip.get_node(vcspath.dirname(pattern))
                    directories = basedir.dirs
                else:
                    directories = (tip.get_node(pattern), )
            except NodeDoesNotExistError:
                continue
            found_items.update((safe_unicode(n.path), self.commit_ids[-1])
                               for n in directories)

        def get_name(item):
            return item[0]

        return OrderedDict(sorted(found_items.items(), key=get_name))
Exemple #12
0
 def description(self):
     description = self._remote.get_config_value('web',
                                                 'description',
                                                 untrusted=True)
     return safe_unicode(description or self.DEFAULT_DESCRIPTION)
 def description(self):
     description = self._remote.get_description()
     return safe_unicode(description or self.DEFAULT_DESCRIPTION)
 def branch(self):
     for name, commit_id in self.repository.branches.iteritems():
         if commit_id == self.raw_id:
             return safe_unicode(name)
     return None
 def author(self):
     return safe_unicode(
         self._remote.commit_attribute(self.id, self._author_property))
 def committer(self):
     return safe_unicode(
         self._remote.commit_attribute(self.id, self._committer_property))
 def message(self):
     return safe_unicode(
         self._remote.commit_attribute(self.id, self._message_property))
 def message(self):
     return safe_unicode(self._properties.get('svn:log'))
Exemple #19
0
 def author(self):
     return safe_unicode(self._remote.ctx_user(self.idx))
Exemple #20
0
 def message(self):
     return safe_unicode(self._remote.ctx_description(self.idx))
 def unicode_path(self):
     return safe_unicode(self.path)
 def name(self):
     """
     Returns name of the node so if its path
     then only last part is returned.
     """
     return safe_unicode(self.path.rstrip('/').split('/')[-1])
Exemple #23
0
 def committer(self):
     return safe_unicode(self.author)
Exemple #24
0
 def contact(self):
     contact = (self._remote.get_config_value("web", "contact")
                or self._remote.get_config_value("ui", "username"))
     return safe_unicode(contact or self.DEFAULT_CONTACT)
Exemple #25
0
 def branch(self):
     return safe_unicode(self._remote.ctx_branch(self.idx))
 def author(self):
     return safe_unicode(self._properties.get('svn:author'))