mercurial/commands.py
changeset 4888 2d545b98a7bc
parent 4879 da8640113b5a
child 4896 ee04732fe61d
equal deleted inserted replaced
4887:bbdcacf7cef8 4888:2d545b98a7bc
  2023         return 1
  2023         return 1
  2024     else:
  2024     else:
  2025         for name, path in ui.configitems("paths"):
  2025         for name, path in ui.configitems("paths"):
  2026             ui.write("%s = %s\n" % (name, path))
  2026             ui.write("%s = %s\n" % (name, path))
  2027 
  2027 
  2028 def postincoming(ui, repo, modheads, optupdate):
  2028 def postincoming(ui, repo, modheads, optupdate, wasempty):
  2029     if modheads == 0:
  2029     if modheads == 0:
  2030         return
  2030         return
  2031     if optupdate:
  2031     if optupdate:
  2032         if modheads == 1:
  2032         if wasempty:
       
  2033             return hg.update(repo, repo.lookup('default'))
       
  2034         elif modheads == 1:
  2033             return hg.update(repo, repo.changelog.tip()) # update
  2035             return hg.update(repo, repo.changelog.tip()) # update
  2034         else:
  2036         else:
  2035             ui.status(_("not updating, since new heads added\n"))
  2037             ui.status(_("not updating, since new heads added\n"))
  2036     if modheads > 1:
  2038     if modheads > 1:
  2037         ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
  2039         ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
  2089             revs = [other.lookup(rev) for rev in revs]
  2091             revs = [other.lookup(rev) for rev in revs]
  2090         else:
  2092         else:
  2091             error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.")
  2093             error = _("Other repository doesn't support revision lookup, so a rev cannot be specified.")
  2092             raise util.Abort(error)
  2094             raise util.Abort(error)
  2093 
  2095 
       
  2096     wasempty = repo.changelog.count() == 0
  2094     modheads = repo.pull(other, heads=revs, force=opts['force'])
  2097     modheads = repo.pull(other, heads=revs, force=opts['force'])
  2095     return postincoming(ui, repo, modheads, opts['update'])
  2098     return postincoming(ui, repo, modheads, opts['update'], wasempty)
  2096 
  2099 
  2097 def push(ui, repo, dest=None, **opts):
  2100 def push(ui, repo, dest=None, **opts):
  2098     """push changes to the specified destination
  2101     """push changes to the specified destination
  2099 
  2102 
  2100     Push changes from the local repository to the given destination.
  2103     Push changes from the local repository to the given destination.
  2654     Apply one or more compressed changegroup files generated by the
  2657     Apply one or more compressed changegroup files generated by the
  2655     bundle command.
  2658     bundle command.
  2656     """
  2659     """
  2657     fnames = (fname1,) + fnames
  2660     fnames = (fname1,) + fnames
  2658     result = None
  2661     result = None
       
  2662     wasempty = repo.changelog.count() == 0
  2659     for fname in fnames:
  2663     for fname in fnames:
  2660         if os.path.exists(fname):
  2664         if os.path.exists(fname):
  2661             f = open(fname, "rb")
  2665             f = open(fname, "rb")
  2662         else:
  2666         else:
  2663             f = urllib.urlopen(fname)
  2667             f = urllib.urlopen(fname)
  2664         gen = changegroup.readbundle(f, fname)
  2668         gen = changegroup.readbundle(f, fname)
  2665         modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
  2669         modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
  2666 
  2670 
  2667     return postincoming(ui, repo, modheads, opts['update'])
  2671     return postincoming(ui, repo, modheads, opts['update'], wasempty)
  2668 
  2672 
  2669 def update(ui, repo, node=None, rev=None, clean=False, date=None):
  2673 def update(ui, repo, node=None, rev=None, clean=False, date=None):
  2670     """update working directory
  2674     """update working directory
  2671 
  2675 
  2672     Update the working directory to the specified revision, or the
  2676     Update the working directory to the specified revision, or the