mercurial/hg.py
changeset 12273 e392d00ab5b0
parent 12271 01dc8ba3e032
child 12314 f2daa6ab514a
equal deleted inserted replaced
12272:42ecd56399d7 12273:e392d00ab5b0
     9 from i18n import _
     9 from i18n import _
    10 from lock import release
    10 from lock import release
    11 from node import hex, nullid, nullrev, short
    11 from node import hex, nullid, nullrev, short
    12 import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo
    12 import localrepo, bundlerepo, httprepo, sshrepo, statichttprepo
    13 import lock, util, extensions, error, encoding, node
    13 import lock, util, extensions, error, encoding, node
    14 import cmdutil, discovery, url
    14 import cmdutil, discovery, url, changegroup
    15 import merge as mergemod
    15 import merge as mergemod
    16 import verify as verifymod
    16 import verify as verifymod
    17 import errno, os, shutil
    17 import errno, os, shutil
    18 
    18 
    19 def _local(path):
    19 def _local(path):
   405         repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
   405         repo.ui.status(_("use 'hg resolve' to retry unresolved file merges "
   406                          "or 'hg update -C' to abandon\n"))
   406                          "or 'hg update -C' to abandon\n"))
   407     elif remind:
   407     elif remind:
   408         repo.ui.status(_("(branch merge, don't forget to commit)\n"))
   408         repo.ui.status(_("(branch merge, don't forget to commit)\n"))
   409     return stats[3] > 0
   409     return stats[3] > 0
       
   410 
       
   411 def incoming(ui, repo, source, opts):
       
   412     limit = cmdutil.loglimit(opts)
       
   413     source, branches = parseurl(ui.expandpath(source), opts.get('branch'))
       
   414     other = repository(remoteui(repo, opts), source)
       
   415     ui.status(_('comparing with %s\n') % url.hidepassword(source))
       
   416     revs, checkout = addbranchrevs(repo, other, branches, opts.get('rev'))
       
   417     if revs:
       
   418         revs = [other.lookup(rev) for rev in revs]
       
   419 
       
   420     tmp = discovery.findcommonincoming(repo, other, heads=revs,
       
   421                                        force=opts.get('force'))
       
   422     common, incoming, rheads = tmp
       
   423     if not incoming:
       
   424         try:
       
   425             os.unlink(opts["bundle"])
       
   426         except:
       
   427             pass
       
   428         ui.status(_("no changes found\n"))
       
   429         return 1
       
   430 
       
   431     cleanup = None
       
   432     try:
       
   433         fname = opts["bundle"]
       
   434         if fname or not other.local():
       
   435             # create a bundle (uncompressed if other repo is not local)
       
   436 
       
   437             if revs is None and other.capable('changegroupsubset'):
       
   438                 revs = rheads
       
   439 
       
   440             if revs is None:
       
   441                 cg = other.changegroup(incoming, "incoming")
       
   442             else:
       
   443                 cg = other.changegroupsubset(incoming, revs, 'incoming')
       
   444             bundletype = other.local() and "HG10BZ" or "HG10UN"
       
   445             fname = cleanup = changegroup.writebundle(cg, fname, bundletype)
       
   446             # keep written bundle?
       
   447             if opts["bundle"]:
       
   448                 cleanup = None
       
   449             if not other.local():
       
   450                 # use the created uncompressed bundlerepo
       
   451                 other = bundlerepo.bundlerepository(ui, repo.root, fname)
       
   452 
       
   453         o = other.changelog.nodesbetween(incoming, revs)[0]
       
   454         if opts.get('newest_first'):
       
   455             o.reverse()
       
   456         displayer = cmdutil.show_changeset(ui, other, opts)
       
   457         count = 0
       
   458         for n in o:
       
   459             if limit is not None and count >= limit:
       
   460                 break
       
   461             parents = [p for p in other.changelog.parents(n) if p != nullid]
       
   462             if opts.get('no_merges') and len(parents) == 2:
       
   463                 continue
       
   464             count += 1
       
   465             displayer.show(other[n])
       
   466         displayer.close()
       
   467     finally:
       
   468         if hasattr(other, 'close'):
       
   469             other.close()
       
   470         if cleanup:
       
   471             os.unlink(cleanup)
   410 
   472 
   411 def outgoing(ui, repo, dest, opts):
   473 def outgoing(ui, repo, dest, opts):
   412     limit = cmdutil.loglimit(opts)
   474     limit = cmdutil.loglimit(opts)
   413     dest = ui.expandpath(dest or 'default-push', dest or 'default')
   475     dest = ui.expandpath(dest or 'default-push', dest or 'default')
   414     dest, branches = parseurl(dest, opts.get('branch'))
   476     dest, branches = parseurl(dest, opts.get('branch'))