summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 6754a29)
raw | patch | inline | side by side (parent: 6754a29)
author | Han-Wen Nienhuys <hanwen@google.com> | |
Wed, 23 May 2007 21:20:53 +0000 (18:20 -0300) | ||
committer | Han-Wen Nienhuys <hanwen@google.com> | |
Mon, 28 May 2007 14:18:31 +0000 (11:18 -0300) |
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
contrib/fast-import/git-p4 | patch | blob | history |
index 93c9d6417cc013153235059117e6190b099790b0..51d117b789ef2dec4c85e9db62f93b1912fd6f0d 100755 (executable)
import optparse, sys, os, marshal, popen2, subprocess, shelve
import tempfile, getopt, sha, os.path, time, platform
import re
+
from sets import Set;
gitdir = os.environ.get("GIT_DIR", "")
if not silent:
sys.stderr.write('writing pipe: %s\n' % c)
- ## todo: check return status
pipe = os.popen(c, 'w')
val = pipe.write(str)
if pipe.close():
def read_pipe(c):
if not silent:
sys.stderr.write('reading pipe: %s\n' % c)
- ## todo: check return status
+
pipe = os.popen(c, 'rb')
val = pipe.read()
if pipe.close():
if os.system(cmd) != 0:
die("command failed: %s" % cmd)
-
-
def p4CmdList(cmd):
cmd = "p4 -G %s" % cmd
pipe = os.popen(cmd, "rb")
optparse.make_option("--detect-labels", dest="detectLabels", action="store_true"),
optparse.make_option("--verbose", dest="verbose", action="store_true"),
optparse.make_option("--import-local", dest="importIntoRemotes", action="store_false"),
- optparse.make_option("--max-changes", dest="maxChanges")
+ optparse.make_option("--max-changes", dest="maxChanges"),
+ optparse.make_option("--keep-path", dest="keepRepoPath")
]
self.description = """Imports from Perforce into a git repository.\n
example:
self.maxChanges = ""
self.isWindows = (platform.system() == "Windows")
self.depotPath = None
+ self.keepRepoPath = False
if gitConfig("git-p4.syncFromOrigin") == "false":
self.syncWithOrigin = False
fnum = fnum + 1
return files
- def stripRepoPath(self, path):
- return path[len(self.depotPath):]
+ def stripRepoPath(self, path, prefix):
+ if self.keepRepoPath:
+ prefix = re.sub("^(//[^/]+/).*", r'\1', prefix)
+
+ return path[len(prefix):]
def splitFilesIntoBranches(self, commit):
branches = {}
file["type"] = commit["type%s" % fnum]
fnum = fnum + 1
- relPath = self.stripRepoPath(path)
+ relPath = self.stripRepoPath(path, self.depotPath)
for branch in self.knownBranches.keys():
continue
rev = file["rev"]
depotPath = path + "#" + rev
- relPath = path[len(branchPrefix):]
+ relPath = self.stripRepoPath(path, branchPrefix)
action = file["action"]
if file["type"] == "apple":