* [PATCH] git-p4 : Small improvement patches
@ 2011-02-03 1:01 Vitor Antunes
2011-02-03 1:01 ` [PATCH] git-p4: Improve branch support Vitor Antunes
0 siblings, 1 reply; 2+ messages in thread
From: Vitor Antunes @ 2011-02-03 1:01 UTC (permalink / raw)
To: git; +Cc: Thomas Berg, Vitor Antunes
This patch finishes all the changes that I've done to git-p4 script and that
I've been using in my daily work. Although most of the changes are trivial, it
would be nice if someone could test these updates and provide feedback.
The script, as it is, still has one limitation: when it detects a new branch it
will base it on the last commit of the origin branch. This may not be true,
because the branch may have been created from an old change list. My idea would
be to find a commit to which the new branch would have a null diff... but I
don't know what would be the best way to do something like this through git
commands. Suggestions are welcome on this point :)
Thank in advance,
Vitor
Vitor Antunes (1):
git-p4: Improve branch support.
contrib/fast-import/git-p4 | 27 +++++++++++++++++++++++----
1 files changed, 23 insertions(+), 4 deletions(-)
--
1.7.2.3
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH] git-p4: Improve branch support.
2011-02-03 1:01 [PATCH] git-p4 : Small improvement patches Vitor Antunes
@ 2011-02-03 1:01 ` Vitor Antunes
0 siblings, 0 replies; 2+ messages in thread
From: Vitor Antunes @ 2011-02-03 1:01 UTC (permalink / raw)
To: git; +Cc: Thomas Berg, Vitor Antunes
Add new config option branchUser to allow filtering P4 branch list by user.
Allow defining the branch list through branchList config option.
Correct base branch directory detection to use '/' as the split character.
Signed-off-by: Vitor Antunes <vitor.hda@gmail.com>
---
contrib/fast-import/git-p4 | 27 +++++++++++++++++++++++----
1 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
index 9b67ae2..af1ba43 100755
--- a/contrib/fast-import/git-p4
+++ b/contrib/fast-import/git-p4
@@ -338,6 +338,11 @@ def gitConfig(key):
_gitConfig[key] = read_pipe("git config %s" % key, ignore_error=True).strip()
return _gitConfig[key]
+def gitConfigList(key):
+ if not _gitConfig.has_key(key):
+ _gitConfig[key] = read_pipe("git config --get-all %s" % key, ignore_error=True).strip().split(os.linesep)
+ return _gitConfig[key]
+
def p4BranchesInGit(branchesAreInRemotes = True):
branches = {}
@@ -1253,7 +1258,13 @@ class P4Sync(Command):
def getBranchMapping(self):
lostAndFoundBranches = set()
- for info in p4CmdList("branches"):
+ user = gitConfig("git-p4.branchUser")
+ if len(user) > 0:
+ command = "branches -u %s" % user
+ else:
+ command = "branches"
+
+ for info in p4CmdList(command):
details = p4Cmd("branch -o %s" % info["branch"])
viewIdx = 0
while details.has_key("View%s" % viewIdx):
@@ -1286,6 +1297,12 @@ class P4Sync(Command):
for branch in lostAndFoundBranches:
self.knownBranches[branch] = branch
+ configBranches = gitConfigList("git-p4.branchList")
+ for branch in configBranches:
+ if branch:
+ (source, destination) = branch.split(":")
+ self.knownBranches[destination] = source
+
def getBranchMappingFromGitBranches(self):
branches = p4BranchesInGit(self.importIntoRemotes)
for branch in branches.keys():
@@ -1581,12 +1598,14 @@ class P4Sync(Command):
else:
paths = []
for (prev, cur) in zip(self.previousDepotPaths, depotPaths):
- for i in range(0, min(len(cur), len(prev))):
- if cur[i] <> prev[i]:
+ prev_list = prev.split("/")
+ cur_list = cur.split("/")
+ for i in range(0, min(len(cur_list), len(prev_list))):
+ if cur_list[i] <> prev_list[i]:
i = i - 1
break
- paths.append (cur[:i + 1])
+ paths.append ("/".join(cur_list[:i + 1]))
self.previousDepotPaths = paths
--
1.7.2.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-02-03 1:02 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-03 1:01 [PATCH] git-p4 : Small improvement patches Vitor Antunes
2011-02-03 1:01 ` [PATCH] git-p4: Improve branch support Vitor Antunes
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).