mercurial/commands.py
changeset 4450 8fa54b9c6c5a
parent 4442 af8db3b42a4a
child 4474 08ae451148b2
child 4484 c927c568a5ad
equal deleted inserted replaced
4449:7eb604da8764 4450:8fa54b9c6c5a
   180         if not prefix: prefix = os.path.basename(repo.root) + '-%h'
   180         if not prefix: prefix = os.path.basename(repo.root) + '-%h'
   181     prefix = cmdutil.make_filename(repo, prefix, node)
   181     prefix = cmdutil.make_filename(repo, prefix, node)
   182     archival.archive(repo, dest, node, kind, not opts['no_decode'],
   182     archival.archive(repo, dest, node, kind, not opts['no_decode'],
   183                      matchfn, prefix)
   183                      matchfn, prefix)
   184 
   184 
   185 def backout(ui, repo, rev, **opts):
   185 def backout(ui, repo, node=None, rev=None, **opts):
   186     '''reverse effect of earlier changeset
   186     '''reverse effect of earlier changeset
   187 
   187 
   188     Commit the backed out changes as a new changeset.  The new
   188     Commit the backed out changes as a new changeset.  The new
   189     changeset is a child of the backed out changeset.
   189     changeset is a child of the backed out changeset.
   190 
   190 
   197     The --merge option remembers the parent of the working directory
   197     The --merge option remembers the parent of the working directory
   198     before starting the backout, then merges the new head with that
   198     before starting the backout, then merges the new head with that
   199     changeset afterwards.  This saves you from doing the merge by
   199     changeset afterwards.  This saves you from doing the merge by
   200     hand.  The result of this merge is not committed, as for a normal
   200     hand.  The result of this merge is not committed, as for a normal
   201     merge.'''
   201     merge.'''
       
   202     if rev and node:
       
   203         raise util.Abort(_("please specify just one revision"))
       
   204 
       
   205     if not rev:
       
   206         rev = node
   202 
   207 
   203     bail_if_changed(repo)
   208     bail_if_changed(repo)
   204     op1, op2 = repo.dirstate.parents()
   209     op1, op2 = repo.dirstate.parents()
   205     if op2 != nullid:
   210     if op2 != nullid:
   206         raise util.Abort(_('outstanding uncommitted merge'))
   211         raise util.Abort(_('outstanding uncommitted merge'))
  1830             ui.write("%40s " % hex(m[f]))
  1835             ui.write("%40s " % hex(m[f]))
  1831         if ui.verbose:
  1836         if ui.verbose:
  1832             ui.write("%3s " % (m.execf(f) and "755" or "644"))
  1837             ui.write("%3s " % (m.execf(f) and "755" or "644"))
  1833         ui.write("%s\n" % f)
  1838         ui.write("%s\n" % f)
  1834 
  1839 
  1835 def merge(ui, repo, node=None, force=None):
  1840 def merge(ui, repo, node=None, force=None, rev=None):
  1836     """merge working directory with another revision
  1841     """merge working directory with another revision
  1837 
  1842 
  1838     Merge the contents of the current working directory and the
  1843     Merge the contents of the current working directory and the
  1839     requested revision. Files that changed between either parent are
  1844     requested revision. Files that changed between either parent are
  1840     marked as changed for the next commit and a commit must be
  1845     marked as changed for the next commit and a commit must be
  1843     If no revision is specified, the working directory's parent is a
  1848     If no revision is specified, the working directory's parent is a
  1844     head revision, and the repository contains exactly one other head,
  1849     head revision, and the repository contains exactly one other head,
  1845     the other head is merged with by default.  Otherwise, an explicit
  1850     the other head is merged with by default.  Otherwise, an explicit
  1846     revision to merge with must be provided.
  1851     revision to merge with must be provided.
  1847     """
  1852     """
       
  1853 
       
  1854     if rev and node:
       
  1855         raise util.Abort(_("please specify just one revision"))
       
  1856 
       
  1857     if not node:
       
  1858         node = rev
  1848 
  1859 
  1849     if not node:
  1860     if not node:
  1850         heads = repo.heads()
  1861         heads = repo.heads()
  1851         if len(heads) > 2:
  1862         if len(heads) > 2:
  1852             raise util.Abort(_('repo has %d heads - '
  1863             raise util.Abort(_('repo has %d heads - '
  2556         f = urllib.urlopen(fname)
  2567         f = urllib.urlopen(fname)
  2557     gen = changegroup.readbundle(f, fname)
  2568     gen = changegroup.readbundle(f, fname)
  2558     modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
  2569     modheads = repo.addchangegroup(gen, 'unbundle', 'bundle:' + fname)
  2559     return postincoming(ui, repo, modheads, opts['update'])
  2570     return postincoming(ui, repo, modheads, opts['update'])
  2560 
  2571 
  2561 def update(ui, repo, node=None, clean=False, date=None):
  2572 def update(ui, repo, node=None, rev=None, clean=False, date=None):
  2562     """update working directory
  2573     """update working directory
  2563 
  2574 
  2564     Update the working directory to the specified revision, or the
  2575     Update the working directory to the specified revision, or the
  2565     tip of the current branch if none is specified.
  2576     tip of the current branch if none is specified.
  2566 
  2577 
  2572     merge command.
  2583     merge command.
  2573 
  2584 
  2574     By default, update will refuse to run if doing so would require
  2585     By default, update will refuse to run if doing so would require
  2575     discarding local changes.
  2586     discarding local changes.
  2576     """
  2587     """
       
  2588     if rev and node:
       
  2589         raise util.Abort(_("please specify just one revision"))
       
  2590 
       
  2591     if not rev:
       
  2592         rev = node
       
  2593 
  2577     if date:
  2594     if date:
  2578         if node:
  2595         if rev:
  2579             raise util.Abort(_("you can't specify a revision and a date"))
  2596             raise util.Abort(_("you can't specify a revision and a date"))
  2580         node = cmdutil.finddate(ui, repo, date)
  2597         rev = cmdutil.finddate(ui, repo, date)
  2581 
  2598 
  2582     if clean:
  2599     if clean:
  2583         return hg.clean(repo, node)
  2600         return hg.clean(repo, rev)
  2584     else:
  2601     else:
  2585         return hg.update(repo, node)
  2602         return hg.update(repo, rev)
  2586 
  2603 
  2587 def verify(ui, repo):
  2604 def verify(ui, repo):
  2588     """verify the integrity of the repository
  2605     """verify the integrity of the repository
  2589 
  2606 
  2590     Verify the integrity of the current repository.
  2607     Verify the integrity of the current repository.
  2680          [('', 'merge', None,
  2697          [('', 'merge', None,
  2681            _('merge with old dirstate parent after backout')),
  2698            _('merge with old dirstate parent after backout')),
  2682           ('d', 'date', '', _('record datecode as commit date')),
  2699           ('d', 'date', '', _('record datecode as commit date')),
  2683           ('', 'parent', '', _('parent to choose when backing out merge')),
  2700           ('', 'parent', '', _('parent to choose when backing out merge')),
  2684           ('u', 'user', '', _('record user as committer')),
  2701           ('u', 'user', '', _('record user as committer')),
       
  2702           ('r', 'rev', '', _('revision to backout')),
  2685          ] + walkopts + commitopts,
  2703          ] + walkopts + commitopts,
  2686          _('hg backout [OPTION]... REV')),
  2704          _('hg backout [OPTION]... [-r] REV')),
  2687     "branch": (branch,
  2705     "branch": (branch,
  2688                [('f', 'force', None,
  2706                [('f', 'force', None,
  2689                  _('set branch name even if it shadows an existing branch'))],
  2707                  _('set branch name even if it shadows an existing branch'))],
  2690                 _('hg branch [NAME]')),
  2708                 _('hg branch [NAME]')),
  2691     "branches": (branches, [], _('hg branches')),
  2709     "branches": (branches, [], _('hg branches')),
  2856          ] + walkopts,
  2874          ] + walkopts,
  2857          _('hg log [OPTION]... [FILE]')),
  2875          _('hg log [OPTION]... [FILE]')),
  2858     "manifest": (manifest, [], _('hg manifest [REV]')),
  2876     "manifest": (manifest, [], _('hg manifest [REV]')),
  2859     "^merge":
  2877     "^merge":
  2860         (merge,
  2878         (merge,
  2861          [('f', 'force', None, _('force a merge with outstanding changes'))],
  2879          [('f', 'force', None, _('force a merge with outstanding changes')),
  2862          _('hg merge [-f] [REV]')),
  2880           ('r', 'rev', '', _('revision to merge')),
       
  2881              ],
       
  2882          _('hg merge [-f] [[-r] REV]')),
  2863     "outgoing|out": (outgoing,
  2883     "outgoing|out": (outgoing,
  2864          [('M', 'no-merges', None, _('do not show merges')),
  2884          [('M', 'no-merges', None, _('do not show merges')),
  2865           ('f', 'force', None,
  2885           ('f', 'force', None,
  2866            _('run even when remote repository is unrelated')),
  2886            _('run even when remote repository is unrelated')),
  2867           ('p', 'patch', None, _('show patch')),
  2887           ('p', 'patch', None, _('show patch')),
  2988            _('update to new tip if changesets were unbundled'))],
  3008            _('update to new tip if changesets were unbundled'))],
  2989          _('hg unbundle [-u] FILE')),
  3009          _('hg unbundle [-u] FILE')),
  2990     "^update|up|checkout|co":
  3010     "^update|up|checkout|co":
  2991         (update,
  3011         (update,
  2992          [('C', 'clean', None, _('overwrite locally modified files')),
  3012          [('C', 'clean', None, _('overwrite locally modified files')),
  2993           ('d', 'date', '', _('tipmost revision matching date'))],
  3013           ('d', 'date', '', _('tipmost revision matching date')),
  2994          _('hg update [-C] [-d DATE] [REV]')),
  3014           ('r', 'rev', '', _('revision'))],
       
  3015          _('hg update [-C] [-d DATE] [[-r] REV]')),
  2995     "verify": (verify, [], _('hg verify')),
  3016     "verify": (verify, [], _('hg verify')),
  2996     "version": (version_, [], _('hg version')),
  3017     "version": (version_, [], _('hg version')),
  2997 }
  3018 }
  2998 
  3019 
  2999 norepo = ("clone init version help debugancestor debugcomplete debugdata"
  3020 norepo = ("clone init version help debugancestor debugcomplete debugdata"