git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Luke Diamand <luke@diamand.org>
To: git@vger.kernel.org
Cc: "Eric Scouten" <eric@scouten.com>,
	"SZEDER Gábor" <szeder.dev@gmail.com>,
	"Merland Romain" <merlorom@yahoo.fr>,
	"Miguel Torroja" <miguel.torroja@gmail.com>,
	"Lars Schneider" <larsxschneider@gmail.com>,
	"Lex Spoon" <lex@lexspoon.org>,
	viniciusalexandre@gmail.com, "Luke Diamand" <luke@diamand.org>
Subject: [PATCHv2 2/6] git-p4: add option to disable syncing of p4/master with p4
Date: Fri,  8 Jun 2018 21:32:44 +0100	[thread overview]
Message-ID: <20180608203248.16311-3-luke@diamand.org> (raw)
In-Reply-To: <20180608203248.16311-2-luke@diamand.org>

Add an option to the git-p4 submit command to disable syncing
with Perforce.

This is useful for the case where a git-p4 mirror has been setup
on a server somewhere, running from (e.g.) cron, and developers
then clone from this. Having the local cloned copy also sync
from Perforce just isn't useful.

Signed-off-by: Luke Diamand <luke@diamand.org>
---
 Documentation/git-p4.txt |  8 ++++++++
 git-p4.py                | 31 ++++++++++++++++++++-----------
 2 files changed, 28 insertions(+), 11 deletions(-)

diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt
index 3d83842e47..f0de3b891b 100644
--- a/Documentation/git-p4.txt
+++ b/Documentation/git-p4.txt
@@ -369,6 +369,11 @@ These options can be used to modify 'git p4 submit' behavior.
     Disable the automatic rebase after all commits have been successfully
     submitted. Can also be set with git-p4.disableRebase.
 
+--disable-p4sync::
+    Disable the automatic sync of p4/master from Perforce after commits have
+    been submitted. Implies --disable-rebase. Can also be set with
+    git-p4.disableP4Sync. Sync with origin/master still goes ahead if possible.
+
 Rebase options
 ~~~~~~~~~~~~~~
 These options can be used to modify 'git p4 rebase' behavior.
@@ -693,6 +698,9 @@ git-p4.conflict::
 git-p4.disableRebase::
     Do not rebase the tree against p4/master following a submit.
 
+git-p4.disableP4Sync::
+    Do not sync p4/master with Perforce following a submit. Implies git-p4.disableRebase.
+
 IMPLEMENTATION DETAILS
 ----------------------
 * Changesets from p4 are imported using Git fast-import.
diff --git a/git-p4.py b/git-p4.py
index 5ab9421af8..b61f47cc61 100755
--- a/git-p4.py
+++ b/git-p4.py
@@ -1368,7 +1368,9 @@ def __init__(self):
                                      help="submit only the specified commit(s), one commit or xxx..xxx"),
                 optparse.make_option("--disable-rebase", dest="disable_rebase", action="store_true",
                                      help="Disable rebase after submit is completed. Can be useful if you "
-                                     "work from a local git branch that is not master")
+                                     "work from a local git branch that is not master"),
+                optparse.make_option("--disable-p4sync", dest="disable_p4sync", action="store_true",
+                                     help="Skip Perforce sync of p4/master after submit or shelve"),
         ]
         self.description = "Submit changes from git to the perforce depot."
         self.usage += " [name of git branch to submit into perforce depot]"
@@ -1380,6 +1382,7 @@ def __init__(self):
         self.update_shelve = list()
         self.commit = ""
         self.disable_rebase = gitConfigBool("git-p4.disableRebase")
+        self.disable_p4sync = gitConfigBool("git-p4.disableP4Sync")
         self.prepare_p4_only = False
         self.conflict_behavior = None
         self.isWindows = (platform.system() == "Windows")
@@ -2240,11 +2243,14 @@ def run(self, args):
             sync = P4Sync()
             if self.branch:
                 sync.branch = self.branch
-            sync.run([])
+            if self.disable_p4sync:
+                sync.sync_origin_only()
+            else:
+                sync.run([])
 
-            if self.disable_rebase is False:
-                rebase = P4Rebase()
-                rebase.rebase()
+                if not self.disable_rebase:
+                    rebase = P4Rebase()
+                    rebase.rebase()
 
         else:
             if len(applied) == 0:
@@ -3324,6 +3330,14 @@ def importChanges(self, changes, shelved=False, origin_revision=0):
                 print self.gitError.read()
                 sys.exit(1)
 
+    def sync_origin_only(self):
+        if self.syncWithOrigin:
+            self.hasOrigin = originP4BranchesExist()
+            if self.hasOrigin:
+                if not self.silent:
+                    print 'Syncing with origin first, using "git fetch origin"'
+                system("git fetch origin")
+
     def importHeadRevision(self, revision):
         print "Doing initial import of %s from revision %s into %s" % (' '.join(self.depotPaths), revision, self.branch)
 
@@ -3402,12 +3416,7 @@ def run(self, args):
         else:
             self.refPrefix = "refs/heads/p4/"
 
-        if self.syncWithOrigin:
-            self.hasOrigin = originP4BranchesExist()
-            if self.hasOrigin:
-                if not self.silent:
-                    print 'Syncing with origin first, using "git fetch origin"'
-                system("git fetch origin")
+        self.sync_origin_only()
 
         branch_arg_given = bool(self.branch)
         if len(self.branch) == 0:
-- 
2.17.0.392.gdeb1a6e9b7


  reply	other threads:[~2018-06-08 20:33 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-08 20:32 [PATCHv2 0/6] git-p4: some small fixes updated Luke Diamand
2018-06-08 20:32 ` [PATCHv2 1/6] git-p4: disable-rebase: allow setting this via configuration Luke Diamand
2018-06-08 20:32   ` Luke Diamand [this message]
2018-06-08 20:32     ` [PATCHv2 3/6] git-p4: better error reporting when p4 fails Luke Diamand
2018-06-08 20:32       ` [PATCHv2 4/6] git-p4: raise exceptions from p4CmdList based on error from p4 server Luke Diamand
2018-06-08 20:32         ` [PATCHv2 5/6] git-p4: narrow the scope of exceptions caught when parsing an int Luke Diamand
2018-06-08 20:32           ` [PATCHv2 6/6] git-p4: auto-size the block Luke Diamand
2018-06-12 17:10 ` [PATCHv2 0/6] git-p4: some small fixes updated Junio C Hamano
2018-06-12 21:24   ` Luke Diamand
2018-06-12 21:35     ` Junio C Hamano
2018-06-12 21:49       ` Luke Diamand
2018-06-12 21:53         ` Eric Sunshine
2018-06-12 22:23           ` Luke Diamand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180608203248.16311-3-luke@diamand.org \
    --to=luke@diamand.org \
    --cc=eric@scouten.com \
    --cc=git@vger.kernel.org \
    --cc=larsxschneider@gmail.com \
    --cc=lex@lexspoon.org \
    --cc=merlorom@yahoo.fr \
    --cc=miguel.torroja@gmail.com \
    --cc=szeder.dev@gmail.com \
    --cc=viniciusalexandre@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).