mercurial/hg.py
changeset 14076 924c82157d46
parent 14073 72c84f24b420
child 14156 839086b25c36
equal deleted inserted replaced
14075:bc101902a68d 14076:924c82157d46
     9 from i18n import _
     9 from i18n import _
    10 from lock import release
    10 from lock import release
    11 from node import hex, nullid
    11 from node import hex, nullid
    12 import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo, bookmarks
    12 import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo, bookmarks
    13 import lock, util, extensions, error, node
    13 import lock, util, extensions, error, node
    14 import cmdutil, discovery, url
    14 import cmdutil, discovery
    15 import merge as mergemod
    15 import merge as mergemod
    16 import verify as verifymod
    16 import verify as verifymod
    17 import errno, os, shutil
    17 import errno, os, shutil
    18 
    18 
    19 def _local(path):
    19 def _local(path):
    20     path = util.expandpath(url.localpath(path))
    20     path = util.expandpath(util.localpath(path))
    21     return (os.path.isfile(path) and bundlerepo or localrepo)
    21     return (os.path.isfile(path) and bundlerepo or localrepo)
    22 
    22 
    23 def addbranchrevs(lrepo, repo, branches, revs):
    23 def addbranchrevs(lrepo, repo, branches, revs):
    24     hashbranch, branches = branches
    24     hashbranch, branches = branches
    25     if not hashbranch and not branches:
    25     if not hashbranch and not branches:
    52     return revs, revs[0]
    52     return revs, revs[0]
    53 
    53 
    54 def parseurl(path, branches=None):
    54 def parseurl(path, branches=None):
    55     '''parse url#branch, returning (url, (branch, branches))'''
    55     '''parse url#branch, returning (url, (branch, branches))'''
    56 
    56 
    57     u = url.url(path)
    57     u = util.url(path)
    58     branch = None
    58     branch = None
    59     if u.fragment:
    59     if u.fragment:
    60         branch = u.fragment
    60         branch = u.fragment
    61         u.fragment = None
    61         u.fragment = None
    62     return str(u), (branch, branches or [])
    62     return str(u), (branch, branches or [])
    69     'ssh': sshrepo,
    69     'ssh': sshrepo,
    70     'static-http': statichttprepo,
    70     'static-http': statichttprepo,
    71 }
    71 }
    72 
    72 
    73 def _lookup(path):
    73 def _lookup(path):
    74     u = url.url(path)
    74     u = util.url(path)
    75     scheme = u.scheme or 'file'
    75     scheme = u.scheme or 'file'
    76     thing = schemes.get(scheme) or schemes['file']
    76     thing = schemes.get(scheme) or schemes['file']
    77     try:
    77     try:
    78         return thing(path)
    78         return thing(path)
    79     except TypeError:
    79     except TypeError:
   219         dest = defaultdest(source)
   219         dest = defaultdest(source)
   220         ui.status(_("destination directory: %s\n") % dest)
   220         ui.status(_("destination directory: %s\n") % dest)
   221     else:
   221     else:
   222         dest = ui.expandpath(dest)
   222         dest = ui.expandpath(dest)
   223 
   223 
   224     dest = url.localpath(dest)
   224     dest = util.localpath(dest)
   225     source = url.localpath(source)
   225     source = util.localpath(source)
   226 
   226 
   227     if os.path.exists(dest):
   227     if os.path.exists(dest):
   228         if not os.path.isdir(dest):
   228         if not os.path.isdir(dest):
   229             raise util.Abort(_("destination '%s' already exists") % dest)
   229             raise util.Abort(_("destination '%s' already exists") % dest)
   230         elif os.listdir(dest):
   230         elif os.listdir(dest):
   246             dir_cleanup = DirCleanup(dest)
   246             dir_cleanup = DirCleanup(dest)
   247 
   247 
   248         abspath = origsource
   248         abspath = origsource
   249         copy = False
   249         copy = False
   250         if src_repo.cancopy() and islocal(dest):
   250         if src_repo.cancopy() and islocal(dest):
   251             abspath = os.path.abspath(url.localpath(origsource))
   251             abspath = os.path.abspath(util.localpath(origsource))
   252             copy = not pull and not rev
   252             copy = not pull and not rev
   253 
   253 
   254         if copy:
   254         if copy:
   255             try:
   255             try:
   256                 # we use a lock here because if we race with commit, we
   256                 # we use a lock here because if we race with commit, we
   419         (remoterepo, incomingchangesetlist, displayer) parameters,
   419         (remoterepo, incomingchangesetlist, displayer) parameters,
   420     and is supposed to contain only code that can't be unified.
   420     and is supposed to contain only code that can't be unified.
   421     """
   421     """
   422     source, branches = parseurl(ui.expandpath(source), opts.get('branch'))
   422     source, branches = parseurl(ui.expandpath(source), opts.get('branch'))
   423     other = repository(remoteui(repo, opts), source)
   423     other = repository(remoteui(repo, opts), source)
   424     ui.status(_('comparing with %s\n') % url.hidepassword(source))
   424     ui.status(_('comparing with %s\n') % util.hidepassword(source))
   425     revs, checkout = addbranchrevs(repo, other, branches, opts.get('rev'))
   425     revs, checkout = addbranchrevs(repo, other, branches, opts.get('rev'))
   426 
   426 
   427     if revs:
   427     if revs:
   428         revs = [other.lookup(rev) for rev in revs]
   428         revs = [other.lookup(rev) for rev in revs]
   429     other, common, anyinc, bundle = bundlerepo.getremotechanges(ui, repo, other,
   429     other, common, anyinc, bundle = bundlerepo.getremotechanges(ui, repo, other,
   475     return _incoming(display, subreporecurse, ui, repo, source, opts)
   475     return _incoming(display, subreporecurse, ui, repo, source, opts)
   476 
   476 
   477 def _outgoing(ui, repo, dest, opts):
   477 def _outgoing(ui, repo, dest, opts):
   478     dest = ui.expandpath(dest or 'default-push', dest or 'default')
   478     dest = ui.expandpath(dest or 'default-push', dest or 'default')
   479     dest, branches = parseurl(dest, opts.get('branch'))
   479     dest, branches = parseurl(dest, opts.get('branch'))
   480     ui.status(_('comparing with %s\n') % url.hidepassword(dest))
   480     ui.status(_('comparing with %s\n') % util.hidepassword(dest))
   481     revs, checkout = addbranchrevs(repo, repo, branches, opts.get('rev'))
   481     revs, checkout = addbranchrevs(repo, repo, branches, opts.get('rev'))
   482     if revs:
   482     if revs:
   483         revs = [repo.lookup(rev) for rev in revs]
   483         revs = [repo.lookup(rev) for rev in revs]
   484 
   484 
   485     other = repository(remoteui(repo, opts), dest)
   485     other = repository(remoteui(repo, opts), dest)