Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
git
提交
179caebf
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,发现更多精彩内容 >>
提交
179caebf
编写于
3月 22, 2007
作者:
S
Simon Hausmann
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Brand new smart incremental import that doesn't need tags or git repo-config :)
Signed-off-by:
N
Simon Hausmann
<
simon@lst.de
>
上级
569d1bd4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
33 addition
and
11 deletion
+33
-11
contrib/fast-import/git-p4
contrib/fast-import/git-p4
+31
-7
contrib/fast-import/git-p4.txt
contrib/fast-import/git-p4.txt
+2
-4
未找到文件。
contrib/fast-import/git-p4
浏览文件 @
179caebf
...
...
@@ -84,7 +84,9 @@ def extractDepotPathAndChangeFromGitLog(log):
return
values
.
get
(
"depot-path"
),
values
.
get
(
"change"
)
def
gitBranchExists
(
branch
):
return
os
.
system
(
"git-rev-parse %s 2>/dev/null >/dev/null"
)
==
0
if
os
.
system
(
"git-rev-parse %s 2>/dev/null >/dev/null"
%
branch
)
==
0
:
return
True
return
False
class
Command
:
def
__init__
(
self
):
...
...
@@ -706,17 +708,40 @@ class GitSync(Command):
self
.
users
[
output
[
"User"
]]
=
output
[
"FullName"
]
+
" <"
+
output
[
"Email"
]
+
">"
def
run
(
self
,
args
):
self
.
globalPrefix
=
""
self
.
changeRange
=
""
self
.
initialParent
=
""
self
.
tagLastChange
=
True
if
len
(
self
.
branch
)
==
0
:
self
.
branch
=
"p4"
if
len
(
args
)
==
0
:
if
not
gitBranchExists
(
self
.
branch
)
and
gitBranchExists
(
"origin"
):
if
not
self
.
silent
:
print
"Creating %s branch in git repository based on origin"
%
self
.
branch
system
(
"git branch %s origin"
%
self
.
branch
)
[
self
.
previousDepotPath
,
p4Change
]
=
extractDepotPathAndChangeFromGitLog
(
extractLogMessageFromGitCommit
(
self
.
branch
))
if
len
(
self
.
previousDepotPath
)
>
0
and
len
(
p4Change
)
>
0
:
p4Change
=
int
(
p4Change
)
+
1
self
.
globalPrefix
=
self
.
previousDepotPath
self
.
changeRange
=
"@%s,#head"
%
p4Change
self
.
initialParent
=
self
.
branch
self
.
tagLastChange
=
False
if
not
self
.
silent
:
print
"Performing incremental import into %s git branch"
%
self
.
branch
self
.
branch
=
"refs/heads/"
+
self
.
branch
self
.
globalPrefix
=
self
.
previousDepotPath
=
os
.
popen
(
"git-repo-config --get p4.depotpath"
).
read
()
if
len
(
self
.
globalPrefix
)
==
0
:
self
.
globalPrefix
=
self
.
previousDepotPath
=
os
.
popen
(
"git-repo-config --get p4.depotpath"
).
read
()
if
len
(
self
.
globalPrefix
)
!=
0
:
self
.
globalPrefix
=
self
.
globalPrefix
[:
-
1
]
if
len
(
args
)
==
0
and
len
(
self
.
globalPrefix
)
!=
0
:
if
not
self
.
silent
:
print
"
[using previously specified depot path %s]
"
%
self
.
globalPrefix
print
"
Depot path: %s
"
%
self
.
globalPrefix
elif
len
(
args
)
!=
1
:
return
False
else
:
...
...
@@ -725,10 +750,8 @@ class GitSync(Command):
sys
.
exit
(
1
)
self
.
globalPrefix
=
args
[
0
]
self
.
changeRange
=
""
self
.
revision
=
""
self
.
users
=
{}
self
.
initialParent
=
""
self
.
lastChange
=
0
self
.
initialTag
=
""
...
...
@@ -890,8 +913,9 @@ class GitSync(Command):
if
not
self
.
silent
:
print
""
self
.
gitStream
.
write
(
"reset refs/tags/p4/%s
\n
"
%
self
.
lastChange
)
self
.
gitStream
.
write
(
"from %s
\n\n
"
%
self
.
branch
);
if
self
.
tagLastChange
:
self
.
gitStream
.
write
(
"reset refs/tags/p4/%s
\n
"
%
self
.
lastChange
)
self
.
gitStream
.
write
(
"from %s
\n\n
"
%
self
.
branch
);
self
.
gitStream
.
close
()
...
...
contrib/fast-import/git-p4.txt
浏览文件 @
179caebf
...
...
@@ -38,11 +38,9 @@ Incremental Imports
After an initial import you can easily synchronize your git repository with
newer changes from the Perforce depot by just calling
git-p4
.p4
sync
git-p4 sync
in your git repository. git-p4 stores the depot path of the original import in
the .git/config file and remembers the last imported p4 revision as a git tag
called p4/<changenum> .
in your git repository.
It is recommended to run 'git repack -a -d -f' from time to time when using
incremental imports to optimally combine the individual git packs that each
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录