{"thread":{"id":"48652","subject":"[PATCHv1 0/2] git-p4: disable sync after submit","startedAt":"2018-06-05T08:29:08Z","lastAt":"2018-06-05T08:47:41Z","messageCount":4,"participants":["Luke Diamand","Eric Sunshine"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"349319","messageId":"20180605082854.17090-1-luke@diamand.org","threadId":"48652","inReplyTo":null,"subject":"[PATCHv1 0/2] git-p4: disable sync after submit","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2018-06-05T08:28:52Z","receivedAt":"2018-06-05T08:29:08Z","isPatch":false,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"This is a small patch to git-p4 to disable the automatic sync after\nsubmit.\n\nIn my day-to-day work, I have a central git-p4 repo which is\nautomatically kept up-to-date, so the repos where I actually work and\nsubmit from don't even need the sync. I usually end up hitting Ctrl-C\npartway through the sync.\n\nI imagine other people with large git-p4 projects do something similar\nand have the same problem.\n\nThis also updates Merland's recent submit-selection change so that both\noptions can be set via configuration rather than being set on the\ncommand line.\n\nLuke Diamand (2):\n  git-p4: disable-rebase: allow setting this via configuration\n  git-p4: add option to disable syncing of p4/master with p4\n\n Documentation/git-p4.txt | 13 ++++++++++++-\n git-p4.py                | 33 +++++++++++++++++++++------------\n 2 files changed, 33 insertions(+), 13 deletions(-)\n\n-- \n2.17.0.392.gdeb1a6e9b7\n\n"},{"id":"349320","messageId":"20180605082854.17090-2-luke@diamand.org","threadId":"48652","inReplyTo":"20180605082854.17090-1-luke@diamand.org","subject":"[PATCHv1 1/2] git-p4: disable-rebase: allow setting this via configuration","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2018-06-05T08:28:53Z","receivedAt":"2018-06-05T08:29:09Z","isPatch":false,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"This just lets you set the --disable-rebase option with the\ngit configuration options git-p4.disableRebase. If you're\nusing this option, you probably want to set it all the time\nfor a given repo.\n\nSigned-off-by: Luke Diamand <luke@diamand.org>\n---\n Documentation/git-p4.txt | 5 ++++-\n git-p4.py                | 2 +-\n 2 files changed, 5 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt\nindex e8452528fc..3d83842e47 100644\n--- a/Documentation/git-p4.txt\n+++ b/Documentation/git-p4.txt\n@@ -367,7 +367,7 @@ These options can be used to modify 'git p4 submit' behavior.\n \n --disable-rebase::\n     Disable the automatic rebase after all commits have been successfully\n-    submitted.\n+    submitted. Can also be set with git-p4.disableRebase.\n \n Rebase options\n ~~~~~~~~~~~~~~\n@@ -690,6 +690,9 @@ git-p4.conflict::\n \tSpecify submit behavior when a conflict with p4 is found, as per\n \t--conflict.  The default behavior is 'ask'.\n \n+git-p4.disableRebase::\n+    Do not rebase the tree against p4/master following a submit.\n+\n IMPLEMENTATION DETAILS\n ----------------------\n * Changesets from p4 are imported using Git fast-import.\ndiff --git a/git-p4.py b/git-p4.py\nindex c4581d20a6..5ab9421af8 100755\n--- a/git-p4.py\n+++ b/git-p4.py\n@@ -1379,7 +1379,7 @@ def __init__(self):\n         self.shelve = False\n         self.update_shelve = list()\n         self.commit = \"\"\n-        self.disable_rebase = False\n+        self.disable_rebase = gitConfigBool(\"git-p4.disableRebase\")\n         self.prepare_p4_only = False\n         self.conflict_behavior = None\n         self.isWindows = (platform.system() == \"Windows\")\n-- \n2.17.0.392.gdeb1a6e9b7\n\n"},{"id":"349321","messageId":"20180605082854.17090-3-luke@diamand.org","threadId":"48652","inReplyTo":"20180605082854.17090-1-luke@diamand.org","subject":"[PATCHv1 2/2] git-p4: add option to disable syncing of p4/master with p4","fromName":"Luke Diamand","fromEmail":"luke@diamand.org","sentAt":"2018-06-05T08:28:54Z","receivedAt":"2018-06-05T08:29:13Z","isPatch":false,"sender":{"key":"luke@diamand.org","avatar":"https://avatars.githubusercontent.com/u/5330967?v=4"},"body":"Add an option to the git-p4 submit command to disable syncing\nwith Perforce.\n\nThis is useful for the case where a git-p4 mirror has been setup\non a server somewhere, running from (e.g.) cron, and developers\nthen clone from this. Having the local cloned copy also sync\nfrom Perforce just isn't useful.\n\nSigned-off-by: Luke Diamand <luke@diamand.org>\n---\n Documentation/git-p4.txt |  8 ++++++++\n git-p4.py                | 31 ++++++++++++++++++++-----------\n 2 files changed, 28 insertions(+), 11 deletions(-)\n\ndiff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt\nindex 3d83842e47..8f6a7543fd 100644\n--- a/Documentation/git-p4.txt\n+++ b/Documentation/git-p4.txt\n@@ -369,6 +369,11 @@ These options can be used to modify 'git p4 submit' behavior.\n     Disable the automatic rebase after all commits have been successfully\n     submitted. Can also be set with git-p4.disableRebase.\n \n+--disable-p4sync::\n+    Disable the automatic sync of p4/master from Perforce after commit have\n+    been submitted. Implies --disable-rebase. Can also be set with\n+    git-p4.disableP4Sync. Sync with origin/master still goes ahead if possible.\n+\n Rebase options\n ~~~~~~~~~~~~~~\n These options can be used to modify 'git p4 rebase' behavior.\n@@ -693,6 +698,9 @@ git-p4.conflict::\n git-p4.disableRebase::\n     Do not rebase the tree against p4/master following a submit.\n \n+git-p4.disableP4Sync::\n+    Do not sync p4/master with Perforce following a submit. Implies git-p4.disableRebase.\n+\n IMPLEMENTATION DETAILS\n ----------------------\n * Changesets from p4 are imported using Git fast-import.\ndiff --git a/git-p4.py b/git-p4.py\nindex 5ab9421af8..b9e79f1d8b 100755\n--- a/git-p4.py\n+++ b/git-p4.py\n@@ -1368,7 +1368,9 @@ def __init__(self):\n                                      help=\"submit only the specified commit(s), one commit or xxx..xxx\"),\n                 optparse.make_option(\"--disable-rebase\", dest=\"disable_rebase\", action=\"store_true\",\n                                      help=\"Disable rebase after submit is completed. Can be useful if you \"\n-                                     \"work from a local git branch that is not master\")\n+                                     \"work from a local git branch that is not master\"),\n+                optparse.make_option(\"--disable-p4sync\", dest=\"disable_p4sync\", action=\"store_true\",\n+                                     help=\"Skip perforce sync of p4/master after submit or shelve\"),\n         ]\n         self.description = \"Submit changes from git to the perforce depot.\"\n         self.usage += \" [name of git branch to submit into perforce depot]\"\n@@ -1380,6 +1382,7 @@ def __init__(self):\n         self.update_shelve = list()\n         self.commit = \"\"\n         self.disable_rebase = gitConfigBool(\"git-p4.disableRebase\")\n+        self.disable_p4sync = gitConfigBool(\"git-p4.disableP4Sync\")\n         self.prepare_p4_only = False\n         self.conflict_behavior = None\n         self.isWindows = (platform.system() == \"Windows\")\n@@ -2240,11 +2243,14 @@ def run(self, args):\n             sync = P4Sync()\n             if self.branch:\n                 sync.branch = self.branch\n-            sync.run([])\n+            if self.disable_p4sync:\n+                sync.sync_origin_only()\n+            else:\n+                sync.run([])\n \n-            if self.disable_rebase is False:\n-                rebase = P4Rebase()\n-                rebase.rebase()\n+                if not self.disable_rebase:\n+                    rebase = P4Rebase()\n+                    rebase.rebase()\n \n         else:\n             if len(applied) == 0:\n@@ -3324,6 +3330,14 @@ def importChanges(self, changes, shelved=False, origin_revision=0):\n                 print self.gitError.read()\n                 sys.exit(1)\n \n+    def sync_origin_only(self):\n+        if self.syncWithOrigin:\n+            self.hasOrigin = originP4BranchesExist()\n+            if self.hasOrigin:\n+                if not self.silent:\n+                    print 'Syncing with origin first, using \"git fetch origin\"'\n+                system(\"git fetch origin\")\n+\n     def importHeadRevision(self, revision):\n         print \"Doing initial import of %s from revision %s into %s\" % (' '.join(self.depotPaths), revision, self.branch)\n \n@@ -3402,12 +3416,7 @@ def run(self, args):\n         else:\n             self.refPrefix = \"refs/heads/p4/\"\n \n-        if self.syncWithOrigin:\n-            self.hasOrigin = originP4BranchesExist()\n-            if self.hasOrigin:\n-                if not self.silent:\n-                    print 'Syncing with origin first, using \"git fetch origin\"'\n-                system(\"git fetch origin\")\n+        self.sync_origin_only()\n \n         branch_arg_given = bool(self.branch)\n         if len(self.branch) == 0:\n-- \n2.17.0.392.gdeb1a6e9b7\n\n"},{"id":"349322","messageId":"CAPig+cQH1n+c2sNijPBKTG2tGDYEWjBz_PUoWREQh8y9tG4a-Q@mail.gmail.com","threadId":"48652","inReplyTo":"20180605082854.17090-3-luke@diamand.org","subject":"Re: [PATCHv1 2/2] git-p4: add option to disable syncing of p4/master with p4","fromName":"Eric Sunshine","fromEmail":"sunshine@sunshineco.com","sentAt":"2018-06-05T08:47:26Z","receivedAt":"2018-06-05T08:47:41Z","isPatch":false,"sender":{"key":"sunshine@sunshineco.com","avatar":"https://avatars.githubusercontent.com/u/163641?v=4"},"body":"On Tue, Jun 5, 2018 at 4:29 AM Luke Diamand <luke@diamand.org> wrote:\n> Add an option to the git-p4 submit command to disable syncing\n> with Perforce.\n>\n> This is useful for the case where a git-p4 mirror has been setup\n> on a server somewhere, running from (e.g.) cron, and developers\n> then clone from this. Having the local cloned copy also sync\n> from Perforce just isn't useful.\n>\n> Signed-off-by: Luke Diamand <luke@diamand.org>\n> ---\n> diff --git a/Documentation/git-p4.txt b/Documentation/git-p4.txt\n> @@ -369,6 +369,11 @@ These options can be used to modify 'git p4 submit' behavior.\n> +--disable-p4sync::\n> +    Disable the automatic sync of p4/master from Perforce after commit have\n\ns/commit/commits/\n\n> +    been submitted. Implies --disable-rebase. Can also be set with\n> +    git-p4.disableP4Sync. Sync with origin/master still goes ahead if possible.\n> diff --git a/git-p4.py b/git-p4.py\n> @@ -1368,7 +1368,9 @@ def __init__(self):\n> +                optparse.make_option(\"--disable-p4sync\", dest=\"disable_p4sync\", action=\"store_true\",\n> +                                     help=\"Skip perforce sync of p4/master after submit or shelve\"),\n\ns/perforce/Perforce/\n"}]}