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

login
register
mail settings
Submitter Jason R. Coombs
Date Jan. 29, 2016, 8:13 p.m.
Message ID <77639cbb262eb69d2a5f.1454098436@waste.org>
Download mbox | patch
Permalink /patch/12910/
State Deferred
Headers show

Comments

Jason R. Coombs - Jan. 29, 2016, 8:13 p.m.
# HG changeset patch
# User Jason R. Coombs <jaraco@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
Matt Mackall - Jan. 29, 2016, 8:44 p.m.
On Fri, 2016-01-29 at 14:13 -0600, Jason R. Coombs wrote:
> # HG changeset patch
> # User Jason R. Coombs <jaraco@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

Not sure how this series fits into the rules for stable / code-freeze, described
here:

https://www.mercurial-scm.org/wiki/TimeBasedReleasePlan#Rules_for_code_freeze_an
d_stable_branch_commits

-- 
Mathematics is the supreme nostalgia of our time.

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