git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pete Wyckoff <pw@padd.com>
To: git@vger.kernel.org
Cc: Gary Gibbons <ggibbons@perforce.com>
Subject: [PATCH 4/6] git-p4: support single file p4 client view maps
Date: Mon,  2 Jan 2012 18:05:52 -0500	[thread overview]
Message-ID: <1325545554-16540-5-git-send-email-pw@padd.com> (raw)
In-Reply-To: <1325545554-16540-1-git-send-email-pw@padd.com>

From: Gary Gibbons <ggibbons@perforce.com>

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>
---
 contrib/fast-import/git-p4    |   29 ++++++++++++++++++++---------
 t/t9809-git-p4-client-view.sh |    2 +-
 2 files changed, 21 insertions(+), 10 deletions(-)

diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 2fd4d3b..8f28e0a 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)
diff --git a/t/t9809-git-p4-client-view.sh b/t/t9809-git-p4-client-view.sh
index 06652cb..1cc83c5 100755
--- a/t/t9809-git-p4-client-view.sh
+++ b/t/t9809-git-p4-client-view.sh
@@ -191,7 +191,7 @@ test_expect_success 'exclusion wildcard, client rhs different (normal)' '
 	git_verify $files
 '
 
-test_expect_failure 'exclusion single file' '
+test_expect_success 'exclusion single file' '
 	client_view "//depot/... //client/..." \
 		    "-//depot/dir2/file22 //client/file22" &&
 	files="dir1/file11 dir1/file12 dir2/file21" &&
-- 
1.7.8.1.407.gd70cb

  parent reply	other threads:[~2012-01-02 23:07 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-01-02 23:05 [PATCH 0/6] git-p4: view spec improvements Pete Wyckoff
2012-01-02 23:05 ` [PATCH 1/6] git-p4: test client view handling Pete Wyckoff
2012-01-02 23:05 ` [PATCH 2/6] git-p4: fix test for unsupported P4 Client Views Pete Wyckoff
2012-01-02 23:05 ` [PATCH 3/6] git-p4: sort client views by reverse View number Pete Wyckoff
2012-01-02 23:05 ` Pete Wyckoff [this message]
2012-01-02 23:05 ` [PATCH 5/6] git-p4: rewrite view handling Pete Wyckoff
2012-01-02 23:05 ` [PATCH 6/6] git-p4: view spec documentation Pete Wyckoff

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1325545554-16540-5-git-send-email-pw@padd.com \
    --to=pw@padd.com \
    --cc=ggibbons@perforce.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).