Esempio n. 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')
Esempio n. 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')
Esempio n. 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)
Esempio n. 4
0
    def branch(self):

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

        ref = heads.get(self.raw_id)
        if ref:
            return safe_unicode(ref)
Esempio n. 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)
Esempio n. 6
0
    def branch(self):

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

        ref = heads.get(self.raw_id)
        if ref:
            return safe_unicode(ref)
Esempio n. 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)
Esempio n. 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))
Esempio n. 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)
Esempio n. 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)
Esempio n. 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))
Esempio n. 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
Esempio n. 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
Esempio n. 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
Esempio n. 15
0
 def branch(self):
     return  safe_unicode(self._ctx.branch())
Esempio n. 16
0
 def description(self):
     undefined_description = u'unknown'
     _desc = self._repo.get_description()
     return safe_unicode(_desc or undefined_description)
Esempio n. 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
Esempio n. 18
0
 def message(self):
     return safe_unicode(self._ctx.description())
Esempio n. 19
0
 def name_unicode(self):
     return safe_unicode(self.name)
Esempio n. 20
0
 def author(self):
     return safe_unicode(self._ctx.user())
Esempio n. 21
0
 def message(self):
     return safe_unicode(self._ctx.description())
Esempio n. 22
0
 def contact(self):
     undefined_contact = u'Unknown'
     return safe_unicode(get_contact(self._repo.ui.config)
                         or undefined_contact)
Esempio n. 23
0
 def committer(self):
     return safe_unicode(getattr(self._commit, self._committer_property))
Esempio n. 24
0
 def unicode_path(self):
     return safe_unicode(self.path)
Esempio n. 25
0
 def contact(self):
     undefined_contact = u'Unknown'
     return safe_unicode(
         get_contact(self._repo.ui.config) or undefined_contact)
Esempio n. 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)
Esempio n. 27
0
 def author(self):
     return safe_unicode(self._ctx.user())
Esempio n. 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)
Esempio n. 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])
Esempio n. 30
0
 def unicode_path(self):
     return safe_unicode(self.path)
Esempio n. 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)
Esempio n. 32
0
 def committer(self):
     return safe_unicode(self.author)
Esempio n. 33
0
 def message(self):
     return safe_unicode(self._commit.message)
Esempio n. 34
0
 def committer(self):
     return safe_unicode(self.author)
Esempio n. 35
0
 def author(self):
     return safe_unicode(getattr(self._commit, self._author_property))
Esempio n. 36
0
 def message(self):
     return safe_unicode(self._commit.message)
Esempio n. 37
0
 def committer(self):
     return safe_unicode(getattr(self._commit, self._committer_property))
Esempio n. 38
0
 def author(self):
     return safe_unicode(getattr(self._commit, self._author_property))
Esempio n. 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])
Esempio n. 40
0
 def branch(self):
     return  safe_unicode(self._ctx.branch())
Esempio n. 41
0
 def name_unicode(self):
     return safe_unicode(self.name)
Esempio n. 42
0
 def description(self):
     undefined_description = u'unknown'
     _desc = self._repo.get_description()
     return safe_unicode(_desc or undefined_description)