mercurial/commands.py
changeset 2019 ced2d3620f95
parent 1996 4c70b10f0418
child 2020 00925397236c
equal deleted inserted replaced
2015:1a09814a5b1f 2019:ced2d3620f95
  1996     files.sort()
  1996     files.sort()
  1997 
  1997 
  1998     for f in files:
  1998     for f in files:
  1999         ui.write("%40s %3s %s\n" % (hex(m[f]), mf[f] and "755" or "644", f))
  1999         ui.write("%40s %3s %s\n" % (hex(m[f]), mf[f] and "755" or "644", f))
  2000 
  2000 
       
  2001 def merge(ui, repo, node=None, **opts):
       
  2002     """Merge working directory with another revision
       
  2003 
       
  2004     Merge the contents of the current working directory and the
       
  2005     requested revision. Files that changed between either parent are
       
  2006     marked as changed for the next commit and a commit must be
       
  2007     performed before any further updates are allowed.
       
  2008     """
       
  2009     return update(ui, repo, node=node, merge=True, **opts)
       
  2010     
  2001 def outgoing(ui, repo, dest="default-push", **opts):
  2011 def outgoing(ui, repo, dest="default-push", **opts):
  2002     """show changesets not found in destination
  2012     """show changesets not found in destination
  2003 
  2013 
  2004     Show changesets not found in the specified destination repository or
  2014     Show changesets not found in the specified destination repository or
  2005     the default push location. These are the changesets that would be pushed
  2015     the default push location. These are the changesets that would be pushed
  2068         return 1
  2078         return 1
  2069     else:
  2079     else:
  2070         for name, path in ui.configitems("paths"):
  2080         for name, path in ui.configitems("paths"):
  2071             ui.write("%s = %s\n" % (name, path))
  2081             ui.write("%s = %s\n" % (name, path))
  2072 
  2082 
       
  2083 def postincoming(ui, repo, modheads, optupdate):
       
  2084     if modheads == 0:
       
  2085         return
       
  2086     if optupdate:
       
  2087         if modheads == 1:
       
  2088             return update(ui, repo)
       
  2089         else:
       
  2090             ui.status(_("not updating, since new heads added\n"))
       
  2091     if modheads > 1:
       
  2092         ui.status(_("(run 'hg heads' to see heads, 'hg merge' to merge)\n"))
       
  2093     else:
       
  2094         ui.status(_("(run 'hg update' to get a working copy)\n"))
       
  2095     
  2073 def pull(ui, repo, source="default", **opts):
  2096 def pull(ui, repo, source="default", **opts):
  2074     """pull changes from the specified source
  2097     """pull changes from the specified source
  2075 
  2098 
  2076     Pull changes from a remote repository to a local one.
  2099     Pull changes from a remote repository to a local one.
  2077 
  2100 
  2112     revs = None
  2135     revs = None
  2113     if opts['rev'] and not other.local():
  2136     if opts['rev'] and not other.local():
  2114         raise util.Abort(_("pull -r doesn't work for remote repositories yet"))
  2137         raise util.Abort(_("pull -r doesn't work for remote repositories yet"))
  2115     elif opts['rev']:
  2138     elif opts['rev']:
  2116         revs = [other.lookup(rev) for rev in opts['rev']]
  2139         revs = [other.lookup(rev) for rev in opts['rev']]
  2117     r = repo.pull(other, heads=revs, force=opts['force'])
  2140     modheads = repo.pull(other, heads=revs, force=opts['force'])
  2118     if not r:
  2141     return postincoming(ui, repo, modheads, opts['update'])
  2119         if opts['update']:
       
  2120             return update(ui, repo)
       
  2121         else:
       
  2122             ui.status(_("(run 'hg update' to get a working copy)\n"))
       
  2123 
       
  2124     return r
       
  2125 
  2142 
  2126 def push(ui, repo, dest="default-push", **opts):
  2143 def push(ui, repo, dest="default-push", **opts):
  2127     """push changes to the specified destination
  2144     """push changes to the specified destination
  2128 
  2145 
  2129     Push changes from the local repository to the given destination.
  2146     Push changes from the local repository to the given destination.
  2156     other = hg.repository(ui, dest)
  2173     other = hg.repository(ui, dest)
  2157     revs = None
  2174     revs = None
  2158     if opts['rev']:
  2175     if opts['rev']:
  2159         revs = [repo.lookup(rev) for rev in opts['rev']]
  2176         revs = [repo.lookup(rev) for rev in opts['rev']]
  2160     r = repo.push(other, opts['force'], revs=revs)
  2177     r = repo.push(other, opts['force'], revs=revs)
  2161     return r
  2178     return r == 0
  2162 
  2179 
  2163 def rawcommit(ui, repo, *flist, **rc):
  2180 def rawcommit(ui, repo, *flist, **rc):
  2164     """raw commit interface (DEPRECATED)
  2181     """raw commit interface (DEPRECATED)
  2165 
  2182 
  2166     (DEPRECATED)
  2183     (DEPRECATED)
  2385                     respond("not locked")
  2402                     respond("not locked")
  2386                     continue
  2403                     continue
  2387                 respond("")
  2404                 respond("")
  2388 
  2405 
  2389                 r = repo.addchangegroup(fin)
  2406                 r = repo.addchangegroup(fin)
  2390                 respond("")
  2407                 respond(str(r))
  2391 
  2408 
  2392     optlist = "name templates style address port ipv6 accesslog errorlog"
  2409     optlist = "name templates style address port ipv6 accesslog errorlog"
  2393     for o in optlist.split():
  2410     for o in optlist.split():
  2394         if opts[o]:
  2411         if opts[o]:
  2395             ui.setconfig("web", o, opts[o])
  2412             ui.setconfig("web", o, opts[o])
  2597                 yield chunk
  2614                 yield chunk
  2598     else:
  2615     else:
  2599         raise util.Abort(_("%s: unknown bundle compression type")
  2616         raise util.Abort(_("%s: unknown bundle compression type")
  2600                          % fname)
  2617                          % fname)
  2601     gen = generator(util.filechunkiter(f, 4096))
  2618     gen = generator(util.filechunkiter(f, 4096))
  2602     if repo.addchangegroup(util.chunkbuffer(gen)):
  2619     modheads = repo.addchangegroup(util.chunkbuffer(gen))
  2603         return 1
  2620     return postincoming(ui, repo, modheads, opts['update'])
  2604 
       
  2605     if opts['update']:
       
  2606         return update(ui, repo)
       
  2607     else:
       
  2608         ui.status(_("(run 'hg update' to get a working copy)\n"))
       
  2609 
  2621 
  2610 def undo(ui, repo):
  2622 def undo(ui, repo):
  2611     """undo the last commit or pull
  2623     """undo the last commit or pull
  2612 
  2624 
  2613     Roll back the last pull or commit transaction on the
  2625     Roll back the last pull or commit transaction on the
  2847           ('', 'template', '', _('display with template')),
  2859           ('', 'template', '', _('display with template')),
  2848           ('I', 'include', [], _('include names matching the given patterns')),
  2860           ('I', 'include', [], _('include names matching the given patterns')),
  2849           ('X', 'exclude', [], _('exclude names matching the given patterns'))],
  2861           ('X', 'exclude', [], _('exclude names matching the given patterns'))],
  2850          _('hg log [OPTION]... [FILE]')),
  2862          _('hg log [OPTION]... [FILE]')),
  2851     "manifest": (manifest, [], _('hg manifest [REV]')),
  2863     "manifest": (manifest, [], _('hg manifest [REV]')),
       
  2864     "merge":
       
  2865     (merge,
       
  2866      [('b', 'branch', '', _('merge with head of a specific branch')),
       
  2867       ('', 'style', '', _('display using template map file')),
       
  2868       ('f', 'force', None, _('force a merge with outstanding changes')),
       
  2869       ('', 'template', '', _('display with template'))],
       
  2870      _('hg merge [-b TAG] [-f] [REV]')),
  2852     "outgoing|out": (outgoing,
  2871     "outgoing|out": (outgoing,
  2853          [('M', 'no-merges', None, _('do not show merges')),
  2872          [('M', 'no-merges', None, _('do not show merges')),
  2854           ('f', 'force', None,
  2873           ('f', 'force', None,
  2855            _('run even when remote repository is unrelated')),
  2874            _('run even when remote repository is unrelated')),
  2856           ('p', 'patch', None, _('show patch')),
  2875           ('p', 'patch', None, _('show patch')),