Patchwork [2,of,3,v2] schemes: add expand-scheme command, resolving a scheme to its canonical form

login
register
mail settings
Submitter Jason R. Coombs
Date Feb. 1, 2016, 2:09 p.m.
Message ID <4c43c291019bd015d803.1454335784@waste.org>
Download mbox | patch
Permalink /patch/12932/
State Accepted
Headers show

Comments

Jason R. Coombs - Feb. 1, 2016, 2:09 p.m.
# HG changeset patch
# User Jason R. Coombs <jaraco@jaraco.com>
# Date 1454096876 18000
#      Fri Jan 29 14:47:56 2016 -0500
# Node ID 4c43c291019bd015d803ac0f5d4f1faef92165b8
# Parent  315d5f0fdf71c4f173a09916d11133103fdbec1c
schemes: add expand-scheme command, resolving a scheme to its canonical form

Patch

diff --git a/hgext/schemes.py b/hgext/schemes.py
--- a/hgext/schemes.py
+++ b/hgext/schemes.py
@@ -41,7 +41,7 @@ 
 """
 
 import os, re
-from mercurial import extensions, hg, templater, util, error
+from mercurial import extensions, hg, templater, util, error, cmdutil
 from mercurial.i18n import _
 
 # Note for extension authors: ONLY specify testedwith = 'internal' for
@@ -109,3 +109,15 @@ 
         hg.schemes[scheme] = ShortRepository(url, scheme, t)
 
     extensions.wrapfunction(util, 'hasdriveletter', hasdriveletter)
+
+cmdtable = {}
+command = cmdutil.command(cmdtable)
+
+@command('expand-scheme', 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(ui, url)
+    ui.status(url + '\n')