Perfarce extension patch: implement config option lowerpaths
r.ghetta
birrachiara at tin.it
Wed Feb 3 12:32:47 CST 2010
Revised patch follows: option name renamed to 'lowercasepaths'.
Riccardo
# HG changeset patch
# User Riccardo Ghetta <bchiara at users.sf.net>
# Date 1264277013 -3600
# Node ID 54b9b70dddff510878fe8f46fa2887a0a54a1aeb
# Parent de64500a0e71a1343e07a7b648dc93233fd1118e
Added config option lowercasepaths.
If True forces all paths to lowercase. It's intended as a workaround when
the Perforce depot on windows contains the same path spelled differently.
Perforce records the directory names at add time, so if you add path/foo
then Path/bar Perforce records path and Path respectively.
Mercurial does the same, but considers them two paths as different, while
Perforce on windows treats them as identical.
With --config perfarce.lowercasepaths=True perfarce forces all path names
(file names are unchanged) to lowercase, avoiding this problem.
diff --git a/perfarce.py b/perfarce.py
--- a/perfarce.py
+++ b/perfarce.py
@@ -51,6 +51,16 @@
clone If the source repository name starts with p4:// then this
creates the destination repository and pulls all changes
from the p4 depot into it.
+ If the option
+
+ --config perfarce.lowercasepaths=False
+
+ is True then the import forces all paths in lowercase,
+ otherwise paths are recorded unchanged. Filename case is
+ always preserved.
+ This setting is a workaround to handle Perforce depots
+ containing a path spelled differently from file to file
+ (e.g. path/foo and PAth/bar).
'''
from mercurial import cmdutil, commands, context, copies, error, extensions, hg, node, util
@@ -97,7 +107,7 @@
self.client = None
self.root = None
self.keep = ui.configbool('perfarce', 'keep', True)
-
+ self.lowercasepaths = ui.configbool('perfarce', 'lowercasepaths', False)
# caches
self.clientspec = {}
self.usercache = {}
@@ -375,8 +385,11 @@
tp = d['headType']
ac = d['headAction']
lf = d['clientFile']
+ if self.lowercasepaths:
+ pathname, fname = os.path.split(lf)
+ lf = os.path.join(os.path.normcase(pathname), fname)
lf = util.pconvert(lf)
- if lf.startswith('%s/' % self.root):
+ if lf.startswith('%s/' % self.root.lower() if self.lowercasepaths else self.root):
lf = lf[len(self.root) + 1:]
else:
raise util.Abort(_('invalid p4 local path %s') % lf)
@@ -738,6 +751,9 @@
if changes[0] != startrev:
raise util.Abort(_('changelist for --startrev not found'))
+ if client.lowercasepaths:
+ ui.status(_("Converting pathnames to lowercase.\n"))
+
tags = {}
try:
@@ -856,6 +872,7 @@
fp.write("default = %s\n" % source)
fp.write("\n[perfarce]\n")
fp.write("keep = %s\n" % client.keep)
+ fp.write("lowercasepaths = %s\n" % client.lowercasepaths)
fp.close()
return r
More information about the Mercurial-devel
mailing list