mercurial/commands.py
changeset 9718 fe1b19bfe75b
parent 9714 2f1ab7f77ddc
child 9725 3f522d2fa633
equal deleted inserted replaced
9717:68a1b9d0663e 9718:fe1b19bfe75b
  3135 
  3135 
  3136 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False):
  3136 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False):
  3137     """update working directory
  3137     """update working directory
  3138 
  3138 
  3139     Update the repository's working directory to the specified
  3139     Update the repository's working directory to the specified
  3140     revision, or the tip of the current branch if none is specified.
  3140     changeset.
  3141     Use null as the revision to remove the working copy (like 'hg
  3141 
       
  3142     If no changeset is specified, attempt to update to the head of the
       
  3143     current branch. If this head is a descendant of the working
       
  3144     directory's parent, update to it, otherwise abort.
       
  3145 
       
  3146     The following rules apply when the working directory contains
       
  3147     uncommitted changes:
       
  3148 
       
  3149     1. If neither -c/--check nor -C/--clean is specified, uncommitted
       
  3150     changes are merged into the requested changeset, and the merged result
       
  3151     is left uncommitted. Updating and merging will occur only if the
       
  3152     requested changeset is an ancestor or descendant of the parent
       
  3153     changeset. Otherwise, the update is aborted and the uncommitted changes
       
  3154     are preserved.
       
  3155 
       
  3156     2. With the -c/--check option, the update is aborted and the
       
  3157     uncommitted changes are preserved.
       
  3158 
       
  3159     3. With the -C/--clean option, uncommitted changes are discarded and
       
  3160     the working directory is updated to the requested changeset.
       
  3161 
       
  3162     Use null as the changeset to remove the working directory (like 'hg
  3142     clone -U').
  3163     clone -U').
  3143 
  3164 
  3144     When the working directory contains no uncommitted changes, it
  3165     If you want to update just one file to an older changeset, use 'hg revert'.
  3145     will be replaced by the state of the requested revision from the
       
  3146     repository. When the requested revision is on a different branch,
       
  3147     the working directory will additionally be switched to that
       
  3148     branch.
       
  3149 
       
  3150     When there are uncommitted changes, use option -C/--clean to
       
  3151     discard them, forcibly replacing the state of the working
       
  3152     directory with the requested revision. Alternately, use -c/--check
       
  3153     to abort.
       
  3154 
       
  3155     When there are uncommitted changes and option -C/--clean is not
       
  3156     used, and the parent revision and requested revision are on the
       
  3157     same branch, and one of them is an ancestor of the other, then the
       
  3158     new working directory will contain the requested revision merged
       
  3159     with the uncommitted changes. Otherwise, the update will fail with
       
  3160     a suggestion to use 'merge' or 'update -C' instead.
       
  3161 
       
  3162     If you want to update just one file to an older revision, use
       
  3163     revert.
       
  3164 
  3166 
  3165     See 'hg help dates' for a list of formats valid for -d/--date.
  3167     See 'hg help dates' for a list of formats valid for -d/--date.
  3166     """
  3168     """
  3167     if rev and node:
  3169     if rev and node:
  3168         raise util.Abort(_("please specify just one revision"))
  3170         raise util.Abort(_("please specify just one revision"))
  3680          [('u', 'update', None,
  3682          [('u', 'update', None,
  3681            _('update to new tip if changesets were unbundled'))],
  3683            _('update to new tip if changesets were unbundled'))],
  3682          _('[-u] FILE...')),
  3684          _('[-u] FILE...')),
  3683     "^update|up|checkout|co":
  3685     "^update|up|checkout|co":
  3684         (update,
  3686         (update,
  3685          [('C', 'clean', None, _('overwrite locally modified files (no backup)')),
  3687          [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
  3686           ('c', 'check', None, _('check for uncommitted changes')),
  3688           ('c', 'check', None, _('check for uncommitted changes')),
  3687           ('d', 'date', '', _('tipmost revision matching date')),
  3689           ('d', 'date', '', _('tipmost revision matching date')),
  3688           ('r', 'rev', '', _('revision'))],
  3690           ('r', 'rev', '', _('revision'))],
  3689          _('[-C] [-d DATE] [[-r] REV]')),
  3691          _('[-c] [-C] [-d DATE] [[-r] REV]')),
  3690     "verify": (verify, []),
  3692     "verify": (verify, []),
  3691     "version": (version_, []),
  3693     "version": (version_, []),
  3692 }
  3694 }
  3693 
  3695 
  3694 norepo = ("clone init version help debugcommands debugcomplete debugdata"
  3696 norepo = ("clone init version help debugcommands debugcomplete debugdata"