mercurial/commands.py
changeset 3885 1e0b94cfba0e
parent 3862 46abbed02b2d
child 3886 abaee83ce0a6
equal deleted inserted replaced
3881:c0a12e6441a5 3885:1e0b94cfba0e
   238     ui.status(_('changeset %s backs out changeset %s\n') %
   238     ui.status(_('changeset %s backs out changeset %s\n') %
   239               (nice(repo.changelog.tip()), nice(node)))
   239               (nice(repo.changelog.tip()), nice(node)))
   240     if op1 != node:
   240     if op1 != node:
   241         if opts['merge']:
   241         if opts['merge']:
   242             ui.status(_('merging with changeset %s\n') % nice(op1))
   242             ui.status(_('merging with changeset %s\n') % nice(op1))
   243             n = _lookup(repo, hex(op1))
   243             hg.merge(repo, hex(op1))
   244             hg.merge(repo, n)
       
   245         else:
   244         else:
   246             ui.status(_('the backout changeset is a new head - '
   245             ui.status(_('the backout changeset is a new head - '
   247                         'do not forget to merge\n'))
   246                         'do not forget to merge\n'))
   248             ui.status(_('(use "backout --merge" '
   247             ui.status(_('(use "backout --merge" '
   249                         'if you want to auto-merge)\n'))
   248                         'if you want to auto-merge)\n'))
  1696 
  1695 
  1697     df = False
  1696     df = False
  1698     if opts["date"]:
  1697     if opts["date"]:
  1699         df = util.matchdate(opts["date"])
  1698         df = util.matchdate(opts["date"])
  1700 
  1699 
  1701 
       
  1702     displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn)
  1700     displayer = cmdutil.show_changeset(ui, repo, opts, True, matchfn)
  1703     for st, rev, fns in changeiter:
  1701     for st, rev, fns in changeiter:
  1704         if st == 'add':
  1702         if st == 'add':
  1705             changenode = repo.changelog.node(rev)
  1703             changenode = repo.changelog.node(rev)
  1706             parents = [p for p in repo.changelog.parentrevs(rev)
  1704             parents = [p for p in repo.changelog.parentrevs(rev)
  1761             ui.write("%40s " % hex(m[f]))
  1759             ui.write("%40s " % hex(m[f]))
  1762         if ui.verbose:
  1760         if ui.verbose:
  1763             ui.write("%3s " % (m.execf(f) and "755" or "644"))
  1761             ui.write("%3s " % (m.execf(f) and "755" or "644"))
  1764         ui.write("%s\n" % f)
  1762         ui.write("%s\n" % f)
  1765 
  1763 
  1766 def merge(ui, repo, node=None, force=None, branch=None):
  1764 def merge(ui, repo, node=None, force=None):
  1767     """Merge working directory with another revision
  1765     """Merge working directory with another revision
  1768 
  1766 
  1769     Merge the contents of the current working directory and the
  1767     Merge the contents of the current working directory and the
  1770     requested revision. Files that changed between either parent are
  1768     requested revision. Files that changed between either parent are
  1771     marked as changed for the next commit and a commit must be
  1769     marked as changed for the next commit and a commit must be
  1775     head revision, and the repository contains exactly one other head,
  1773     head revision, and the repository contains exactly one other head,
  1776     the other head is merged with by default.  Otherwise, an explicit
  1774     the other head is merged with by default.  Otherwise, an explicit
  1777     revision to merge with must be provided.
  1775     revision to merge with must be provided.
  1778     """
  1776     """
  1779 
  1777 
  1780     if node or branch:
  1778     if not node:
  1781         node = _lookup(repo, node, branch)
       
  1782     else:
       
  1783         heads = repo.heads()
  1779         heads = repo.heads()
  1784         if len(heads) > 2:
  1780         if len(heads) > 2:
  1785             raise util.Abort(_('repo has %d heads - '
  1781             raise util.Abort(_('repo has %d heads - '
  1786                                'please merge with an explicit rev') %
  1782                                'please merge with an explicit rev') %
  1787                              len(heads))
  1783                              len(heads))
  2476     """
  2472     """
  2477     gen = changegroup.readbundle(urllib.urlopen(fname), fname)
  2473     gen = changegroup.readbundle(urllib.urlopen(fname), fname)
  2478     modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
  2474     modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
  2479     return postincoming(ui, repo, modheads, opts['update'])
  2475     return postincoming(ui, repo, modheads, opts['update'])
  2480 
  2476 
  2481 def update(ui, repo, node=None, clean=False, branch=None, date=None):
  2477 def update(ui, repo, node=None, clean=False, date=None):
  2482     """update or merge working directory
  2478     """update or merge working directory
  2483 
  2479 
  2484     Update the working directory to the specified revision.
  2480     Update the working directory to the specified revision.
  2485 
  2481 
  2486     If there are no outstanding changes in the working directory and
  2482     If there are no outstanding changes in the working directory and
  2496     if date:
  2492     if date:
  2497         if node:
  2493         if node:
  2498             raise util.Abort(_("you can't specify a revision and a date"))
  2494             raise util.Abort(_("you can't specify a revision and a date"))
  2499         node = cmdutil.finddate(ui, repo, date)
  2495         node = cmdutil.finddate(ui, repo, date)
  2500 
  2496 
  2501     node = _lookup(repo, node, branch)
       
  2502     if clean:
  2497     if clean:
  2503         return hg.clean(repo, node)
  2498         return hg.clean(repo, node)
  2504     else:
  2499     else:
  2505         return hg.update(repo, node)
  2500         return hg.update(repo, node)
  2506 
       
  2507 def _lookup(repo, node, branch=None):
       
  2508     if branch:
       
  2509         repo.ui.warn(_("the --branch option is deprecated, "
       
  2510                        "please use 'hg branch' instead\n"))
       
  2511         br = repo.branchlookup(branch=branch)
       
  2512         found = []
       
  2513         for x in br:
       
  2514             if branch in br[x]:
       
  2515                 found.append(x)
       
  2516         if len(found) > 1:
       
  2517             repo.ui.warn(_("Found multiple heads for %s\n") % branch)
       
  2518             for x in found:
       
  2519                 cmdutil.show_changeset(ui, repo, {}).show(changenode=x)
       
  2520             raise util.Abort("")
       
  2521         if len(found) == 1:
       
  2522             node = found[0]
       
  2523             repo.ui.warn(_("Using head %s for branch %s\n")
       
  2524                          % (short(node), branch))
       
  2525         else:
       
  2526             raise util.Abort(_("branch %s not found") % branch)
       
  2527     else:
       
  2528         node = node and repo.lookup(node) or repo.changelog.tip()
       
  2529     return node
       
  2530 
  2501 
  2531 def verify(ui, repo):
  2502 def verify(ui, repo):
  2532     """verify the integrity of the repository
  2503     """verify the integrity of the repository
  2533 
  2504 
  2534     Verify the integrity of the current repository.
  2505     Verify the integrity of the current repository.
  2731           ('u', 'user', None, _('print user who committed change')),
  2702           ('u', 'user', None, _('print user who committed change')),
  2732          ] + walkopts,
  2703          ] + walkopts,
  2733          _('hg grep [OPTION]... PATTERN [FILE]...')),
  2704          _('hg grep [OPTION]... PATTERN [FILE]...')),
  2734     "heads":
  2705     "heads":
  2735         (heads,
  2706         (heads,
  2736          [('b', 'branches', None, _('show branches (DEPRECATED)')),
  2707          [('', 'style', '', _('display using template map file')),
  2737           ('', 'style', '', _('display using template map file')),
       
  2738           ('r', 'rev', '', _('show only heads which are descendants of rev')),
  2708           ('r', 'rev', '', _('show only heads which are descendants of rev')),
  2739           ('', 'template', '', _('display with template'))],
  2709           ('', 'template', '', _('display with template'))],
  2740          _('hg heads [-r REV]')),
  2710          _('hg heads [-r REV]')),
  2741     "help": (help_, [], _('hg help [COMMAND]')),
  2711     "help": (help_, [], _('hg help [COMMAND]')),
  2742     "identify|id": (identify, [], _('hg identify')),
  2712     "identify|id": (identify, [], _('hg identify')),
  2743     "import|patch":
  2713     "import|patch":
  2744         (import_,
  2714         (import_,
  2745          [('p', 'strip', 1,
  2715          [('p', 'strip', 1,
  2746            _('directory strip option for patch. This has the same\n'
  2716            _('directory strip option for patch. This has the same\n'
  2747              'meaning as the corresponding patch option')),
  2717              'meaning as the corresponding patch option')),
  2748           ('b', 'base', '', _('base path (DEPRECATED)')),
  2718           ('b', 'base', '', _('base path')),
  2749           ('f', 'force', None,
  2719           ('f', 'force', None,
  2750            _('skip check for outstanding uncommitted changes'))] + commitopts,
  2720            _('skip check for outstanding uncommitted changes'))] + commitopts,
  2751          _('hg import [-p NUM] [-m MESSAGE] [-f] PATCH...')),
  2721          _('hg import [-p NUM] [-m MESSAGE] [-f] PATCH...')),
  2752     "incoming|in": (incoming,
  2722     "incoming|in": (incoming,
  2753          [('M', 'no-merges', None, _('do not show merges')),
  2723          [('M', 'no-merges', None, _('do not show merges')),
  2773            _('print complete paths from the filesystem root')),
  2743            _('print complete paths from the filesystem root')),
  2774          ] + walkopts,
  2744          ] + walkopts,
  2775          _('hg locate [OPTION]... [PATTERN]...')),
  2745          _('hg locate [OPTION]... [PATTERN]...')),
  2776     "^log|history":
  2746     "^log|history":
  2777         (log,
  2747         (log,
  2778          [('b', 'branches', None, _('show branches (DEPRECATED)')),
  2748          [('f', 'follow', None,
  2779           ('f', 'follow', None,
       
  2780            _('follow changeset history, or file history across copies and renames')),
  2749            _('follow changeset history, or file history across copies and renames')),
  2781           ('', 'follow-first', None,
  2750           ('', 'follow-first', None,
  2782            _('only follow the first parent of merge changesets')),
  2751            _('only follow the first parent of merge changesets')),
  2783           ('d', 'date', '', _('show revs matching date spec')),
  2752           ('d', 'date', '', _('show revs matching date spec')),
  2784           ('C', 'copies', None, _('show copied files')),
  2753           ('C', 'copies', None, _('show copied files')),
  2795          ] + walkopts,
  2764          ] + walkopts,
  2796          _('hg log [OPTION]... [FILE]')),
  2765          _('hg log [OPTION]... [FILE]')),
  2797     "manifest": (manifest, [], _('hg manifest [REV]')),
  2766     "manifest": (manifest, [], _('hg manifest [REV]')),
  2798     "merge":
  2767     "merge":
  2799         (merge,
  2768         (merge,
  2800          [('b', 'branch', '', _('merge with head of a specific branch (DEPRECATED)')),
  2769          [('f', 'force', None, _('force a merge with outstanding changes'))],
  2801           ('f', 'force', None, _('force a merge with outstanding changes'))],
       
  2802          _('hg merge [-f] [REV]')),
  2770          _('hg merge [-f] [REV]')),
  2803     "outgoing|out": (outgoing,
  2771     "outgoing|out": (outgoing,
  2804          [('M', 'no-merges', None, _('do not show merges')),
  2772          [('M', 'no-merges', None, _('do not show merges')),
  2805           ('f', 'force', None,
  2773           ('f', 'force', None,
  2806            _('run even when remote repository is unrelated')),
  2774            _('run even when remote repository is unrelated')),
  2811           ('', 'template', '', _('display with template')),
  2779           ('', 'template', '', _('display with template')),
  2812          ] + remoteopts,
  2780          ] + remoteopts,
  2813          _('hg outgoing [-M] [-p] [-n] [-r REV]... [DEST]')),
  2781          _('hg outgoing [-M] [-p] [-n] [-r REV]... [DEST]')),
  2814     "^parents":
  2782     "^parents":
  2815         (parents,
  2783         (parents,
  2816          [('b', 'branches', None, _('show branches (DEPRECATED)')),
  2784          [('r', 'rev', '', _('show parents from the specified rev')),
  2817           ('r', 'rev', '', _('show parents from the specified rev')),
       
  2818           ('', 'style', '', _('display using template map file')),
  2785           ('', 'style', '', _('display using template map file')),
  2819           ('', 'template', '', _('display with template'))],
  2786           ('', 'template', '', _('display with template'))],
  2820          _('hg parents [-r REV] [FILE]')),
  2787          _('hg parents [-r REV] [FILE]')),
  2821     "paths": (paths, [], _('hg paths [NAME]')),
  2788     "paths": (paths, [], _('hg paths [NAME]')),
  2822     "^pull":
  2789     "^pull":
  2914           ('r', 'rev', '', _('revision to tag'))],
  2881           ('r', 'rev', '', _('revision to tag'))],
  2915          _('hg tag [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME')),
  2882          _('hg tag [-l] [-m TEXT] [-d DATE] [-u USER] [-r REV] NAME')),
  2916     "tags": (tags, [], _('hg tags')),
  2883     "tags": (tags, [], _('hg tags')),
  2917     "tip":
  2884     "tip":
  2918         (tip,
  2885         (tip,
  2919          [('b', 'branches', None, _('show branches (DEPRECATED)')),
  2886          [('', 'style', '', _('display using template map file')),
  2920           ('', 'style', '', _('display using template map file')),
       
  2921           ('p', 'patch', None, _('show patch')),
  2887           ('p', 'patch', None, _('show patch')),
  2922           ('', 'template', '', _('display with template'))],
  2888           ('', 'template', '', _('display with template'))],
  2923          _('hg tip [-p]')),
  2889          _('hg tip [-p]')),
  2924     "unbundle":
  2890     "unbundle":
  2925         (unbundle,
  2891         (unbundle,
  2926          [('u', 'update', None,
  2892          [('u', 'update', None,
  2927            _('update to new tip if changesets were unbundled'))],
  2893            _('update to new tip if changesets were unbundled'))],
  2928          _('hg unbundle [-u] FILE')),
  2894          _('hg unbundle [-u] FILE')),
  2929     "^update|up|checkout|co":
  2895     "^update|up|checkout|co":
  2930         (update,
  2896         (update,
  2931          [('b', 'branch', '',
  2897          [('C', 'clean', None, _('overwrite locally modified files')),
  2932            _('checkout the head of a specific branch (DEPRECATED)')),
       
  2933           ('C', 'clean', None, _('overwrite locally modified files')),
       
  2934           ('d', 'date', '', _('tipmost revision matching date'))],
  2898           ('d', 'date', '', _('tipmost revision matching date'))],
  2935          _('hg update [-C] [REV]')),
  2899          _('hg update [-C] [REV]')),
  2936     "verify": (verify, [], _('hg verify')),
  2900     "verify": (verify, [], _('hg verify')),
  2937     "version": (version_, [], _('hg version')),
  2901     "version": (version_, [], _('hg version')),
  2938 }
  2902 }