Пример #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
 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)