changeset 11701:84fb29f5e0d2

mq: fix qimport --name --existing --force on win32 os.rename() does not overwrite existing targets on Windows.
author Patrick Mezard <pmezard@gmail.com>
date Wed, 28 Jul 2010 11:07:20 +0200
parents 52c863295754
children eb07fbc21e9c
files hgext/mq.py tests/test-mq-qimport tests/test-mq-qimport.out
diffstat 3 files changed, 17 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/hgext/mq.py	Fri Jul 23 23:43:43 2010 +0900
+++ b/hgext/mq.py	Wed Jul 28 11:07:20 2010 +0200
@@ -1699,7 +1699,7 @@
 
                     self.ui.write(_('renaming %s to %s\n')
                                         % (filename, patchname))
-                    os.rename(originpath, self.join(patchname))
+                    util.rename(originpath, self.join(patchname))
                 else:
                     patchname = filename
 
--- a/tests/test-mq-qimport	Fri Jul 23 23:43:43 2010 +0900
+++ b/tests/test-mq-qimport	Wed Jul 28 11:07:20 2010 +0200
@@ -118,3 +118,10 @@
 echo % qimport -e --name newname oldexisitingpatch
 hg qimport -e --name this-name-is-better 2.diff
 hg qser
+echo % qimport -e --name without --force
+cp .hg/patches/this-name-is-better .hg/patches/3.diff
+hg qimport -e --name this-name-is-better 3.diff
+hg qser
+echo % qimport -e --name with --force
+hg qimport --force -e --name this-name-is-better 3.diff
+hg qser
--- a/tests/test-mq-qimport.out	Fri Jul 23 23:43:43 2010 +0900
+++ b/tests/test-mq-qimport.out	Wed Jul 28 11:07:20 2010 +0200
@@ -61,3 +61,12 @@
 adding this-name-is-better to series file
 this-name-is-better
 url.diff
+% qimport -e --name without --force
+abort: patch "this-name-is-better" already exists
+this-name-is-better
+url.diff
+% qimport -e --name with --force
+renaming 3.diff to this-name-is-better
+adding this-name-is-better to series file
+this-name-is-better
+url.diff