# HG changeset patch # User mpm@selenic.com # Date 1119954636 28800 # Node ID 1f81ebff98c999d5c164dc4cae7413aaabe6ba28 # Parent dc1f735dfaaca416615ad565e0e01d061aaf1644 [PATCH] Add ui.expandpath command -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [PATCH] Add ui.expandpath command From: Bryan O'Sullivan Add ui.expandpath function. manifest hash: dd2b9e536b94b453b06604b88ba339d93698b2e0 -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (GNU/Linux) iD8DBQFCwSbMywK+sNU5EO8RAibuAJ9jAMqhR3cbTqbPG3g9M8INgFmbvACgjAU2 LpalLI+zhalEUIf1Uw8W5l8= =fqB8 -----END PGP SIGNATURE----- diff -r dc1f735dfaac -r 1f81ebff98c9 mercurial/commands.py --- a/mercurial/commands.py Tue Jun 28 02:22:45 2005 -0800 +++ b/mercurial/commands.py Tue Jun 28 02:30:36 2005 -0800 @@ -267,11 +267,7 @@ def clone(ui, source, dest = None, **opts): """make a copy of an existing repository""" - paths = {} - for name, path in ui.configitems("paths"): - paths[name] = path - - if source in paths: source = paths[source] + source = ui.expandpath(source) created = success = False @@ -549,12 +545,7 @@ def pull(ui, repo, source="default", **opts): """pull changes from the specified source""" - paths = {} - for name, path in ui.configitems("paths"): - paths[name] = path - - if source in paths: - source = paths[source] + source = ui.expandpath(source) ui.status('pulling from %s\n' % (source)) @@ -571,11 +562,7 @@ def push(ui, repo, dest="default-push"): """push changes to the specified destination""" - paths = {} - for name, path in ui.configitems("paths"): - paths[name] = path - - if dest in paths: dest = paths[dest] + dest = ui.expandpath(dest) if not dest.startswith("ssh://"): ui.warn("abort: can only push to ssh:// destinations currently\n") diff -r dc1f735dfaac -r 1f81ebff98c9 mercurial/ui.py --- a/mercurial/ui.py Tue Jun 28 02:22:45 2005 -0800 +++ b/mercurial/ui.py Tue Jun 28 02:30:36 2005 -0800 @@ -41,6 +41,13 @@ return self.cdata.items(section) return [] + def expandpath(self, loc): + paths = {} + for name, path in self.configitems("paths"): + paths[name] = path + + return paths.get(loc, loc) + def write(self, *args): for a in args: sys.stdout.write(str(a))