mercurial/commands.py
changeset 8855 f331de880cbb
parent 8849 80cc4b1a62d0
child 8856 f8d00346a62d
equal deleted inserted replaced
8854:980f5b7c5fb6 8855:f331de880cbb
  2973     finally:
  2973     finally:
  2974         lock.release()
  2974         lock.release()
  2975 
  2975 
  2976     return postincoming(ui, repo, modheads, opts.get('update'), None)
  2976     return postincoming(ui, repo, modheads, opts.get('update'), None)
  2977 
  2977 
  2978 def update(ui, repo, node=None, rev=None, clean=False, date=None):
  2978 def update(ui, repo, node=None, rev=None, clean=False, date=None, check=False):
  2979     """update working directory
  2979     """update working directory
  2980 
  2980 
  2981     Update the repository's working directory to the specified
  2981     Update the repository's working directory to the specified
  2982     revision, or the tip of the current branch if none is specified.
  2982     revision, or the tip of the current branch if none is specified.
  2983     Use null as the revision to remove the working copy (like 'hg
  2983     Use null as the revision to remove the working copy (like 'hg
  2989     the working directory will additionally be switched to that
  2989     the working directory will additionally be switched to that
  2990     branch.
  2990     branch.
  2991 
  2991 
  2992     When there are uncommitted changes, use option -C/--clean to
  2992     When there are uncommitted changes, use option -C/--clean to
  2993     discard them, forcibly replacing the state of the working
  2993     discard them, forcibly replacing the state of the working
  2994     directory with the requested revision.
  2994     directory with the requested revision. Alternately, use -c/--check
       
  2995     to abort.
  2995 
  2996 
  2996     When there are uncommitted changes and option -C/--clean is not
  2997     When there are uncommitted changes and option -C/--clean is not
  2997     used, and the parent revision and requested revision are on the
  2998     used, and the parent revision and requested revision are on the
  2998     same branch, and one of them is an ancestor of the other, then the
  2999     same branch, and one of them is an ancestor of the other, then the
  2999     new working directory will contain the requested revision merged
  3000     new working directory will contain the requested revision merged
  3008     if rev and node:
  3009     if rev and node:
  3009         raise util.Abort(_("please specify just one revision"))
  3010         raise util.Abort(_("please specify just one revision"))
  3010 
  3011 
  3011     if not rev:
  3012     if not rev:
  3012         rev = node
  3013         rev = node
       
  3014 
       
  3015     if not clean and check:
       
  3016         # we could use dirty() but we can ignore merge and branch trivia
       
  3017         c = repo[None]
       
  3018         if c.modified() or c.added() or c.removed():
       
  3019             raise util.Abort(_("uncommitted local changes"))
  3013 
  3020 
  3014     if date:
  3021     if date:
  3015         if rev:
  3022         if rev:
  3016             raise util.Abort(_("you can't specify a revision and a date"))
  3023             raise util.Abort(_("you can't specify a revision and a date"))
  3017         rev = cmdutil.finddate(ui, repo, date)
  3024         rev = cmdutil.finddate(ui, repo, date)
  3500            _('update to new tip if changesets were unbundled'))],
  3507            _('update to new tip if changesets were unbundled'))],
  3501          _('[-u] FILE...')),
  3508          _('[-u] FILE...')),
  3502     "^update|up|checkout|co":
  3509     "^update|up|checkout|co":
  3503         (update,
  3510         (update,
  3504          [('C', 'clean', None, _('overwrite locally modified files (no backup)')),
  3511          [('C', 'clean', None, _('overwrite locally modified files (no backup)')),
       
  3512           ('c', 'check', None, _('check for uncommitted changes')),
  3505           ('d', 'date', '', _('tipmost revision matching date')),
  3513           ('d', 'date', '', _('tipmost revision matching date')),
  3506           ('r', 'rev', '', _('revision'))],
  3514           ('r', 'rev', '', _('revision'))],
  3507          _('[-C] [-d DATE] [[-r] REV]')),
  3515          _('[-C] [-d DATE] [[-r] REV]')),
  3508     "verify": (verify, []),
  3516     "verify": (verify, []),
  3509     "version": (version_, []),
  3517     "version": (version_, []),