git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Fix a spelling mistake in a git-p4 console message
@ 2010-03-19  4:39 Benjamin C Meyer
  2010-03-19  4:39 ` [PATCH 2/2] Improve git-p4 to be able to submit patches back to perforce when the git repository is made up of multiple perforce directories. (v2) Benjamin C Meyer
  0 siblings, 1 reply; 2+ messages in thread
From: Benjamin C Meyer @ 2010-03-19  4:39 UTC (permalink / raw)
  To: git; +Cc: simon.hausmann, Benjamin C Meyer

Signed-off-by: Benjamin C Meyer <bmeyer@rim.com>
---
 contrib/fast-import/git-p4 |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index cd96c6f..c1ea643 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -802,7 +802,7 @@ class P4Submit(Command):
         self.oldWorkingDirectory = os.getcwd()
 
         chdir(self.clientPath)
-        print "Syncronizing p4 checkout..."
+        print "Synchronizing p4 checkout..."
         p4_system("sync ...")
 
         self.check()
-- 
1.7.0.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] Improve git-p4 to be able to submit patches back to perforce when the git repository is made up of multiple perforce directories. (v2)
  2010-03-19  4:39 [PATCH 1/2] Fix a spelling mistake in a git-p4 console message Benjamin C Meyer
@ 2010-03-19  4:39 ` Benjamin C Meyer
  0 siblings, 0 replies; 2+ messages in thread
From: Benjamin C Meyer @ 2010-03-19  4:39 UTC (permalink / raw)
  To: git; +Cc: simon.hausmann, Benjamin C Meyer

git-p4 lets you sync several perforce directories into the one git repository,
but when you would do a git perforce submit it was hardcoded to apply
the patches to whatever was the first directory in the list that
the repository was synced from which would usually fail.  When
multiple perforce directories are now present git-p4 will apply them
to the common root directory where the patches can successfully be applied.

For example if you synced these two directories from perforce in git

//depot/foo/bar,//depot/test

git-p4 will now lookup that the client paths are:

~/p4/foo/bar,~/p4/test

and then set self.clientPath to the root of all of the client paths
(~/p4) permitting the patches from git to be cleanly applied for all
of the directories.

v2: Code path should only be followed when there are more then 1 depo
path, not 0

Signed-off-by: Benjamin C Meyer <bmeyer@rim.com>
---
 contrib/fast-import/git-p4 |   40 +++++++++++++++++++++++++++++-----------
 1 files changed, 29 insertions(+), 11 deletions(-)

diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index c1ea643..58aaea9 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -766,6 +766,21 @@ class P4Submit(Command):
                    + "Please review/edit and then use p4 submit -i < %s to submit directly!"
                    % (fileName, fileName))
 
+    def findCommonPath(self, settings):
+        dirs = []
+        for path in settings:
+            localDir = p4Where(path)
+            if len(localDir) > 0:
+                dirs.append(localDir)
+        localDir = dirs[0];
+        maxMatch = len(localDir) - 1
+        for dir in dirs:
+            if maxMatch > len(dir) - 1:
+                maxMatch = len(dir) - 1
+            while dir[maxMatch] != localDir[maxMatch]:
+                maxMatch = maxMatch - 1;
+        return localDir[0:maxMatch]
+
     def run(self, args):
         if len(args) == 0:
             self.master = currentGitBranch()
@@ -781,23 +796,26 @@ class P4Submit(Command):
             die("%s is not in git-p4.allowSubmit" % self.master)
 
         [upstream, settings] = findUpstreamBranchPoint()
-        self.depotPath = settings['depot-paths'][0]
+        if (len(settings['depot-paths']) > 1):
+            self.depotPath = ""
+            self.clientPath = self.findCommonPath(settings['depot-paths'])
+        else:
+            self.depotPath = settings['depot-paths'][0]
+            if len(self.depotPath) == 0:
+                print "Internal error: cannot locate perforce depot path from existing branches"
+                sys.exit(128)
+            self.clientPath = p4Where(self.depotPath)
+
+        if len(self.clientPath) == 0:
+            print "Error: Cannot locate perforce checkout of %s in client view" % self.depotPath
+            sys.exit(128)
+
         if len(self.origin) == 0:
             self.origin = upstream
 
         if self.verbose:
             print "Origin branch is " + self.origin
 
-        if len(self.depotPath) == 0:
-            print "Internal error: cannot locate perforce depot path from existing branches"
-            sys.exit(128)
-
-        self.clientPath = p4Where(self.depotPath)
-
-        if len(self.clientPath) == 0:
-            print "Error: Cannot locate perforce checkout of %s in client view" % self.depotPath
-            sys.exit(128)
-
         print "Perforce checkout for depot path %s located at %s" % (self.depotPath, self.clientPath)
         self.oldWorkingDirectory = os.getcwd()
 
-- 
1.7.0.2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-03-19  4:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-03-19  4:39 [PATCH 1/2] Fix a spelling mistake in a git-p4 console message Benjamin C Meyer
2010-03-19  4:39 ` [PATCH 2/2] Improve git-p4 to be able to submit patches back to perforce when the git repository is made up of multiple perforce directories. (v2) Benjamin C Meyer

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).