mercurial/commands.py
changeset 1469 0847c45ffee6
parent 1456 214f42f23a3b
parent 1467 06d5d8794e5f
child 1470 fb9b84c91222
equal deleted inserted replaced
1456:214f42f23a3b 1469:0847c45ffee6
   691     other = hg.repository(ui, source)
   691     other = hg.repository(ui, source)
   692 
   692 
   693     copy = False
   693     copy = False
   694     if other.dev() != -1:
   694     if other.dev() != -1:
   695         abspath = os.path.abspath(source)
   695         abspath = os.path.abspath(source)
   696         if not opts['pull']:
   696         if not opts['pull'] and not opts['rev']:
   697             copy = True
   697             copy = True
   698 
   698 
   699     if copy:
   699     if copy:
   700         try:
   700         try:
   701             # we use a lock here because if we race with commit, we
   701             # we use a lock here because if we race with commit, we
   721                 if inst.errno != errno.ENOENT: raise
   721                 if inst.errno != errno.ENOENT: raise
   722 
   722 
   723         repo = hg.repository(ui, dest)
   723         repo = hg.repository(ui, dest)
   724 
   724 
   725     else:
   725     else:
       
   726         revs = None
       
   727         if opts['rev']:
       
   728             if not other.local():
       
   729                 raise util.Abort("clone -r not supported yet for remote repositories.")
       
   730             else:
       
   731                 revs = [other.lookup(rev) for rev in opts['rev']]
   726         repo = hg.repository(ui, dest, create=1)
   732         repo = hg.repository(ui, dest, create=1)
   727         repo.pull(other)
   733         repo.pull(other, heads = revs)
   728 
   734 
   729     f = repo.opener("hgrc", "w", text=True)
   735     f = repo.opener("hgrc", "w", text=True)
   730     f.write("[paths]\n")
   736     f.write("[paths]\n")
   731     f.write("default = %s\n" % abspath)
   737     f.write("default = %s\n" % abspath)
   732 
   738 
  1394     if not other.local():
  1400     if not other.local():
  1395         raise util.Abort(_("incoming doesn't work for remote repositories yet"))
  1401         raise util.Abort(_("incoming doesn't work for remote repositories yet"))
  1396     o = repo.findincoming(other)
  1402     o = repo.findincoming(other)
  1397     if not o:
  1403     if not o:
  1398         return
  1404         return
  1399     o = other.newer(o)
  1405     o = other.changelog.nodesbetween(o)[0]
  1400     if opts['newest_first']:
  1406     if opts['newest_first']:
  1401         o.reverse()
  1407         o.reverse()
  1402     for n in o:
  1408     for n in o:
  1403         parents = [p for p in other.changelog.parents(n) if p != nullid]
  1409         parents = [p for p in other.changelog.parents(n) if p != nullid]
  1404         if opts['no_merges'] and len(parents) == 2:
  1410         if opts['no_merges'] and len(parents) == 2:
  1559     if a push was requested.
  1565     if a push was requested.
  1560     """
  1566     """
  1561     dest = ui.expandpath(dest, repo.root)
  1567     dest = ui.expandpath(dest, repo.root)
  1562     other = hg.repository(ui, dest)
  1568     other = hg.repository(ui, dest)
  1563     o = repo.findoutgoing(other)
  1569     o = repo.findoutgoing(other)
  1564     o = repo.newer(o)
  1570     o = repo.changelog.nodesbetween(o)[0]
  1565     if opts['newest_first']:
  1571     if opts['newest_first']:
  1566         o.reverse()
  1572         o.reverse()
  1567     for n in o:
  1573     for n in o:
  1568         parents = [p for p in repo.changelog.parents(n) if p != nullid]
  1574         parents = [p for p in repo.changelog.parents(n) if p != nullid]
  1569         if opts['no_merges'] and len(parents) == 2:
  1575         if opts['no_merges'] and len(parents) == 2:
  1641         ui.setconfig("ui", "ssh", opts['ssh'])
  1647         ui.setconfig("ui", "ssh", opts['ssh'])
  1642     if opts['remotecmd']:
  1648     if opts['remotecmd']:
  1643         ui.setconfig("ui", "remotecmd", opts['remotecmd'])
  1649         ui.setconfig("ui", "remotecmd", opts['remotecmd'])
  1644 
  1650 
  1645     other = hg.repository(ui, source)
  1651     other = hg.repository(ui, source)
  1646     r = repo.pull(other)
  1652     revs = None
       
  1653     if opts['rev'] and not other.local():
       
  1654         raise util.Abort("pull -r doesn't work for remote repositories yet")
       
  1655     elif opts['rev']:
       
  1656         revs = [other.lookup(rev) for rev in opts['rev']]
       
  1657     r = repo.pull(other, heads=revs)
  1647     if not r:
  1658     if not r:
  1648         if opts['update']:
  1659         if opts['update']:
  1649             return update(ui, repo)
  1660             return update(ui, repo)
  1650         else:
  1661         else:
  1651             ui.status(_("(run 'hg update' to get a working copy)\n"))
  1662             ui.status(_("(run 'hg update' to get a working copy)\n"))
  2191     "^clone":
  2202     "^clone":
  2192         (clone,
  2203         (clone,
  2193          [('U', 'noupdate', None, _('do not update the new working directory')),
  2204          [('U', 'noupdate', None, _('do not update the new working directory')),
  2194           ('e', 'ssh', "", _('specify ssh command to use')),
  2205           ('e', 'ssh', "", _('specify ssh command to use')),
  2195           ('', 'pull', None, _('use pull protocol to copy metadata')),
  2206           ('', 'pull', None, _('use pull protocol to copy metadata')),
       
  2207           ('r', 'rev', [], _('a changeset you would like to have after cloning')),
  2196           ('', 'remotecmd', "", _('specify hg command to run on the remote side'))],
  2208           ('', 'remotecmd', "", _('specify hg command to run on the remote side'))],
  2197          _('hg clone [OPTION]... SOURCE [DEST]')),
  2209          _('hg clone [OPTION]... SOURCE [DEST]')),
  2198     "^commit|ci":
  2210     "^commit|ci":
  2199         (commit,
  2211         (commit,
  2200          [('A', 'addremove', None, _('run addremove during commit')),
  2212          [('A', 'addremove', None, _('run addremove during commit')),
  2302     "paths": (paths, [], _('hg paths [NAME]')),
  2314     "paths": (paths, [], _('hg paths [NAME]')),
  2303     "^pull":
  2315     "^pull":
  2304         (pull,
  2316         (pull,
  2305          [('u', 'update', None, _('update the working directory to tip after pull')),
  2317          [('u', 'update', None, _('update the working directory to tip after pull')),
  2306           ('e', 'ssh', "", _('specify ssh command to use')),
  2318           ('e', 'ssh', "", _('specify ssh command to use')),
       
  2319           ('r', 'rev', [], _('a specific revision you would like to pull')),
  2307           ('', 'remotecmd', "", _('specify hg command to run on the remote side'))],
  2320           ('', 'remotecmd', "", _('specify hg command to run on the remote side'))],
  2308          _('hg pull [-u] [-e FILE] [--remotecmd FILE] [SOURCE]')),
  2321          _('hg pull [-u] [-e FILE] [-r rev] [--remotecmd FILE] [SOURCE]')),
  2309     "^push":
  2322     "^push":
  2310         (push,
  2323         (push,
  2311          [('f', 'force', None, _('force push')),
  2324          [('f', 'force', None, _('force push')),
  2312           ('e', 'ssh', "", _('specify ssh command to use')),
  2325           ('e', 'ssh', "", _('specify ssh command to use')),
  2313           ('', 'remotecmd', "", _('specify hg command to run on the remote side'))],
  2326           ('', 'remotecmd', "", _('specify hg command to run on the remote side'))],