Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
git
提交
f9a3a4f7
G
git
项目概览
李少辉-开发者
/
git
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
G
git
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
f9a3a4f7
编写于
4月 08, 2007
作者:
S
Simon Hausmann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added git-p4 clone convenience command
Signed-off-by:
N
Simon Hausmann
<
simon@lst.de
>
上级
68ed351a
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
77 addition
and
3 deletion
+77
-3
contrib/fast-import/git-p4
contrib/fast-import/git-p4
+55
-2
contrib/fast-import/git-p4.txt
contrib/fast-import/git-p4.txt
+22
-1
未找到文件。
contrib/fast-import/git-p4
浏览文件 @
f9a3a4f7
...
...
@@ -440,6 +440,7 @@ class P4Sync(Command):
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
()
...
...
@@ -826,7 +827,6 @@ class P4Sync(Command):
self
.
globalPrefix
=
""
self
.
changeRange
=
""
self
.
initialParent
=
""
self
.
tagLastChange
=
True
if
len
(
self
.
branch
)
==
0
:
self
.
branch
=
"p4"
...
...
@@ -1062,6 +1062,58 @@ class P4Rebase(Command):
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
)
...
...
@@ -1085,7 +1137,8 @@ commands = {
"clean-tags"
:
P4CleanTags
(),
"submit"
:
P4Submit
(),
"sync"
:
P4Sync
(),
"rebase"
:
P4Rebase
()
"rebase"
:
P4Rebase
(),
"clone"
:
P4Clone
()
}
if
len
(
sys
.
argv
[
1
:])
==
0
:
...
...
contrib/fast-import/git-p4.txt
浏览文件 @
f9a3a4f7
...
...
@@ -10,7 +10,25 @@ done using "git-p4 submit".
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
...
...
@@ -31,6 +49,9 @@ a big import. This may take a while.
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
===================
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录