Skip to content

Commit

Permalink
Make --with-origin the default for syncing.
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Hausmann <shausman@trolltech.com>
  • Loading branch information
Simon Hausmann committed May 25, 2007
1 parent 417a7a6 commit 0126510
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 17 deletions.
16 changes: 10 additions & 6 deletions contrib/fast-import/git-p4
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,9 @@ def gitBranchExists(branch):
proc = subprocess.Popen(["git", "rev-parse", branch], stderr=subprocess.PIPE, stdout=subprocess.PIPE);
return proc.wait() == 0;

def gitConfig(key):
return mypopen("git config %s" % key).read()[:-1]

class Command:
def __init__(self):
self.usage = "usage: %prog [options]"
Expand Down Expand Up @@ -514,7 +517,6 @@ class P4Sync(Command):
optparse.make_option("--changesfile", dest="changesFile"),
optparse.make_option("--silent", dest="silent", action="store_true"),
optparse.make_option("--detect-labels", dest="detectLabels", action="store_true"),
optparse.make_option("--with-origin", dest="syncWithOrigin", action="store_true"),
optparse.make_option("--verbose", dest="verbose", action="store_true"),
optparse.make_option("--import-local", dest="importIntoRemotes", action="store_false"),
optparse.make_option("--max-changes", dest="maxChanges")
Expand All @@ -536,12 +538,15 @@ class P4Sync(Command):
self.detectBranches = False
self.detectLabels = False
self.changesFile = ""
self.syncWithOrigin = False
self.syncWithOrigin = True
self.verbose = False
self.importIntoRemotes = True
self.maxChanges = ""
self.isWindows = (platform.system() == "Windows")

if gitConfig("git-p4.syncFromOrigin") == "false":
self.syncWithOrigin = False

def p4File(self, depotPath):
return os.popen("p4 print -q \"%s\"" % depotPath, "rb").read()

Expand Down Expand Up @@ -847,7 +852,8 @@ class P4Sync(Command):

if self.syncWithOrigin:
if gitBranchExists("origin"):
print "Syncing with origin first as requested by calling git fetch origin"
if not self.silent:
print "Syncing with origin first by calling git fetch origin"
system("git fetch origin")

createP4HeadRef = False;
Expand Down Expand Up @@ -1116,13 +1122,11 @@ class P4Sync(Command):
class P4Rebase(Command):
def __init__(self):
Command.__init__(self)
self.options = [ optparse.make_option("--with-origin", dest="syncWithOrigin", action="store_true") ]
self.options = [ ]
self.description = "Fetches the latest revision from perforce and rebases the current work (branch) against it"
self.syncWithOrigin = False

def run(self, args):
sync = P4Sync()
sync.syncWithOrigin = self.syncWithOrigin
sync.run([])
print "Rebasing the current branch"
oldHead = mypopen("git rev-parse HEAD").read()[:-1]
Expand Down
14 changes: 3 additions & 11 deletions contrib/fast-import/git-p4.txt
Original file line number Diff line number Diff line change
Expand Up @@ -70,18 +70,10 @@ repository can be used to clone the working repository from and one would
import from Perforce directly after cloning using git-p4. If the connection to
the Perforce server is slow and the working repository hasn't been synced for a
while it may be desirable to fetch changes from the origin git repository using
the efficient git protocol. git-p4 supports this through
the efficient git protocol. git-p4 supports this setup by calling "git fetch origin"
by default if there is an origin branch. You can disable this using

git-p4 sync --with-origin

or

git-p4 rebase --with-origin

In that case "git fetch origin" is called and if it turns out that the origin
branch is newer than the git "p4" import branch then the latter is updated from
the former and the direct import from Perforce is resumed, which will result in
fewer changes to be imported using the slower perforce connection.
git config git-p4.syncFromOrigin false

Updating
========
Expand Down

0 comments on commit 0126510

Please sign in to comment.