comparison mercurial/commands.py @ 7270:2db33c1a5654

factor out the url handling from httprepo Create url.py to handle all the url handling: - proxy handling - workaround various python bugs - handle username/password embedded in the url
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Mon, 27 Oct 2008 21:50:01 +0100
parents db6fbb785800
children 8046f0a070a6
comparison
equal deleted inserted replaced
7269:95a53961d7a6 7270:2db33c1a5654
8 from node import hex, nullid, nullrev, short 8 from node import hex, nullid, nullrev, short
9 from repo import RepoError, NoCapability 9 from repo import RepoError, NoCapability
10 from i18n import _, gettext 10 from i18n import _, gettext
11 import os, re, sys, urllib 11 import os, re, sys, urllib
12 import hg, util, revlog, bundlerepo, extensions, copies 12 import hg, util, revlog, bundlerepo, extensions, copies
13 import difflib, patch, time, help, mdiff, tempfile 13 import difflib, patch, time, help, mdiff, tempfile, url
14 import version, socket 14 import version, socket
15 import archival, changegroup, cmdutil, hgweb.server, sshserver, hbisect 15 import archival, changegroup, cmdutil, hgweb.server, sshserver, hbisect
16 import merge as merge_ 16 import merge as merge_
17 17
18 # Commands start here, listed alphabetically 18 # Commands start here, listed alphabetically
1673 limit = cmdutil.loglimit(opts) 1673 limit = cmdutil.loglimit(opts)
1674 source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev')) 1674 source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev'))
1675 cmdutil.setremoteconfig(ui, opts) 1675 cmdutil.setremoteconfig(ui, opts)
1676 1676
1677 other = hg.repository(ui, source) 1677 other = hg.repository(ui, source)
1678 ui.status(_('comparing with %s\n') % util.hidepassword(source)) 1678 ui.status(_('comparing with %s\n') % url.hidepassword(source))
1679 if revs: 1679 if revs:
1680 revs = [other.lookup(rev) for rev in revs] 1680 revs = [other.lookup(rev) for rev in revs]
1681 incoming = repo.findincoming(other, heads=revs, force=opts["force"]) 1681 incoming = repo.findincoming(other, heads=revs, force=opts["force"])
1682 if not incoming: 1682 if not incoming:
1683 try: 1683 try:
1995 cmdutil.setremoteconfig(ui, opts) 1995 cmdutil.setremoteconfig(ui, opts)
1996 if revs: 1996 if revs:
1997 revs = [repo.lookup(rev) for rev in revs] 1997 revs = [repo.lookup(rev) for rev in revs]
1998 1998
1999 other = hg.repository(ui, dest) 1999 other = hg.repository(ui, dest)
2000 ui.status(_('comparing with %s\n') % util.hidepassword(dest)) 2000 ui.status(_('comparing with %s\n') % url.hidepassword(dest))
2001 o = repo.findoutgoing(other, force=opts.get('force')) 2001 o = repo.findoutgoing(other, force=opts.get('force'))
2002 if not o: 2002 if not o:
2003 ui.status(_("no changes found\n")) 2003 ui.status(_("no changes found\n"))
2004 return 1 2004 return 1
2005 o = repo.changelog.nodesbetween(o, revs)[0] 2005 o = repo.changelog.nodesbetween(o, revs)[0]
2066 and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too. 2066 and $HOME/.hgrc. If run inside a repository, .hg/hgrc is used, too.
2067 """ 2067 """
2068 if search: 2068 if search:
2069 for name, path in ui.configitems("paths"): 2069 for name, path in ui.configitems("paths"):
2070 if name == search: 2070 if name == search:
2071 ui.write("%s\n" % util.hidepassword(path)) 2071 ui.write("%s\n" % url.hidepassword(path))
2072 return 2072 return
2073 ui.warn(_("not found!\n")) 2073 ui.warn(_("not found!\n"))
2074 return 1 2074 return 1
2075 else: 2075 else:
2076 for name, path in ui.configitems("paths"): 2076 for name, path in ui.configitems("paths"):
2077 ui.write("%s = %s\n" % (name, util.hidepassword(path))) 2077 ui.write("%s = %s\n" % (name, url.hidepassword(path)))
2078 2078
2079 def postincoming(ui, repo, modheads, optupdate, checkout): 2079 def postincoming(ui, repo, modheads, optupdate, checkout):
2080 if modheads == 0: 2080 if modheads == 0:
2081 return 2081 return
2082 if optupdate: 2082 if optupdate:
2129 """ 2129 """
2130 source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev')) 2130 source, revs, checkout = hg.parseurl(ui.expandpath(source), opts.get('rev'))
2131 cmdutil.setremoteconfig(ui, opts) 2131 cmdutil.setremoteconfig(ui, opts)
2132 2132
2133 other = hg.repository(ui, source) 2133 other = hg.repository(ui, source)
2134 ui.status(_('pulling from %s\n') % util.hidepassword(source)) 2134 ui.status(_('pulling from %s\n') % url.hidepassword(source))
2135 if revs: 2135 if revs:
2136 try: 2136 try:
2137 revs = [other.lookup(rev) for rev in revs] 2137 revs = [other.lookup(rev) for rev in revs]
2138 except NoCapability: 2138 except NoCapability:
2139 error = _("Other repository doesn't support revision lookup, " 2139 error = _("Other repository doesn't support revision lookup, "
2177 dest, revs, checkout = hg.parseurl( 2177 dest, revs, checkout = hg.parseurl(
2178 ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev')) 2178 ui.expandpath(dest or 'default-push', dest or 'default'), opts.get('rev'))
2179 cmdutil.setremoteconfig(ui, opts) 2179 cmdutil.setremoteconfig(ui, opts)
2180 2180
2181 other = hg.repository(ui, dest) 2181 other = hg.repository(ui, dest)
2182 ui.status(_('pushing to %s\n') % util.hidepassword(dest)) 2182 ui.status(_('pushing to %s\n') % url.hidepassword(dest))
2183 if revs: 2183 if revs:
2184 revs = [repo.lookup(rev) for rev in revs] 2184 revs = [repo.lookup(rev) for rev in revs]
2185 r = repo.push(other, opts.get('force'), revs=revs) 2185 r = repo.push(other, opts.get('force'), revs=revs)
2186 return r == 0 2186 return r == 0
2187 2187