Mercurial > hg
view tests/test-hg-parseurl.py @ 41595:8785188d1915
scmutil: introduce a new backuppath() to replace origpath()
Unlike most functions in our codebase, origpath() takes a path that is
relative to cwd. This commit introduces a replacement for
origpath(). The new function takes a path that is relative to the repo
root. There is a lot of duplication between the two, but I intend to
remove origpath() within the next few commits, so it won't be a
maintenance burden.
origpath() is also a little weird in that it returns either a a
cwd-relative path or an absolute path. It needs to be able to return a
path outside the repo, so it makes sense that it can return an
absolute path. However, it would be simpler to always return an
absolute path. The new function does that.
Differential Revision: https://phab.mercurial-scm.org/D5851
author | Martin von Zweigbergk <martinvonz@google.com> |
---|---|
date | Mon, 04 Feb 2019 20:46:33 -0800 |
parents | 5dd71e9ae68a |
children | 2372284d9457 |
line wrap: on
line source
from __future__ import absolute_import, print_function import unittest from mercurial import ( hg, ) class ParseRequestTests(unittest.TestCase): def testparse(self): self.assertEqual(hg.parseurl(b'http://example.com/no/anchor'), (b'http://example.com/no/anchor', (None, []))) self.assertEqual(hg.parseurl(b'http://example.com/an/anchor#foo'), (b'http://example.com/an/anchor', (b'foo', []))) self.assertEqual( hg.parseurl(b'http://example.com/no/anchor/branches', [b'foo']), (b'http://example.com/no/anchor/branches', (None, [b'foo']))) self.assertEqual( hg.parseurl(b'http://example.com/an/anchor/branches#bar', [b'foo']), (b'http://example.com/an/anchor/branches', (b'bar', [b'foo']))) self.assertEqual(hg.parseurl( b'http://example.com/an/anchor/branches-None#foo', None), (b'http://example.com/an/anchor/branches-None', (b'foo', []))) self.assertEqual(hg.parseurl(b'http://example.com/'), (b'http://example.com/', (None, []))) self.assertEqual(hg.parseurl(b'http://example.com'), (b'http://example.com/', (None, []))) self.assertEqual(hg.parseurl(b'http://example.com#foo'), (b'http://example.com/', (b'foo', []))) if __name__ == '__main__': import silenttestrunner silenttestrunner.main(__name__)