diff --git a/hgext/schemes.py b/hgext/schemes.py --- a/hgext/schemes.py +++ b/hgext/schemes.py @@ -41,9 +41,11 @@ same name. """ import os, re -from mercurial import extensions, hg, templater, util, error +from mercurial import extensions, hg, templater, util, error, cmdutil from mercurial.i18n import _ +cmdtable = {} +command = cmdutil.command(cmdtable) # Note for extension authors: ONLY specify testedwith = 'internal' for # extensions which SHIP WITH MERCURIAL. Non-mainline extensions should # be specifying the version(s) of Mercurial they are tested with, or @@ -109,3 +111,12 @@ def extsetup(ui): hg.schemes[scheme] = ShortRepository(url, scheme, t) extensions.wrapfunction(util, 'hasdriveletter', hasdriveletter) + +@command('debugexpandscheme', norepo=True) +def expandscheme(ui, url, **opts): + """given a repo path, provide the scheme-expanded path + """ + repo = hg._peerlookup(url) + if isinstance(repo, ShortRepository): + url = repo.resolve(url) + ui.write(url + '\n') diff --git a/tests/test-schemes.t b/tests/test-schemes.t --- a/tests/test-schemes.t +++ b/tests/test-schemes.t @@ -52,6 +52,21 @@ check that paths are expanded no changes found [1] +check that debugexpandscheme outputs the canonical form + + $ hg debugexpandscheme bb://user/repo + https://bitbucket.org/user/repo + +expanding an unknown scheme emits the input + + $ hg debugexpandscheme foobar://this/that + foobar://this/that + +expanding a canonical URL emits the input + + $ hg debugexpandscheme https://bitbucket.org/user/repo + https://bitbucket.org/user/repo + errors $ cat errors.log