mercurial/commands.py
changeset 7271 8046f0a070a6
parent 7270 2db33c1a5654
child 7276 08dc0152bb5e
equal deleted inserted replaced
7270:2db33c1a5654 7271:8046f0a070a6
     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
     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
    12 import hg, util, revlog, bundlerepo, extensions, copies
    12 import hg, util, revlog, bundlerepo, extensions, copies
    13 import difflib, patch, time, help, mdiff, tempfile, url
    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_
  1588         for p in patches:
  1588         for p in patches:
  1589             pf = os.path.join(d, p)
  1589             pf = os.path.join(d, p)
  1590 
  1590 
  1591             if pf == '-':
  1591             if pf == '-':
  1592                 ui.status(_("applying patch from stdin\n"))
  1592                 ui.status(_("applying patch from stdin\n"))
  1593                 data = patch.extract(ui, sys.stdin)
  1593                 pf = sys.stdin
  1594             else:
  1594             else:
  1595                 ui.status(_("applying %s\n") % p)
  1595                 ui.status(_("applying %s\n") % p)
  1596                 if os.path.exists(pf):
  1596                 pf = url.open(ui, pf)
  1597                     data = patch.extract(ui, file(pf, 'rb'))
  1597             data = patch.extract(ui, pf)
  1598                 else:
       
  1599                     data = patch.extract(ui, urllib.urlopen(pf))
       
  1600             tmpname, message, user, date, branch, nodeid, p1, p2 = data
  1598             tmpname, message, user, date, branch, nodeid, p1, p2 = data
  1601 
  1599 
  1602             if tmpname is None:
  1600             if tmpname is None:
  1603                 raise util.Abort(_('no diffs found'))
  1601                 raise util.Abort(_('no diffs found'))
  1604 
  1602 
  2842 
  2840 
  2843     lock = None
  2841     lock = None
  2844     try:
  2842     try:
  2845         lock = repo.lock()
  2843         lock = repo.lock()
  2846         for fname in fnames:
  2844         for fname in fnames:
  2847             if os.path.exists(fname):
  2845             f = url.open(ui, fname)
  2848                 f = open(fname, "rb")
       
  2849             else:
       
  2850                 f = urllib.urlopen(fname)
       
  2851             gen = changegroup.readbundle(f, fname)
  2846             gen = changegroup.readbundle(f, fname)
  2852             modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
  2847             modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
  2853     finally:
  2848     finally:
  2854         del lock
  2849         del lock
  2855 
  2850