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')
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)
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)
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 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
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
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 message(self): return safe_unicode(self._ctx.description())
def name_unicode(self): return safe_unicode(self.name)
def author(self): return safe_unicode(self._ctx.user())
def contact(self): undefined_contact = u'Unknown' return safe_unicode(get_contact(self._repo.ui.config) or undefined_contact)
def committer(self): return safe_unicode(getattr(self._commit, self._committer_property))
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)
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)
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])
def committer(self): return safe_unicode(self.author)
def message(self): return safe_unicode(self._commit.message)
def author(self): return safe_unicode(getattr(self._commit, self._author_property))