Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
Cleanups
author
Han-Wen Nienhuys
<hanwen@google.com>
Wed, 23 May 2007 19:46:29 +0000
(16:46 -0300)
committer
Simon Hausmann
<simon@lst.de>
Mon, 28 May 2007 12:22:53 +0000
(14:22 +0200)
- don't use dir (python builtin)
- use re for munging depotPath into destination
Signed-off-by: Han-Wen Nienhuys <hanwen@google.com>
contrib/fast-import/git-p4
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
a3c55c0
)
diff --git
a/contrib/fast-import/git-p4
b/contrib/fast-import/git-p4
index aeefadcd66a25f88069a659ec4445bff87444453..910e4ff3cd76c39623323fd35b6763873443ca86 100755
(executable)
--- a/
contrib/fast-import/git-p4
+++ b/
contrib/fast-import/git-p4
@@
-10,6
+10,7
@@
import optparse, sys, os, marshal, popen2, subprocess, shelve
import tempfile, getopt, sha, os.path, time, platform
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", "")
from sets import Set;
gitdir = os.environ.get("GIT_DIR", "")
@@
-842,6
+843,7
@@
class P4Sync(Command):
self.changeRange = ""
self.initialParent = ""
self.previousDepotPath = ""
self.changeRange = ""
self.initialParent = ""
self.previousDepotPath = ""
+
# map from branch depot path to parent branch
self.knownBranches = {}
self.initialParents = {}
# map from branch depot path to parent branch
self.knownBranches = {}
self.initialParents = {}
@@
-1145,37
+1147,26
@@
class P4Clone(P4Sync):
if len(args) < 1:
return False
depotPath = args[0]
if len(args) < 1:
return False
depotPath = args[0]
- d
ir
= ""
+ d
estination
= ""
if len(args) == 2:
if len(args) == 2:
- d
ir
= args[1]
+ d
estination
= args[1]
elif len(args) > 2:
return False
if not depotPath.startswith("//"):
return False
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]
+ depotDir = re.sub("(@[^@]*)$", "", depotPath)
+ depotDir = re.sub("(#[^#]*)$", "", depotDir)
+ depotDir = re.sub(r"\.\.\.$,", "", depotDir)
+ depotDir = re.sub(r"/$", "", depotDir)
- slashPos = dir.rfind("/")
- if slashPos != -1:
- dir = dir[slashPos + 1:]
+ if not destination:
+ destination = os.path.split(depotDir)[-1]
- print "Importing from %s into %s" % (depotPath, d
ir
)
- os.makedirs(d
ir
)
- os.chdir(d
ir
)
+ print "Importing from %s into %s" % (depotPath, d
estination
)
+ os.makedirs(d
estination
)
+ os.chdir(d
estination
)
system("git init")
gitdir = os.getcwd() + "/.git"
if not P4Sync.run(self, [depotPath]):
system("git init")
gitdir = os.getcwd() + "/.git"
if not P4Sync.run(self, [depotPath]):