Added git-p4 rebase convenience
Signed-off-by: Simon Hausmann <simon@lst.de>
Simon Hausmann committed
Apr 7, 2007 at 23:46 UTC
01ce1fe9676e3f714f3a2d068bf8cfe021f4073c
2 files changed
+33
-3
contrib/fast-import/git-p4
+20
-2
@@ -804,7 +804,11 @@ class P4Sync(Command):
804
def getLabels(self):
805
self.labels = {}
806
807
- for output in p4CmdList("labels %s..." % self.globalPrefix):
807
+ l = p4CmdList("labels %s..." % self.globalPrefix)
808
+ if len(l) > 0:
809
+ print "Finding files belonging to labels in %s" % self.globalPrefix
810
+
811
+ for output in l:
812
label = output["label"]
813
revisions = {}
814
newestChange = 0
@@ -1039,6 +1043,19 @@ class P4Sync(Command):
1043
1044
return True
1045
1046
+class P4Rebase(Command):
1047
+ def __init__(self):
1048
+ Command.__init__(self)
1049
+ self.options = [ ]
1050
+ self.description = "Fetches the latest revision from perforce and rebases the current work (branch) against it"
1051
+
1052
+ def run(self, args):
1053
+ sync = P4Sync()
1054
+ sync.run([])
1055
+ print "Rebasing the current branch"
1056
+ system("git rebase p4")
1057
+ return True
1058
+
1059
class HelpFormatter(optparse.IndentedHelpFormatter):
1060
def __init__(self):
1061
optparse.IndentedHelpFormatter.__init__(self)
@@ -1061,7 +1078,8 @@ commands = {
1078
"debug" : P4Debug(),
1079
"clean-tags" : P4CleanTags(),
1080
"submit" : P4Submit(),
1064
- "sync" : P4Sync()
1081
+ "sync" : P4Sync(),
1082
+ "rebase" : P4Rebase()
1083
}
1084
1085
if len(sys.argv[1:]) == 0:
contrib/fast-import/git-p4.txt
+13
-1
@@ -40,12 +40,24 @@ newer changes from the Perforce depot by just calling
40
41
git-p4 sync
42
43
-in your git repository.
43
+in your git repository. By default the "p4" branch is updated.
44
45
It is recommended to run 'git repack -a -d -f' from time to time when using
46
incremental imports to optimally combine the individual git packs that each
47
incremental import creates through the use of git-fast-import.
48
49
+Updating
50
+========
51
+
52
+A common working pattern is to fetch the latest changes from the Perforce depot
53
+and merge them with local uncommitted changes. The recommended way is to use
54
+git's rebase mechanism to preserve linear history. git-p4 provides a convenient
55
+
56
+ git-p4 rebase
57
+
58
+command that calls git-p4 sync followed by git rebase to rebase the current
59
+working branch.
60
+
61
Submitting
62
==========
63