예제 #1
0
    def test_change_non_ascii(self):
        to_add = [
            FileNode('żółwik/zwierzątko', content='ćććć'),
            FileNode(u'żółwik/zwierzątko_uni', content=u'ćććć'),
        ]
        for node in to_add:
            self.imc.add(node)

        tip = self.imc.commit(u'Initial', u'*****@*****.**')

        # Change node's content
        node = FileNode('żółwik/zwierzątko', content='My **changed** content')
        self.imc.change(node)
        self.imc.commit(u'Changed %s' % safe_unicode(node.path),
                        u'*****@*****.**')

        node = FileNode(u'żółwik/zwierzątko_uni',
                        content=u'My **changed** content')
        self.imc.change(node)
        self.imc.commit(u'Changed %s' % safe_unicode(node.path),
                        u'*****@*****.**')

        newtip = self.repo.get_changeset()
        self.assertNotEqual(tip, newtip)
        self.assertNotEqual(tip.id, newtip.id)

        self.assertEqual(
            newtip.get_node('żółwik/zwierzątko').content,
            'My **changed** content')
        self.assertEqual(
            newtip.get_node('żółwik/zwierzątko_uni').content,
            'My **changed** content')
예제 #2
0
    def test_change_non_ascii(self):
        to_add = [
            FileNode('żółwik/zwierzątko', content='ćććć'),
            FileNode(u'żółwik/zwierzątko_uni', content=u'ćććć'),
        ]
        for node in to_add:
            self.imc.add(node)

        tip = self.imc.commit(u'Initial', u'*****@*****.**')

        # Change node's content
        node = FileNode('żółwik/zwierzątko', content='My **changed** content')
        self.imc.change(node)
        self.imc.commit(u'Changed %s' % safe_unicode(node.path),
                        u'*****@*****.**')

        node = FileNode(u'żółwik/zwierzątko_uni', content=u'My **changed** content')
        self.imc.change(node)
        self.imc.commit(u'Changed %s' % safe_unicode(node.path),
                        u'*****@*****.**')

        newtip = self.repo.get_changeset()
        self.assertNotEqual(tip, newtip)
        self.assertNotEqual(tip.id, newtip.id)

        self.assertEqual(newtip.get_node('żółwik/zwierzątko').content,
                         'My **changed** content')
        self.assertEqual(newtip.get_node('żółwik/zwierzątko_uni').content,
                         'My **changed** content')
예제 #3
0
 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.changeset.short_id)
예제 #4
0
    def branch(self):

        heads = self.repository._heads(reverse=False)

        ref = heads.get(self.raw_id)
        if ref:
            return safe_unicode(ref)
예제 #5
0
 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.changeset.short_id)
예제 #6
0
    def branch(self):

        heads = self.repository._heads(reverse=False)

        ref = heads.get(self.raw_id)
        if ref:
            return safe_unicode(ref)
예제 #7
0
 def description(self):
     undefined_description = u'unknown'
     _desc = self._repo.ui.config('web',
                                  'description',
                                  None,
                                  untrusted=True)
     return safe_unicode(_desc or undefined_description)
예제 #8
0
    def _get_bookmarks(self):
        if self._empty:
            return {}

        sortkey = lambda ctx: ctx[0]  # sort by name
        _bookmarks = [(safe_unicode(n), hex(h),) for n, h in
                 self._repo._bookmarks.items()]
        return OrderedDict(sorted(_bookmarks, key=sortkey, reverse=True))
예제 #9
0
    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)
예제 #10
0
    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)
예제 #11
0
    def _get_bookmarks(self):
        if self._empty:
            return {}

        sortkey = lambda ctx: ctx[0]  # sort by name
        _bookmarks = [(
            safe_unicode(n),
            hex(h),
        ) for n, h in self._repo._bookmarks.items()]
        return OrderedDict(sorted(_bookmarks, key=sortkey, reverse=True))
예제 #12
0
    def __init__(self,
                 repo_path,
                 create=False,
                 src_url=None,
                 update_after_clone=False,
                 bare=False):

        self.path = safe_unicode(abspath(repo_path))
        self.repo = self._get_repo(create, src_url, update_after_clone, bare)
        self.bare = self.repo.bare
예제 #13
0
    def _get_branches(self, normal=True, closed=False):
        """
        Gets branches for this repository
        Returns only not closed branches by default

        :param closed: return also closed branches for mercurial
        :param normal: return also normal branches
        """

        if self._empty:
            return {}

        bt = OrderedDict()
        for bn, _heads, tip, isclosed in sorted(self._repo.branchmap().iterbranches()):
            if isclosed:
                if closed:
                    bt[safe_unicode(bn)] = hex(tip)
            else:
                if normal:
                    bt[safe_unicode(bn)] = hex(tip)

        return bt
예제 #14
0
    def _get_branches(self, normal=True, closed=False):
        """
        Gets branches for this repository
        Returns only not closed branches by default

        :param closed: return also closed branches for mercurial
        :param normal: return also normal branches
        """

        if self._empty:
            return {}

        bt = OrderedDict()
        for bn, _heads, tip, isclosed in sorted(
                self._repo.branchmap().iterbranches()):
            if isclosed:
                if closed:
                    bt[safe_unicode(bn)] = hex(tip)
            else:
                if normal:
                    bt[safe_unicode(bn)] = hex(tip)

        return bt
예제 #15
0
 def branch(self):
     return  safe_unicode(self._ctx.branch())
예제 #16
0
 def description(self):
     undefined_description = u'unknown'
     _desc = self._repo.get_description()
     return safe_unicode(_desc or undefined_description)
예제 #17
0
    def __init__(self, repo_path, create=False, src_url=None,
                 update_after_clone=False, bare=False):

        self.path = safe_unicode(abspath(repo_path))
        self.repo = self._get_repo(create, src_url, update_after_clone, bare)
        self.bare = self.repo.bare
예제 #18
0
 def message(self):
     return safe_unicode(self._ctx.description())
예제 #19
0
 def name_unicode(self):
     return safe_unicode(self.name)
예제 #20
0
 def author(self):
     return safe_unicode(self._ctx.user())
예제 #21
0
 def message(self):
     return safe_unicode(self._ctx.description())
예제 #22
0
 def contact(self):
     undefined_contact = u'Unknown'
     return safe_unicode(get_contact(self._repo.ui.config)
                         or undefined_contact)
예제 #23
0
 def committer(self):
     return safe_unicode(getattr(self._commit, self._committer_property))
예제 #24
0
 def unicode_path(self):
     return safe_unicode(self.path)
예제 #25
0
 def contact(self):
     undefined_contact = u'Unknown'
     return safe_unicode(
         get_contact(self._repo.ui.config) or undefined_contact)
예제 #26
0
 def line_decoder(l):
     if l.startswith('+') and not l.startswith('+++'):
         self.adds += 1
     elif l.startswith('-') and not l.startswith('---'):
         self.removes += 1
     return safe_unicode(l)
예제 #27
0
 def author(self):
     return safe_unicode(self._ctx.user())
예제 #28
0
 def line_decoder(l):
     if l.startswith('+') and not l.startswith('+++'):
         self.adds += 1
     elif l.startswith('-') and not l.startswith('---'):
         self.removes += 1
     return safe_unicode(l)
예제 #29
0
 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])
예제 #30
0
 def unicode_path(self):
     return safe_unicode(self.path)
예제 #31
0
 def description(self):
     undefined_description = u'unknown'
     _desc = self._repo.ui.config('web', 'description', None, untrusted=True)
     return safe_unicode(_desc or undefined_description)
예제 #32
0
 def committer(self):
     return safe_unicode(self.author)
예제 #33
0
 def message(self):
     return safe_unicode(self._commit.message)
예제 #34
0
 def committer(self):
     return safe_unicode(self.author)
예제 #35
0
 def author(self):
     return safe_unicode(getattr(self._commit, self._author_property))
예제 #36
0
 def message(self):
     return safe_unicode(self._commit.message)
예제 #37
0
 def committer(self):
     return safe_unicode(getattr(self._commit, self._committer_property))
예제 #38
0
 def author(self):
     return safe_unicode(getattr(self._commit, self._author_property))
예제 #39
0
 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])
예제 #40
0
 def branch(self):
     return  safe_unicode(self._ctx.branch())
예제 #41
0
파일: base.py 프로젝트: msabramo/kallithea
 def name_unicode(self):
     return safe_unicode(self.name)
예제 #42
0
 def description(self):
     undefined_description = u'unknown'
     _desc = self._repo.get_description()
     return safe_unicode(_desc or undefined_description)