mercurial/commands.py
changeset 31166 fad5e299cfc7
parent 31123 df0a0734304a
child 31173 052e4f1ffce9
equal deleted inserted replaced
31165:81250d377611 31166:fad5e299cfc7
  5276     return postincoming(ui, repo, modheads, opts.get('update'), None, None)
  5276     return postincoming(ui, repo, modheads, opts.get('update'), None, None)
  5277 
  5277 
  5278 @command('^update|up|checkout|co',
  5278 @command('^update|up|checkout|co',
  5279     [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
  5279     [('C', 'clean', None, _('discard uncommitted changes (no backup)')),
  5280     ('c', 'check', None, _('require clean working directory')),
  5280     ('c', 'check', None, _('require clean working directory')),
       
  5281     ('m', 'merge', None, _('merge uncommitted changes')),
  5281     ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
  5282     ('d', 'date', '', _('tipmost revision matching date'), _('DATE')),
  5282     ('r', 'rev', '', _('revision'), _('REV'))
  5283     ('r', 'rev', '', _('revision'), _('REV'))
  5283      ] + mergetoolopts,
  5284      ] + mergetoolopts,
  5284     _('[-C|-c] [-d DATE] [[-r] REV]'))
  5285     _('[-C|-c|-m] [-d DATE] [[-r] REV]'))
  5285 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False,
  5286 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False,
  5286            tool=None):
  5287            merge=None, tool=None):
  5287     """update working directory (or switch revisions)
  5288     """update working directory (or switch revisions)
  5288 
  5289 
  5289     Update the repository's working directory to the specified
  5290     Update the repository's working directory to the specified
  5290     changeset. If no changeset is specified, update to the tip of the
  5291     changeset. If no changeset is specified, update to the tip of the
  5291     current named branch and move the active bookmark (see :hg:`help
  5292     current named branch and move the active bookmark (see :hg:`help
  5300     for uncommitted changes; if none are found, the working directory is
  5301     for uncommitted changes; if none are found, the working directory is
  5301     updated to the specified changeset.
  5302     updated to the specified changeset.
  5302 
  5303 
  5303     .. container:: verbose
  5304     .. container:: verbose
  5304 
  5305 
  5305       The -C/--clean and -c/--check options control what happens if the
  5306       The -C/--clean, -c/--check, and -m/--merge options control what
  5306       working directory contains uncommitted changes.
  5307       happens if the working directory contains uncommitted changes.
  5307       At most of one of them can be specified.
  5308       At most of one of them can be specified.
  5308 
  5309 
  5309       1. If no option is specified, and if
  5310       1. If no option is specified, and if
  5310          the requested changeset is an ancestor or descendant of
  5311          the requested changeset is an ancestor or descendant of
  5311          the working directory's parent, the uncommitted changes
  5312          the working directory's parent, the uncommitted changes
  5313          result is left uncommitted. If the requested changeset is
  5314          result is left uncommitted. If the requested changeset is
  5314          not an ancestor or descendant (that is, it is on another
  5315          not an ancestor or descendant (that is, it is on another
  5315          branch), the update is aborted and the uncommitted changes
  5316          branch), the update is aborted and the uncommitted changes
  5316          are preserved.
  5317          are preserved.
  5317 
  5318 
  5318       2. With the -c/--check option, the update is aborted and the
  5319       2. With the -m/--merge option, the update is allowed even if the
       
  5320          requested changeset is not an ancestor or descendant of
       
  5321          the working directory's parent.
       
  5322 
       
  5323       3. With the -c/--check option, the update is aborted and the
  5319          uncommitted changes are preserved.
  5324          uncommitted changes are preserved.
  5320 
  5325 
  5321       3. With the -C/--clean option, uncommitted changes are discarded and
  5326       4. With the -C/--clean option, uncommitted changes are discarded and
  5322          the working directory is updated to the requested changeset.
  5327          the working directory is updated to the requested changeset.
  5323 
  5328 
  5324     To cancel an uncommitted merge (and lose your changes), use
  5329     To cancel an uncommitted merge (and lose your changes), use
  5325     :hg:`update --clean .`.
  5330     :hg:`update --clean .`.
  5326 
  5331 
  5341         rev = node
  5346         rev = node
  5342 
  5347 
  5343     if date and rev is not None:
  5348     if date and rev is not None:
  5344         raise error.Abort(_("you can't specify a revision and a date"))
  5349         raise error.Abort(_("you can't specify a revision and a date"))
  5345 
  5350 
  5346     if check and clean:
  5351     if len([x for x in (clean, check, merge) if x]) > 1:
  5347         raise error.Abort(_("cannot specify both -c/--check and -C/--clean"))
  5352         raise error.Abort(_("can only specify one of -C/--clean, -c/--check, "
       
  5353                             "or -m/merge"))
       
  5354 
       
  5355     updatecheck = None
       
  5356     if check:
       
  5357         updatecheck = 'abort'
       
  5358     elif merge:
       
  5359         updatecheck = 'none'
  5348 
  5360 
  5349     with repo.wlock():
  5361     with repo.wlock():
  5350         cmdutil.clearunfinished(repo)
  5362         cmdutil.clearunfinished(repo)
  5351 
  5363 
  5352         if date:
  5364         if date:
  5356         brev = rev
  5368         brev = rev
  5357         rev = scmutil.revsingle(repo, rev, rev).rev()
  5369         rev = scmutil.revsingle(repo, rev, rev).rev()
  5358 
  5370 
  5359         repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
  5371         repo.ui.setconfig('ui', 'forcemerge', tool, 'update')
  5360 
  5372 
  5361         return hg.updatetotally(ui, repo, rev, brev, clean=clean, check=check)
  5373         return hg.updatetotally(ui, repo, rev, brev, clean=clean,
       
  5374                                 updatecheck=updatecheck)
  5362 
  5375 
  5363 @command('verify', [])
  5376 @command('verify', [])
  5364 def verify(ui, repo):
  5377 def verify(ui, repo):
  5365     """verify the integrity of the repository
  5378     """verify the integrity of the repository
  5366 
  5379