[PATCH 04 of 11] cmdutil: rename a to A on ci filesystems succeeds (issue1717)
Simon Heimberg
simohe at besonet.ch
Fri Aug 7 19:43:02 UTC 2009
# HG changeset patch
# User Simon Heimberg <simohe at besonet.ch>
# Date 1248259922 -7200
# Node ID 76406c3720caa61cf9d466b43d2aac68b15ec362
# Parent 6aad3d33602f990c179f901df3474babf784fc84
cmdutil: rename a to A on ci filesystems succeeds (issue1717)
tested on linux with hfs
diff -r 6aad3d33602f -r 76406c3720ca mercurial/cmdutil.py
--- a/mercurial/cmdutil.py Fre Aug 07 16:56:31 2009 +0200
+++ b/mercurial/cmdutil.py Mit Jul 22 12:52:02 2009 +0200
@@ -390,8 +390,22 @@
# check for overwrites
exists = os.path.exists(target)
+ changecase = False
if not after and exists or after and state in 'mn':
- if not opts['force']:
+ def realpath(path):
+ return util.realpath(path, repo.root)
+
+ if opts['force']:
+ pass
+ elif src == target:
+ ui.warn(_('%s: not overwriting - same file\n') % reltarget)
+ return
+ elif rename and not after and realpath(src) == realpath(target):
+ # case change on case insensitive filesystems
+ changecase = True
+ if not dryrun:
+ os.rename(src, target)
+ else:
ui.warn(_('%s: not overwriting - file exists\n') %
reltarget)
return
@@ -399,7 +413,7 @@
if after:
if not exists:
return
- elif not dryrun:
+ elif not (dryrun or changecase):
try:
if exists:
os.unlink(target)
@@ -440,7 +454,7 @@
repo.copy(origsrc, abstarget)
if rename and not dryrun:
- repo.remove([abssrc], not after)
+ repo.remove([abssrc], not (after or changecase))
# pat: ossep
# dest ossep
diff -r 6aad3d33602f -r 76406c3720ca tests/test-casefolding
--- a/tests/test-casefolding Fre Aug 07 16:56:31 2009 +0200
+++ b/tests/test-casefolding Mit Jul 22 12:52:02 2009 +0200
@@ -12,15 +12,15 @@
hg manifest
cd ..
-echo '% test case collision on rename (issue 750)'
+echo '% test case collision on rename (issue 750/1717)'
hg init repo2
cd repo2
echo a > a
hg --debug ci -Am adda
hg mv a A
+hg st
# 'a' used to be removed under windows
-test -f a || echo 'a is missing'
-hg st
+ls
cd ..
echo '% test case collision between revisions (issue 912)'
diff -r 6aad3d33602f -r 76406c3720ca tests/test-casefolding.out
--- a/tests/test-casefolding.out Fre Aug 07 16:56:31 2009 +0200
+++ b/tests/test-casefolding.out Mit Jul 22 12:52:02 2009 +0200
@@ -2,11 +2,13 @@
adding a
A a
a
-% test case collision on rename (issue 750)
+% test case collision on rename (issue 750/1717)
adding a
a
committed changeset 0:07f4944404050f47db2e5c5071e0e84e7a27bba9
-A: not overwriting - file exists
+A A
+R a
+A
% test case collision between revisions (issue 912)
adding a
adding A
More information about the Mercurial-devel
mailing list