Skip to content

Commit 4c750c0

Browse files
committed
git-p4: git-p4 submit cleanups.
Removed storing the list of commits in a configuration file. We only need the list of commits at run-time. Signed-off-by: Simon Hausmann <[email protected]>
1 parent 0e36f2d commit 4c750c0

File tree

1 file changed

+10
-41
lines changed

1 file changed

+10
-41
lines changed

contrib/fast-import/git-p4

Lines changed: 10 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -464,18 +464,13 @@ class P4Submit(Command):
464464
def __init__(self):
465465
Command.__init__(self)
466466
self.options = [
467-
optparse.make_option("--continue", action="store_false", dest="firstTime"),
468467
optparse.make_option("--verbose", dest="verbose", action="store_true"),
469468
optparse.make_option("--origin", dest="origin"),
470-
optparse.make_option("--reset", action="store_true", dest="reset"),
471469
optparse.make_option("-M", dest="detectRename", action="store_true"),
472470
]
473471
self.description = "Submit changes from git to the perforce depot."
474472
self.usage += " [name of git branch to submit into perforce depot]"
475-
self.firstTime = True
476-
self.reset = False
477473
self.interactive = True
478-
self.firstTime = True
479474
self.origin = ""
480475
self.detectRename = False
481476
self.verbose = False
@@ -485,19 +480,6 @@ class P4Submit(Command):
485480
if len(p4CmdList("opened ...")) > 0:
486481
die("You have files opened with perforce! Close them before starting the sync.")
487482

488-
def start(self):
489-
if len(self.config) > 0 and not self.reset:
490-
die("Cannot start sync. Previous sync config found at %s\n"
491-
"If you want to start submitting again from scratch "
492-
"maybe you want to call git-p4 submit --reset" % self.configFile)
493-
494-
commits = []
495-
for line in read_pipe_lines("git rev-list --no-merges %s..%s" % (self.origin, self.master)):
496-
commits.append(line.strip())
497-
commits.reverse()
498-
499-
self.config["commits"] = commits
500-
501483
# replaces everything between 'Description:' and the next P4 submit template field with the
502484
# commit message
503485
def prepareLogMessage(self, template, message):
@@ -723,42 +705,29 @@ class P4Submit(Command):
723705
print "Syncronizing p4 checkout..."
724706
system("p4 sync ...")
725707

726-
if self.reset:
727-
self.firstTime = True
728-
729708
self.check()
730-
self.configFile = self.gitdir + "/p4-git-sync.cfg"
731-
self.config = shelve.open(self.configFile, writeback=True)
732709

733-
if self.firstTime:
734-
self.start()
735-
736-
commits = self.config.get("commits", [])
710+
commits = []
711+
for line in read_pipe_lines("git rev-list --no-merges %s..%s" % (self.origin, self.master)):
712+
commits.append(line.strip())
713+
commits.reverse()
737714

738715
while len(commits) > 0:
739-
self.firstTime = False
740716
commit = commits[0]
741717
commits = commits[1:]
742-
self.config["commits"] = commits
743718
self.applyCommit(commit)
744719
if not self.interactive:
745720
break
746721

747-
self.config.close()
748-
749722
if len(commits) == 0:
750-
if self.firstTime:
751-
print "No changes found to apply between %s and current HEAD" % self.origin
752-
else:
753-
print "All changes applied!"
754-
os.chdir(self.oldWorkingDirectory)
723+
print "All changes applied!"
724+
os.chdir(self.oldWorkingDirectory)
755725

756-
sync = P4Sync()
757-
sync.run([])
726+
sync = P4Sync()
727+
sync.run([])
758728

759-
rebase = P4Rebase()
760-
rebase.rebase()
761-
os.remove(self.configFile)
729+
rebase = P4Rebase()
730+
rebase.rebase()
762731

763732
return True
764733

0 commit comments

Comments
 (0)