# HG changeset patch # User Benoit Boissinot # Date 1162296232 -3600 # Node ID 5f08389bcf064190f680ad638114dc3c3f1da063 # Parent 9bfb3c049b2aaa85c013262db3907179902b7560# Parent 1c9b6f1237e007eb7f39774ec0c1f4335271e493 merge with crew diff --git a/contrib/zsh_completion b/contrib/zsh_completion --- a/contrib/zsh_completion +++ b/contrib/zsh_completion @@ -140,13 +140,19 @@ typeset -A _hg_cmd_globals _hg_unknown() { typeset -a status_files _hg_status u - (( $#status_files )) && _describe -t files 'unknown files' status_files + _wanted files expl 'unknown files' _multi_parts / status_files } _hg_missing() { typeset -a status_files _hg_status d - (( $#status_files )) && _describe -t files 'missing files' status_files + _wanted files expl 'missing files' _multi_parts / status_files +} + +_hg_modified() { + typeset -a status_files + _hg_status m + _wanted files expl 'modified files' _multi_parts / status_files } _hg_addremove() { @@ -303,13 +309,24 @@ typeset -A _hg_cmd_globals } _hg_cmd_diff() { + typeset -A opt_args _arguments -s -w : $_hg_global_opts $_hg_pat_opts $_hg_diff_opts \ '*'{-r,--rev}'+[revision]:revision:_hg_revrange' \ '(--show-function -p)'{-p,--show-function}'[show which function each change is in]' \ '(--ignore-all-space -w)'{-w,--ignore-all-space}'[ignore white space when comparing lines]' \ '(--ignore-space-change -b)'{-b,--ignore-space-change}'[ignore changes in the amount of white space]' \ '(--ignore-blank-lines -B)'{-B,--ignore-blank-lines}'[ignore changes whose lines are all blank]' \ - '*:file:_files -W $(_hg_cmd root)' + '*:file:->diff_files' + + if [[ $state == 'diff_files' ]] + then + if [[ -n $opt_args[-r] ]] + then + _files -W $(_hg_cmd root) + else + _hg_modified + fi + fi } _hg_cmd_export() { @@ -448,7 +465,19 @@ typeset -A _hg_cmd_globals '(--all -a :)'{-a,--all}'[revert all changes when no arguments given]' \ '(--rev -r)'{-r+,--rev}'[revision to revert to]:revision:_hg_tags' \ '--no-backup[do not save backup copies of files]' \ - '*:file:_files -W $(_hg_cmd root)' + '*:file:->diff_files' + + if [[ $state == 'diff_files' ]] + then + if [[ -n $opt_args[-r] ]] + then + _files -W $(_hg_cmd root) + else + typeset -a status_files + _hg_status mard + _wanted files expl 'modified, added, removed or deleted file' _multi_parts / status_files + fi + fi } _hg_cmd_serve() { diff --git a/mercurial/patch.py b/mercurial/patch.py --- a/mercurial/patch.py +++ b/mercurial/patch.py @@ -369,6 +369,9 @@ def updatedir(ui, repo, patches, wlock=N if gp and gp.mode: x = gp.mode & 0100 != 0 dst = os.path.join(repo.root, gp.path) + # patch won't create empty files + if ctype == 'ADD' and not os.path.exists(dst): + repo.wwrite(gp.path, '') util.set_exec(dst, x) cmdutil.addremove(repo, cfiles, wlock=wlock) files = patches.keys() diff --git a/tests/test-git-import b/tests/test-git-import --- a/tests/test-git-import +++ b/tests/test-git-import @@ -14,6 +14,13 @@ index 0000000..7898192 +a EOF +echo % new empty file +hg import -mempty - <