Exemple #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')
    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')
Exemple #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)
Exemple #4
0
    def branch(self):

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

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

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

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