mercurial/commands.py
changeset 5241 5517aa5aafb0
parent 5224 9cd6578750b9
parent 5238 20817af258d8
child 5255 65dc707606ed
equal deleted inserted replaced
5234:20770c5d41e0 5241:5517aa5aafb0
   333                     if p not in seen:
   333                     if p not in seen:
   334                         seen[p] = 1
   334                         seen[p] = 1
   335                         visit.append(p)
   335                         visit.append(p)
   336     else:
   336     else:
   337         cmdutil.setremoteconfig(ui, opts)
   337         cmdutil.setremoteconfig(ui, opts)
   338         dest, revs = hg.parseurl(
   338         dest, revs, checkout = hg.parseurl(
   339             ui.expandpath(dest or 'default-push', dest or 'default'), revs)
   339             ui.expandpath(dest or 'default-push', dest or 'default'), revs)
   340         other = hg.repository(ui, dest)
   340         other = hg.repository(ui, dest)
   341         o = repo.findoutgoing(other, force=opts['force'])
   341         o = repo.findoutgoing(other, force=opts['force'])
   342 
   342 
   343     if revs:
   343     if revs:
  1472     hexfunc = ui.debugflag and hex or short
  1472     hexfunc = ui.debugflag and hex or short
  1473     default = not (num or id or branch or tags)
  1473     default = not (num or id or branch or tags)
  1474     output = []
  1474     output = []
  1475 
  1475 
  1476     if source:
  1476     if source:
  1477         source, revs = hg.parseurl(ui.expandpath(source), [])
  1477         source, revs, checkout = hg.parseurl(ui.expandpath(source), [])
  1478         srepo = hg.repository(ui, source)
  1478         srepo = hg.repository(ui, source)
  1479         if not rev and revs:
  1479         if not rev and revs:
  1480             rev = revs[0]
  1480             rev = revs[0]
  1481         if not rev:
  1481         if not rev:
  1482             rev = "tip"
  1482             rev = "tip"
  1637     For remote repository, using --bundle avoids downloading the changesets
  1637     For remote repository, using --bundle avoids downloading the changesets
  1638     twice if the incoming is followed by a pull.
  1638     twice if the incoming is followed by a pull.
  1639 
  1639 
  1640     See pull for valid source format details.
  1640     See pull for valid source format details.
  1641     """
  1641     """
  1642     source, revs = hg.parseurl(ui.expandpath(source), opts['rev'])
  1642     source, revs, checkout = hg.parseurl(ui.expandpath(source), opts['rev'])
  1643     cmdutil.setremoteconfig(ui, opts)
  1643     cmdutil.setremoteconfig(ui, opts)
  1644 
  1644 
  1645     other = hg.repository(ui, source)
  1645     other = hg.repository(ui, source)
  1646     ui.status(_('comparing with %s\n') % source)
  1646     ui.status(_('comparing with %s\n') % source)
  1647     if revs:
  1647     if revs:
  1948     the default push location. These are the changesets that would be pushed
  1948     the default push location. These are the changesets that would be pushed
  1949     if a push was requested.
  1949     if a push was requested.
  1950 
  1950 
  1951     See pull for valid destination format details.
  1951     See pull for valid destination format details.
  1952     """
  1952     """
  1953     dest, revs = hg.parseurl(
  1953     dest, revs, checkout = hg.parseurl(
  1954         ui.expandpath(dest or 'default-push', dest or 'default'), opts['rev'])
  1954         ui.expandpath(dest or 'default-push', dest or 'default'), opts['rev'])
  1955     cmdutil.setremoteconfig(ui, opts)
  1955     cmdutil.setremoteconfig(ui, opts)
  1956     if revs:
  1956     if revs:
  1957         revs = [repo.lookup(rev) for rev in revs]
  1957         revs = [repo.lookup(rev) for rev in revs]
  1958 
  1958 
  2016         return 1
  2016         return 1
  2017     else:
  2017     else:
  2018         for name, path in ui.configitems("paths"):
  2018         for name, path in ui.configitems("paths"):
  2019             ui.write("%s = %s\n" % (name, path))
  2019             ui.write("%s = %s\n" % (name, path))
  2020 
  2020 
  2021 def postincoming(ui, repo, modheads, optupdate):
  2021 def postincoming(ui, repo, modheads, optupdate, checkout):
  2022     if modheads == 0:
  2022     if modheads == 0:
  2023         return
  2023         return
  2024     if optupdate:
  2024     if optupdate:
  2025         if modheads <= 1:
  2025         if modheads <= 1 or checkout:
  2026             return hg.update(repo, None)
  2026             return hg.update(repo, checkout)
  2027         else:
  2027         else:
  2028             ui.status(_("not updating, since new heads added\n"))
  2028             ui.status(_("not updating, since new heads added\n"))
  2029     if modheads > 1:
  2029     if modheads > 1:
  2030         ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
  2030         ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
  2031     else:
  2031     else:
  2070         Host *
  2070         Host *
  2071           Compression yes
  2071           Compression yes
  2072       Alternatively specify "ssh -C" as your ssh command in your hgrc or
  2072       Alternatively specify "ssh -C" as your ssh command in your hgrc or
  2073       with the --ssh command line option.
  2073       with the --ssh command line option.
  2074     """
  2074     """
  2075     source, revs = hg.parseurl(ui.expandpath(source), opts['rev'])
  2075     source, revs, checkout = hg.parseurl(ui.expandpath(source), opts['rev'])
  2076     cmdutil.setremoteconfig(ui, opts)
  2076     cmdutil.setremoteconfig(ui, opts)
  2077 
  2077 
  2078     other = hg.repository(ui, source)
  2078     other = hg.repository(ui, source)
  2079     ui.status(_('pulling from %s\n') % (source))
  2079     ui.status(_('pulling from %s\n') % (source))
  2080     if revs:
  2080     if revs:
  2083         else:
  2083         else:
  2084             error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.")
  2084             error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.")
  2085             raise util.Abort(error)
  2085             raise util.Abort(error)
  2086 
  2086 
  2087     modheads = repo.pull(other, heads=revs, force=opts['force'])
  2087     modheads = repo.pull(other, heads=revs, force=opts['force'])
  2088     return postincoming(ui, repo, modheads, opts['update'])
  2088     return postincoming(ui, repo, modheads, opts['update'], checkout)
  2089 
  2089 
  2090 def push(ui, repo, dest=None, **opts):
  2090 def push(ui, repo, dest=None, **opts):
  2091     """push changes to the specified destination
  2091     """push changes to the specified destination
  2092 
  2092 
  2093     Push changes from the local repository to the given destination.
  2093     Push changes from the local repository to the given destination.
  2115     about ssh:// URLs.
  2115     about ssh:// URLs.
  2116 
  2116 
  2117     Pushing to http:// and https:// URLs is only possible, if this
  2117     Pushing to http:// and https:// URLs is only possible, if this
  2118     feature is explicitly enabled on the remote Mercurial server.
  2118     feature is explicitly enabled on the remote Mercurial server.
  2119     """
  2119     """
  2120     dest, revs = hg.parseurl(
  2120     dest, revs, checkout = hg.parseurl(
  2121         ui.expandpath(dest or 'default-push', dest or 'default'), opts['rev'])
  2121         ui.expandpath(dest or 'default-push', dest or 'default'), opts['rev'])
  2122     cmdutil.setremoteconfig(ui, opts)
  2122     cmdutil.setremoteconfig(ui, opts)
  2123 
  2123 
  2124     other = hg.repository(ui, dest)
  2124     other = hg.repository(ui, dest)
  2125     ui.status('pushing to %s\n' % (dest))
  2125     ui.status('pushing to %s\n' % (dest))
  2661         else:
  2661         else:
  2662             f = urllib.urlopen(fname)
  2662             f = urllib.urlopen(fname)
  2663         gen = changegroup.readbundle(f, fname)
  2663         gen = changegroup.readbundle(f, fname)
  2664         modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
  2664         modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
  2665 
  2665 
  2666     return postincoming(ui, repo, modheads, opts['update'])
  2666     return postincoming(ui, repo, modheads, opts['update'], None)
  2667 
  2667 
  2668 def update(ui, repo, node=None, rev=None, clean=False, date=None):
  2668 def update(ui, repo, node=None, rev=None, clean=False, date=None):
  2669     """update working directory
  2669     """update working directory
  2670 
  2670 
  2671     Update the working directory to the specified revision, or the
  2671     Update the working directory to the specified revision, or the