mercurial/commands.py
changeset 7637 1d54e2f6c0b7
parent 7633 08cabecfa8a8
child 7643 9a1ea6587557
equal deleted inserted replaced
7636:e3f8c6d6b72e 7637:1d54e2f6c0b7
     4 #
     4 #
     5 # This software may be used and distributed according to the terms
     5 # This software may be used and distributed according to the terms
     6 # of the GNU General Public License, incorporated herein by reference.
     6 # of the GNU General Public License, incorporated herein by reference.
     7 
     7 
     8 from node import hex, nullid, nullrev, short
     8 from node import hex, nullid, nullrev, short
     9 from repo import RepoError, NoCapability
       
    10 from i18n import _, gettext
     9 from i18n import _, gettext
    11 import os, re, sys
    10 import os, re, sys
    12 import hg, util, revlog, bundlerepo, extensions, copies, context, error
    11 import hg, util, revlog, bundlerepo, extensions, copies, context, error
    13 import difflib, patch, time, help, mdiff, tempfile, url
    12 import difflib, patch, time, help, mdiff, tempfile, url
    14 import archival, changegroup, cmdutil, hgweb.server, sshserver, hbisect
    13 import archival, changegroup, cmdutil, hgweb.server, sshserver, hbisect
  1669                     try:
  1668                     try:
  1670                         p1 = repo.lookup(p1)
  1669                         p1 = repo.lookup(p1)
  1671                         p2 = repo.lookup(p2)
  1670                         p2 = repo.lookup(p2)
  1672                         if p1 == wp[0].node():
  1671                         if p1 == wp[0].node():
  1673                             repo.dirstate.setparents(p1, p2)
  1672                             repo.dirstate.setparents(p1, p2)
  1674                     except RepoError:
  1673                     except error.RepoError:
  1675                         pass
  1674                         pass
  1676                 if opts.get('exact') or opts.get('import_branch'):
  1675                 if opts.get('exact') or opts.get('import_branch'):
  1677                     repo.dirstate.setbranch(branch or 'default')
  1676                     repo.dirstate.setbranch(branch or 'default')
  1678 
  1677 
  1679                 files = {}
  1678                 files = {}
  2177     other = hg.repository(ui, source)
  2176     other = hg.repository(ui, source)
  2178     ui.status(_('pulling from %s\n') % url.hidepassword(source))
  2177     ui.status(_('pulling from %s\n') % url.hidepassword(source))
  2179     if revs:
  2178     if revs:
  2180         try:
  2179         try:
  2181             revs = [other.lookup(rev) for rev in revs]
  2180             revs = [other.lookup(rev) for rev in revs]
  2182         except NoCapability:
  2181         except error.CapabilityError:
  2183             error = _("Other repository doesn't support revision lookup, "
  2182             err = _("Other repository doesn't support revision lookup, "
  2184                       "so a rev cannot be specified.")
  2183                     "so a rev cannot be specified.")
  2185             raise util.Abort(error)
  2184             raise util.Abort(err)
  2186 
  2185 
  2187     modheads = repo.pull(other, heads=revs, force=opts.get('force'))
  2186     modheads = repo.pull(other, heads=revs, force=opts.get('force'))
  2188     return postincoming(ui, repo, modheads, opts.get('update'), checkout)
  2187     return postincoming(ui, repo, modheads, opts.get('update'), checkout)
  2189 
  2188 
  2190 def push(ui, repo, dest=None, **opts):
  2189 def push(ui, repo, dest=None, **opts):
  2647     stderr. Use the "-A" and "-E" options to log to files.
  2646     stderr. Use the "-A" and "-E" options to log to files.
  2648     """
  2647     """
  2649 
  2648 
  2650     if opts["stdio"]:
  2649     if opts["stdio"]:
  2651         if repo is None:
  2650         if repo is None:
  2652             raise RepoError(_("There is no Mercurial repository here"
  2651             raise error.RepoError(_("There is no Mercurial repository here"
  2653                               " (.hg not found)"))
  2652                               " (.hg not found)"))
  2654         s = sshserver.sshserver(ui, repo)
  2653         s = sshserver.sshserver(ui, repo)
  2655         s.serve_forever()
  2654         s.serve_forever()
  2656 
  2655 
  2657     parentui = ui.parentui or ui
  2656     parentui = ui.parentui or ui
  2662             parentui.setconfig("web", o, str(opts[o]))
  2661             parentui.setconfig("web", o, str(opts[o]))
  2663             if (repo is not None) and (repo.ui != parentui):
  2662             if (repo is not None) and (repo.ui != parentui):
  2664                 repo.ui.setconfig("web", o, str(opts[o]))
  2663                 repo.ui.setconfig("web", o, str(opts[o]))
  2665 
  2664 
  2666     if repo is None and not ui.config("web", "webdir_conf"):
  2665     if repo is None and not ui.config("web", "webdir_conf"):
  2667         raise RepoError(_("There is no Mercurial repository here"
  2666         raise error.RepoError(_("There is no Mercurial repository here"
  2668                           " (.hg not found)"))
  2667                                 " (.hg not found)"))
  2669 
  2668 
  2670     class service:
  2669     class service:
  2671         def init(self):
  2670         def init(self):
  2672             util.set_signal_handler()
  2671             util.set_signal_handler()
  2673             self.httpd = hgweb.server.create_server(parentui, repo)
  2672             self.httpd = hgweb.server.create_server(parentui, repo)