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 3/6] git-p4: sort client views by reverse View number
Date: Mon,  2 Jan 2012 18:05:51 -0500	[thread overview]
Message-ID: <1325545554-16540-4-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>

Correct view sorting to support the Perforce order,
where client views are ordered and later views
override earlier view mappings.

[pw: one test now succeeds]

Signed-off-by: Gary Gibbons <ggibbons@perforce.com>
Signed-off-by: Pete Wyckoff <pw@padd.com>
---
 contrib/fast-import/git-p4    |   11 +++++++++--
 t/t9809-git-p4-client-view.sh |    2 +-
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index c144c89..2fd4d3b 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -1924,10 +1924,17 @@ class P4Sync(Command, P4UserMap):
                     else:
                         include = len(v)
 
-                    temp[v] = (include, cv)
+                    # store the View #number for sorting
+                    # and the View string itself (this last for documentation)
+                    temp[v] = (include, cv, int(k[4:]),k)
 
         self.clientSpecDirs = temp.items()
-        self.clientSpecDirs.sort( lambda x, y: abs( y[1][0] ) - abs( x[1][0] ) )
+        # Perforce ViewNN with higher #numbers override those with lower
+        # reverse sort on the View #number
+        self.clientSpecDirs.sort( lambda x, y:  y[1][2] -  x[1][2]  )
+        if self.verbose:
+            for val in self.clientSpecDirs:
+                    print "clientSpecDirs: %s %s" % (val[0],val[1])
 
     def run(self, args):
         self.depotPaths = []
diff --git a/t/t9809-git-p4-client-view.sh b/t/t9809-git-p4-client-view.sh
index cbf2213..06652cb 100755
--- a/t/t9809-git-p4-client-view.sh
+++ b/t/t9809-git-p4-client-view.sh
@@ -133,7 +133,7 @@ test_expect_failure 'single file map' '
 	git_verify $files
 '
 
-test_expect_failure 'later mapping takes precedence (entire repo)' '
+test_expect_success 'later mapping takes precedence (entire repo)' '
 	client_view "//depot/dir1/... //client/cli1/..." \
 		    "//depot/... //client/cli2/..." &&
 	files="cli2/dir1/file11 cli2/dir1/file12
-- 
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 ` Pete Wyckoff [this message]
2012-01-02 23:05 ` [PATCH 4/6] git-p4: support single file p4 client view maps Pete Wyckoff
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-4-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).