changeset 3594:5f08389bcf06

merge with crew
author Benoit Boissinot <benoit.boissinot@ens-lyon.org>
date Tue, 31 Oct 2006 13:03:52 +0100
parents 9bfb3c049b2a (current diff) 1c9b6f1237e0 (diff)
children fc34fd58ae7b
files
diffstat 4 files changed, 48 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/contrib/zsh_completion	Tue Oct 31 13:03:23 2006 +0100
+++ b/contrib/zsh_completion	Tue Oct 31 13:03:52 2006 +0100
@@ -140,13 +140,19 @@
 _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 @@
 }
 
 _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 @@
   '(--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() {
--- a/mercurial/patch.py	Tue Oct 31 13:03:23 2006 +0100
+++ b/mercurial/patch.py	Tue Oct 31 13:03:52 2006 +0100
@@ -369,6 +369,9 @@
         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()
--- a/tests/test-git-import	Tue Oct 31 13:03:23 2006 +0100
+++ b/tests/test-git-import	Tue Oct 31 13:03:52 2006 +0100
@@ -14,6 +14,13 @@
 +a
 EOF
 
+echo % new empty file
+hg import -mempty - <<EOF
+diff --git a/empty b/empty
+new file mode 100644
+EOF
+hg locate empty
+
 echo % chmod +x
 hg import -msetx - <<EOF
 diff --git a/new b/new
--- a/tests/test-git-import.out	Tue Oct 31 13:03:23 2006 +0100
+++ b/tests/test-git-import.out	Tue Oct 31 13:03:52 2006 +0100
@@ -1,5 +1,8 @@
 % new file
 applying patch from stdin
+% new empty file
+applying patch from stdin
+empty
 % chmod +x
 applying patch from stdin
 % copy
@@ -9,10 +12,12 @@
 % rename
 applying patch from stdin
 copyx
+empty
 new
 rename
 % delete
 applying patch from stdin
+empty
 new
 rename
 % regular diff