@matheusbsbs / matheus-bagliano / commits / 01265103fe
Fork 0

Make --with-origin the default for syncing.

Signed-off-by: Simon Hausmann <shausman@trolltech.com>

Simon Hausmann committed May 25, 2007 at 10:36 UTC 01265103fe3966abd720ebb0bba1882a5701f327
2 files changed +13 -17
contrib/fast-import/git-p4
+10 -6
@@ -118,6 +118,9 @@ def gitBranchExists(branch):
118 proc = subprocess.Popen(["git", "rev-parse", branch], stderr=subprocess.PIPE, stdout=subprocess.PIPE);
119 return proc.wait() == 0;
120
121 +def gitConfig(key):
122 + return mypopen("git config %s" % key).read()[:-1]
123 +
124 class Command:
125 def __init__(self):
126 self.usage = "usage: %prog [options]"
@@ -514,7 +517,6 @@ class P4Sync(Command):
517 optparse.make_option("--changesfile", dest="changesFile"),
518 optparse.make_option("--silent", dest="silent", action="store_true"),
519 optparse.make_option("--detect-labels", dest="detectLabels", action="store_true"),
517 - optparse.make_option("--with-origin", dest="syncWithOrigin", action="store_true"),
520 optparse.make_option("--verbose", dest="verbose", action="store_true"),
521 optparse.make_option("--import-local", dest="importIntoRemotes", action="store_false"),
522 optparse.make_option("--max-changes", dest="maxChanges")
@@ -536,12 +538,15 @@ class P4Sync(Command):
538 self.detectBranches = False
539 self.detectLabels = False
540 self.changesFile = ""
539 - self.syncWithOrigin = False
541 + self.syncWithOrigin = True
542 self.verbose = False
543 self.importIntoRemotes = True
544 self.maxChanges = ""
545 self.isWindows = (platform.system() == "Windows")
546
547 + if gitConfig("git-p4.syncFromOrigin") == "false":
548 + self.syncWithOrigin = False
549 +
550 def p4File(self, depotPath):
551 return os.popen("p4 print -q \"%s\"" % depotPath, "rb").read()
552
@@ -847,7 +852,8 @@ class P4Sync(Command):
852
853 if self.syncWithOrigin:
854 if gitBranchExists("origin"):
850 - print "Syncing with origin first as requested by calling git fetch origin"
855 + if not self.silent:
856 + print "Syncing with origin first by calling git fetch origin"
857 system("git fetch origin")
858
859 createP4HeadRef = False;
@@ -1116,13 +1122,11 @@ class P4Sync(Command):
1122 class P4Rebase(Command):
1123 def __init__(self):
1124 Command.__init__(self)
1119 - self.options = [ optparse.make_option("--with-origin", dest="syncWithOrigin", action="store_true") ]
1125 + self.options = [ ]
1126 self.description = "Fetches the latest revision from perforce and rebases the current work (branch) against it"
1121 - self.syncWithOrigin = False
1127
1128 def run(self, args):
1129 sync = P4Sync()
1125 - sync.syncWithOrigin = self.syncWithOrigin
1130 sync.run([])
1131 print "Rebasing the current branch"
1132 oldHead = mypopen("git rev-parse HEAD").read()[:-1]
contrib/fast-import/git-p4.txt
+3 -11
@@ -70,18 +70,10 @@ repository can be used to clone the working repository from and one would
70 import from Perforce directly after cloning using git-p4. If the connection to
71 the Perforce server is slow and the working repository hasn't been synced for a
72 while it may be desirable to fetch changes from the origin git repository using
73 -the efficient git protocol. git-p4 supports this through
73 +the efficient git protocol. git-p4 supports this setup by calling "git fetch origin"
74 +by default if there is an origin branch. You can disable this using
75
75 - git-p4 sync --with-origin
76 -
77 -or
78 -
79 - git-p4 rebase --with-origin
80 -
81 -In that case "git fetch origin" is called and if it turns out that the origin
82 -branch is newer than the git "p4" import branch then the latter is updated from
83 -the former and the direct import from Perforce is resumed, which will result in
84 -fewer changes to be imported using the slower perforce connection.
76 + git config git-p4.syncFromOrigin false
77
78 Updating
79 ========