{"thread":{"id":"26394","subject":"[PATCH] git-p4 : Small improvement patches","startedAt":"2011-02-03T01:01:52Z","lastAt":"2011-02-03T01:01:53Z","messageCount":2,"participants":["Vitor Antunes"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"160301","messageId":"1296694913-7844-1-git-send-email-vitor.hda@gmail.com","threadId":"26394","inReplyTo":null,"subject":"[PATCH] git-p4 : Small improvement patches","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-02-03T01:01:52Z","receivedAt":"2011-02-03T01:01:52Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"This patch finishes all the changes that I've done to git-p4 script and that\nI've been using in my daily work. Although most of the changes are trivial, it\nwould be nice if someone could test these updates and provide feedback.\n\nThe script, as it is, still has one limitation: when it detects a new branch it\nwill base it on the last commit of the origin branch. This may not be true,\nbecause the branch may have been created from an old change list. My idea would\nbe to find a commit to which the new branch would have a null diff... but I\ndon't know what would be the best way to do something like this through git\ncommands. Suggestions are welcome on this point :)\n\nThank in advance,\nVitor\n\nVitor Antunes (1):\n  git-p4: Improve branch support.\n\n contrib/fast-import/git-p4 |   27 +++++++++++++++++++++++----\n 1 files changed, 23 insertions(+), 4 deletions(-)\n\n-- \n1.7.2.3\n"},{"id":"160302","messageId":"1296694913-7844-2-git-send-email-vitor.hda@gmail.com","threadId":"26394","inReplyTo":"1296694913-7844-1-git-send-email-vitor.hda@gmail.com","subject":"[PATCH] git-p4: Improve branch support.","fromName":"Vitor Antunes","fromEmail":"vitor.hda@gmail.com","sentAt":"2011-02-03T01:01:53Z","receivedAt":"2011-02-03T01:01:53Z","isPatch":true,"sender":{"key":"vitor.hda@gmail.com","avatar":"https://avatars.githubusercontent.com/u/606876?v=4"},"body":"Add new config option branchUser to allow filtering P4 branch list by user.\nAllow defining the branch list through branchList config option.\nCorrect base branch directory detection to use '/' as the split character.\n\nSigned-off-by: Vitor Antunes <vitor.hda@gmail.com>\n---\n contrib/fast-import/git-p4 |   27 +++++++++++++++++++++++----\n 1 files changed, 23 insertions(+), 4 deletions(-)\n\ndiff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4\nindex 9b67ae2..af1ba43 100755\n--- a/contrib/fast-import/git-p4\n+++ b/contrib/fast-import/git-p4\n@@ -338,6 +338,11 @@ def gitConfig(key):\n         _gitConfig[key] = read_pipe(\"git config %s\" % key, ignore_error=True).strip()\n     return _gitConfig[key]\n \n+def gitConfigList(key):\n+    if not _gitConfig.has_key(key):\n+        _gitConfig[key] = read_pipe(\"git config --get-all %s\" % key, ignore_error=True).strip().split(os.linesep)\n+    return _gitConfig[key]\n+\n def p4BranchesInGit(branchesAreInRemotes = True):\n     branches = {}\n \n@@ -1253,7 +1258,13 @@ class P4Sync(Command):\n     def getBranchMapping(self):\n         lostAndFoundBranches = set()\n \n-        for info in p4CmdList(\"branches\"):\n+        user = gitConfig(\"git-p4.branchUser\")\n+        if len(user) > 0:\n+            command = \"branches -u %s\" % user\n+        else:\n+            command = \"branches\"\n+\n+        for info in p4CmdList(command):\n             details = p4Cmd(\"branch -o %s\" % info[\"branch\"])\n             viewIdx = 0\n             while details.has_key(\"View%s\" % viewIdx):\n@@ -1286,6 +1297,12 @@ class P4Sync(Command):\n         for branch in lostAndFoundBranches:\n             self.knownBranches[branch] = branch\n \n+        configBranches = gitConfigList(\"git-p4.branchList\")\n+        for branch in configBranches:\n+            if branch:\n+                (source, destination) = branch.split(\":\")\n+                self.knownBranches[destination] = source\n+\n     def getBranchMappingFromGitBranches(self):\n         branches = p4BranchesInGit(self.importIntoRemotes)\n         for branch in branches.keys():\n@@ -1581,12 +1598,14 @@ class P4Sync(Command):\n                     else:\n                         paths = []\n                         for (prev, cur) in zip(self.previousDepotPaths, depotPaths):\n-                            for i in range(0, min(len(cur), len(prev))):\n-                                if cur[i] <> prev[i]:\n+                            prev_list = prev.split(\"/\")\n+                            cur_list = cur.split(\"/\")\n+                            for i in range(0, min(len(cur_list), len(prev_list))):\n+                                if cur_list[i] <> prev_list[i]:\n                                     i = i - 1\n                                     break\n \n-                            paths.append (cur[:i + 1])\n+                            paths.append (\"/\".join(cur_list[:i + 1]))\n \n                         self.previousDepotPaths = paths\n \n-- \n1.7.2.3\n"}]}