Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
李少辉-开发者
git
提交
b25b2065
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,发现更多精彩内容 >>
提交
b25b2065
编写于
5月 23, 2007
作者:
H
Han-Wen Nienhuys
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
use strip() iso. slicing for removing \n
Signed-off-by:
N
Han-Wen Nienhuys
<
hanwen@google.com
>
上级
b76f0565
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
16 addition
and
14 deletion
+16
-14
contrib/fast-import/git-p4
contrib/fast-import/git-p4
+16
-14
未找到文件。
contrib/fast-import/git-p4
浏览文件 @
b25b2065
...
@@ -15,7 +15,7 @@ import re
...
@@ -15,7 +15,7 @@ import re
from
sets
import
Set
;
from
sets
import
Set
;
gitdir
=
os
.
environ
.
get
(
"GIT_DIR"
,
""
)
gitdir
=
os
.
environ
.
get
(
"GIT_DIR"
,
""
)
silent
=
Fals
e
silent
=
Tru
e
def
write_pipe
(
c
,
str
):
def
write_pipe
(
c
,
str
):
if
not
silent
:
if
not
silent
:
...
@@ -109,7 +109,7 @@ def die(msg):
...
@@ -109,7 +109,7 @@ def die(msg):
sys
.
exit
(
1
)
sys
.
exit
(
1
)
def
currentGitBranch
():
def
currentGitBranch
():
return
read_pipe
(
"git name-rev HEAD"
).
split
(
" "
)[
1
]
[:
-
1
]
return
read_pipe
(
"git name-rev HEAD"
).
split
(
" "
)[
1
]
.
strip
()
def
isValidGitDir
(
path
):
def
isValidGitDir
(
path
):
if
os
.
path
.
exists
(
path
+
"/HEAD"
)
and
os
.
path
.
exists
(
path
+
"/refs"
)
and
os
.
path
.
exists
(
path
+
"/objects"
):
if
os
.
path
.
exists
(
path
+
"/HEAD"
)
and
os
.
path
.
exists
(
path
+
"/refs"
)
and
os
.
path
.
exists
(
path
+
"/objects"
):
...
@@ -117,7 +117,7 @@ def isValidGitDir(path):
...
@@ -117,7 +117,7 @@ def isValidGitDir(path):
return
False
return
False
def
parseRevision
(
ref
):
def
parseRevision
(
ref
):
return
read_pipe
(
"git rev-parse %s"
%
ref
)
[:
-
1
]
return
read_pipe
(
"git rev-parse %s"
%
ref
)
.
strip
()
def
extractLogMessageFromGitCommit
(
commit
):
def
extractLogMessageFromGitCommit
(
commit
):
logMessage
=
""
logMessage
=
""
...
@@ -205,7 +205,8 @@ class P4RollBack(Command):
...
@@ -205,7 +205,8 @@ class P4RollBack(Command):
for
line
in
lines
:
for
line
in
lines
:
if
self
.
rollbackLocalBranches
or
(
line
.
startswith
(
"p4/"
)
and
line
!=
"p4/HEAD
\n
"
):
if
self
.
rollbackLocalBranches
or
(
line
.
startswith
(
"p4/"
)
and
line
!=
"p4/HEAD
\n
"
):
ref
=
refPrefix
+
line
[:
-
1
]
line
=
line
.
strip
()
ref
=
refPrefix
+
line
log
=
extractLogMessageFromGitCommit
(
ref
)
log
=
extractLogMessageFromGitCommit
(
ref
)
depotPath
,
change
=
extractDepotPathAndChangeFromGitLog
(
log
)
depotPath
,
change
=
extractDepotPathAndChangeFromGitLog
(
log
)
changed
=
False
changed
=
False
...
@@ -271,7 +272,7 @@ class P4Submit(Command):
...
@@ -271,7 +272,7 @@ class P4Submit(Command):
commits
.
append
(
"0"
)
commits
.
append
(
"0"
)
else
:
else
:
for
line
in
read_pipe_lines
(
"git rev-list --no-merges %s..%s"
%
(
self
.
origin
,
self
.
master
)):
for
line
in
read_pipe_lines
(
"git rev-list --no-merges %s..%s"
%
(
self
.
origin
,
self
.
master
)):
commits
.
append
(
line
[:
-
1
]
)
commits
.
append
(
line
.
strip
()
)
commits
.
reverse
()
commits
.
reverse
()
self
.
config
[
"commits"
]
=
commits
self
.
config
[
"commits"
]
=
commits
...
@@ -372,7 +373,7 @@ class P4Submit(Command):
...
@@ -372,7 +373,7 @@ class P4Submit(Command):
if
not
self
.
directSubmit
:
if
not
self
.
directSubmit
:
logMessage
=
extractLogMessageFromGitCommit
(
id
)
logMessage
=
extractLogMessageFromGitCommit
(
id
)
logMessage
=
logMessage
.
replace
(
"
\n
"
,
"
\n\t
"
)
logMessage
=
logMessage
.
replace
(
"
\n
"
,
"
\n\t
"
)
logMessage
=
logMessage
[:
-
1
]
logMessage
=
logMessage
.
strip
()
template
=
read_pipe
(
"p4 change -o"
)
template
=
read_pipe
(
"p4 change -o"
)
...
@@ -513,7 +514,7 @@ class P4Submit(Command):
...
@@ -513,7 +514,7 @@ class P4Submit(Command):
if
len
(
self
.
substFile
)
>
0
:
if
len
(
self
.
substFile
)
>
0
:
for
line
in
open
(
self
.
substFile
,
"r"
).
readlines
():
for
line
in
open
(
self
.
substFile
,
"r"
).
readlines
():
tokens
=
line
[:
-
1
]
.
split
(
"="
)
tokens
=
line
.
strip
()
.
split
(
"="
)
self
.
logSubstitutions
[
tokens
[
0
]]
=
tokens
[
1
]
self
.
logSubstitutions
[
tokens
[
0
]]
=
tokens
[
1
]
self
.
check
()
self
.
check
()
...
@@ -784,7 +785,7 @@ class P4Sync(Command):
...
@@ -784,7 +785,7 @@ class P4Sync(Command):
lines
=
cache
.
readlines
()
lines
=
cache
.
readlines
()
cache
.
close
()
cache
.
close
()
for
line
in
lines
:
for
line
in
lines
:
entry
=
line
[:
-
1
]
.
split
(
"
\t
"
)
entry
=
line
.
strip
()
.
split
(
"
\t
"
)
self
.
users
[
entry
[
0
]]
=
entry
[
1
]
self
.
users
[
entry
[
0
]]
=
entry
[
1
]
except
IOError
:
except
IOError
:
self
.
getUserMapFromPerforceServer
()
self
.
getUserMapFromPerforceServer
()
...
@@ -814,7 +815,7 @@ class P4Sync(Command):
...
@@ -814,7 +815,7 @@ class P4Sync(Command):
print
"Label changes: %s"
%
self
.
labels
.
keys
()
print
"Label changes: %s"
%
self
.
labels
.
keys
()
def
getBranchMapping
(
self
):
def
getBranchMapping
(
self
):
self
.
projectName
=
self
.
depotPath
[
self
.
depotPath
[:
-
1
]
.
rfind
(
"/"
)
+
1
:]
self
.
projectName
=
self
.
depotPath
[
self
.
depotPath
.
strip
()
.
rfind
(
"/"
)
+
1
:]
for
info
in
p4CmdList
(
"branches"
):
for
info
in
p4CmdList
(
"branches"
):
details
=
p4Cmd
(
"branch -o %s"
%
info
[
"branch"
])
details
=
p4Cmd
(
"branch -o %s"
%
info
[
"branch"
])
...
@@ -848,6 +849,7 @@ class P4Sync(Command):
...
@@ -848,6 +849,7 @@ class P4Sync(Command):
lie
=
line
.
strip
()
lie
=
line
.
strip
()
if
self
.
importIntoRemotes
and
((
not
line
.
startswith
(
"p4/"
))
or
line
==
"p4/HEAD
\n
"
):
if
self
.
importIntoRemotes
and
((
not
line
.
startswith
(
"p4/"
))
or
line
==
"p4/HEAD
\n
"
):
continue
continue
if
self
.
importIntoRemotes
:
if
self
.
importIntoRemotes
:
# strip off p4
# strip off p4
branch
=
re
.
sub
(
"^p4/"
,
""
,
line
)
branch
=
re
.
sub
(
"^p4/"
,
""
,
line
)
...
@@ -966,7 +968,7 @@ class P4Sync(Command):
...
@@ -966,7 +968,7 @@ class P4Sync(Command):
self
.
branch
=
"refs/heads/"
+
self
.
branch
self
.
branch
=
"refs/heads/"
+
self
.
branch
if
len
(
self
.
depotPath
)
!=
0
:
if
len
(
self
.
depotPath
)
!=
0
:
self
.
depotPath
=
self
.
depotPath
[:
-
1
]
self
.
depotPath
=
self
.
depotPath
.
strip
()
if
len
(
args
)
==
0
and
len
(
self
.
depotPath
)
!=
0
:
if
len
(
args
)
==
0
and
len
(
self
.
depotPath
)
!=
0
:
if
not
self
.
silent
:
if
not
self
.
silent
:
...
@@ -1184,7 +1186,7 @@ class P4Rebase(Command):
...
@@ -1184,7 +1186,7 @@ class P4Rebase(Command):
sync
=
P4Sync
()
sync
=
P4Sync
()
sync
.
run
([])
sync
.
run
([])
print
"Rebasing the current branch"
print
"Rebasing the current branch"
oldHead
=
read_pipe
(
"git rev-parse HEAD"
)
[:
-
1
]
oldHead
=
read_pipe
(
"git rev-parse HEAD"
)
.
strip
()
system
(
"git rebase p4"
)
system
(
"git rebase p4"
)
system
(
"git diff-tree --stat --summary -M %s HEAD"
%
oldHead
)
system
(
"git diff-tree --stat --summary -M %s HEAD"
%
oldHead
)
return
True
return
True
...
@@ -1217,7 +1219,7 @@ class P4Clone(P4Sync):
...
@@ -1217,7 +1219,7 @@ class P4Clone(P4Sync):
depotDir
=
re
.
sub
(
r
"/$"
,
""
,
depotDir
)
depotDir
=
re
.
sub
(
r
"/$"
,
""
,
depotDir
)
if
not
destination
:
if
not
destination
:
destination
=
os
.
path
.
split
(
depotDir
)[
-
1
]
destination
=
os
.
path
.
split
(
depotDir
)[
1
]
print
"Importing from %s into %s"
%
(
depotPath
,
destination
)
print
"Importing from %s into %s"
%
(
depotPath
,
destination
)
os
.
makedirs
(
destination
)
os
.
makedirs
(
destination
)
...
@@ -1295,9 +1297,9 @@ if cmd.needsGit:
...
@@ -1295,9 +1297,9 @@ if cmd.needsGit:
if
len
(
gitdir
)
==
0
:
if
len
(
gitdir
)
==
0
:
gitdir
=
".git"
gitdir
=
".git"
if
not
isValidGitDir
(
gitdir
):
if
not
isValidGitDir
(
gitdir
):
gitdir
=
read_pipe
(
"git rev-parse --git-dir"
)
[:
-
1
]
gitdir
=
read_pipe
(
"git rev-parse --git-dir"
)
.
strip
()
if
os
.
path
.
exists
(
gitdir
):
if
os
.
path
.
exists
(
gitdir
):
cdup
=
read_pipe
(
"git rev-parse --show-cdup"
)
[:
-
1
];
cdup
=
read_pipe
(
"git rev-parse --show-cdup"
)
.
strip
()
if
len
(
cdup
)
>
0
:
if
len
(
cdup
)
>
0
:
os
.
chdir
(
cdup
);
os
.
chdir
(
cdup
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录