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

Jason R. Coombs jaraco at jaraco.com
Fri Jan 29 14:13:56 CST 2016


# HG changeset patch
# User Jason R. Coombs <jaraco at jaraco.com>
# Date 1454096876 18000
#      Fri Jan 29 14:47:56 2016 -0500
# Branch stable
# Node ID 77639cbb262eb69d2a5fdfe100bdb17649c8d844
# Parent  69854d00f42654a31d113294024f50c9e81e8779
schemes: add expand-scheme command, resolving a scheme to its canonical form

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)
+
+ at 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')


More information about the Mercurial-devel mailing list