@matheusbsbs / matheus-bagliano / commits / 4c750c0d8b
Fork 0

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 <simon@lst.de>

Simon Hausmann committed Feb 19, 2008 at 09:37 UTC 4c750c0d8bfd7e75b86d660def012bff17d2bf8e
1 file changed +10 -41
contrib/fast-import/git-p4
+10 -41
@@ -464,18 +464,13 @@ class P4Submit(Command):
464 def __init__(self):
465 Command.__init__(self)
466 self.options = [
467 - optparse.make_option("--continue", action="store_false", dest="firstTime"),
467 optparse.make_option("--verbose", dest="verbose", action="store_true"),
468 optparse.make_option("--origin", dest="origin"),
470 - optparse.make_option("--reset", action="store_true", dest="reset"),
469 optparse.make_option("-M", dest="detectRename", action="store_true"),
470 ]
471 self.description = "Submit changes from git to the perforce depot."
472 self.usage += " [name of git branch to submit into perforce depot]"
475 - self.firstTime = True
476 - self.reset = False
473 self.interactive = True
478 - self.firstTime = True
474 self.origin = ""
475 self.detectRename = False
476 self.verbose = False
@@ -485,19 +480,6 @@ class P4Submit(Command):
480 if len(p4CmdList("opened ...")) > 0:
481 die("You have files opened with perforce! Close them before starting the sync.")
482
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 -
483 # replaces everything between 'Description:' and the next P4 submit template field with the
484 # commit message
485 def prepareLogMessage(self, template, message):
@@ -723,42 +705,29 @@ class P4Submit(Command):
705 print "Syncronizing p4 checkout..."
706 system("p4 sync ...")
707
726 - if self.reset:
727 - self.firstTime = True
728 -
708 self.check()
730 - self.configFile = self.gitdir + "/p4-git-sync.cfg"
731 - self.config = shelve.open(self.configFile, writeback=True)
709
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()
714
715 while len(commits) > 0:
739 - self.firstTime = False
716 commit = commits[0]
717 commits = commits[1:]
742 - self.config["commits"] = commits
718 self.applyCommit(commit)
719 if not self.interactive:
720 break
721
747 - self.config.close()
748 -
722 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)
725
756 - sync = P4Sync()
757 - sync.run([])
726 + sync = P4Sync()
727 + sync.run([])
728
759 - rebase = P4Rebase()
760 - rebase.rebase()
761 - os.remove(self.configFile)
729 + rebase = P4Rebase()
730 + rebase.rebase()
731
732 return True
733