summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 68ed351)
raw | patch | inline | side by side (parent: 68ed351)
author | Simon Hausmann <simon@lst.de> | |
Sun, 8 Apr 2007 08:08:26 +0000 (10:08 +0200) | ||
committer | Simon Hausmann <simon@lst.de> | |
Sun, 8 Apr 2007 08:08:26 +0000 (10:08 +0200) |
Signed-off-by: Simon Hausmann <simon@lst.de>
contrib/fast-import/git-p4 | patch | blob | history | |
contrib/fast-import/git-p4.txt | patch | blob | history |
index 65660e135169b83b5cbb3f7f9f4f0f067baba5e8..0a22d9a2e47e9f56b1f1cd0de92dbd99001b8ae0 100755 (executable)
self.detectBranches = False
self.detectLabels = False
self.changesFile = ""
+ self.tagLastChange = True
def p4File(self, depotPath):
return os.popen("p4 print -q \"%s\"" % depotPath, "rb").read()
self.globalPrefix = ""
self.changeRange = ""
self.initialParent = ""
- self.tagLastChange = True
if len(self.branch) == 0:
self.branch = "p4"
system("git diff-tree --stat --summary -M %s HEAD" % oldHead)
return True
+class P4Clone(P4Sync):
+ def __init__(self):
+ P4Sync.__init__(self)
+ self.description = "Creates a new git repository and imports from Perforce into it"
+ self.usage = "usage: %prog [options] //depot/path[@revRange] [directory]"
+ self.needsGit = False
+ self.tagLastChange = False
+
+ def run(self, args):
+ if len(args) < 1:
+ return False
+ depotPath = args[0]
+ dir = ""
+ if len(args) == 2:
+ dir = args[1]
+ elif len(args) > 2:
+ return False
+
+ if not depotPath.startswith("//"):
+ return False
+
+ if len(dir) == 0:
+ dir = depotPath
+ atPos = dir.rfind("@")
+ if atPos != -1:
+ dir = dir[0:atPos]
+ hashPos = dir.rfind("#")
+ if hashPos != -1:
+ dir = dir[0:hashPos]
+
+ if dir.endswith("..."):
+ dir = dir[:-3]
+
+ if dir.endswith("/"):
+ dir = dir[:-1]
+
+ slashPos = dir.rfind("/")
+ if slashPos != -1:
+ dir = dir[slashPos + 1:]
+
+ print "Importing from %s into %s" % (depotPath, dir)
+ os.makedirs(dir)
+ os.chdir(dir)
+ system("git init")
+ if not P4Sync.run(self, [depotPath]):
+ return False
+ os.wait()
+ if self.branch != "master":
+ system("git branch master p4")
+ system("git checkout -f")
+ return True
+
class HelpFormatter(optparse.IndentedHelpFormatter):
def __init__(self):
optparse.IndentedHelpFormatter.__init__(self)
"clean-tags" : P4CleanTags(),
"submit" : P4Submit(),
"sync" : P4Sync(),
- "rebase" : P4Rebase()
+ "rebase" : P4Rebase(),
+ "clone" : P4Clone()
}
if len(sys.argv[1:]) == 0:
index 5f7251c2d6d626da9d2e16771df5ab6f486895d9..99ae85bd7ba425a15c55ffb3db651a3698d7176d 100644 (file)
Importing
=========
-The procedure is simple:
+You can simply start with
+
+ git-p4 clone //depot/path/project
+
+or
+
+ git-p4 clone //depot/path/project myproject
+
+This will create an empty git repository in a subdirectory called "project" (or
+"myproject" with the second command), import the head revision from the
+specified perforce path into a git "p4" branch, create a master branch off it
+and check it out. If you want the entire history (not just the head revision) then
+you can simply append a "@all" to the depot path:
+
+ git-p4 clone //depot/project/main@all myproject
+
+
+
+If you want more control you can also use the git-p4 sync command directly:
mkdir repo-git
cd repo-git
Support for Perforce integrations is still work in progress. Don't bother
trying it unless you want to hack on it :)
+For convenience there's also the git-p4 clone command that works similar to
+git-clone and combines the creation of the git repository with the the initial
+import and the branch setup
Incremental Imports
===================