summaryrefslogtreecommitdiff
path: root/contrib/fast-import
diff options
context:
space:
mode:
authorLibravatar Gary Gibbons <ggibbons@perforce.com>2012-01-02 18:05:52 -0500
committerLibravatar Junio C Hamano <gitster@pobox.com>2012-01-03 14:10:03 -0800
commite3e68643b5c2adec097ba26230e0fcb641febacb (patch)
treec4cb11e7afc2861f99c586304b9502cdb21f5920 /contrib/fast-import
parentgit-p4: sort client views by reverse View number (diff)
downloadtgif-e3e68643b5c2adec097ba26230e0fcb641febacb.tar.xz
git-p4: support single file p4 client view maps
Perforce client views can map individual files, mapping one //depot file path to one //client file path. These mappings contain no meta/masking characters. This patch add support for these file maps to the currently supported '...' view mappings. [pw: one test now suceeds] Signed-off-by: Gary Gibbons <ggibbons@perforce.com> Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'contrib/fast-import')
-rwxr-xr-xcontrib/fast-import/git-p429
1 files changed, 20 insertions, 9 deletions
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 2fd4d3b2a6..8f28e0a6fb 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -1217,6 +1217,7 @@ class P4Sync(Command, P4UserMap):
self.cloneExclude = []
self.useClientSpec = False
self.clientSpecDirs = []
+ self.haveSingleFileClientViews = False
if gitConfig("git-p4.syncFromOrigin") == "false":
self.syncWithOrigin = False
@@ -1274,6 +1275,16 @@ class P4Sync(Command, P4UserMap):
# will end up putting all foo/branch files into
# branch/foo/
for val in self.clientSpecDirs:
+ if self.haveSingleFileClientViews and len(path) == abs(val[1][0]) and path == val[0]:
+ # since 'path' is a depot file path, if it matches the LeftMap,
+ # then the View is a single file mapping, so use the entire rightMap
+ # first two tests above avoid the last == test for common cases
+ path = val[1][1]
+ # now strip out the client (//client/...)
+ path = re.sub("^(//[^/]+/)", '', path)
+ # the rest is local client path
+ return path
+
if path.startswith(val[0]):
# replace the depot path with the client path
path = path.replace(val[0], val[1][1])
@@ -1905,19 +1916,19 @@ class P4Sync(Command, P4UserMap):
# save the "client view"; i.e the RHS of the view
# line that tells the client where to put the
# files for this view.
- cv = v[index+3:].strip() # +3 to remove previous '...'
- # if the client view doesn't end with a
- # ... wildcard, then we're going to mess up the
- # output directory, so fail gracefully.
- if not cv.endswith('...'):
- print 'Sorry, client view in "%s" needs to end with wildcard' % (k)
- sys.exit(1)
- cv=cv[:-3]
+ # check for individual file mappings - those which have no '...'
+ if index < 0 :
+ v,cv = v.strip().split()
+ v = v[start:]
+ self.haveSingleFileClientViews = True
+ else:
+ cv = v[index+3:].strip() # +3 to remove previous '...'
+ cv=cv[:-3]
+ v = v[start:index]
# now save the view; +index means included, -index
# means it should be filtered out.
- v = v[start:index]
if v.startswith("-"):
v = v[1:]
include = -len(v)