Skip to content

Commit 6a10b6a

Browse files
luked99gitster
authored andcommitted
git p4: move verbose to base class
The verbose flag is common to all classes, or at least should be. Make it a member of the base Command class, rather than reimplementing for each class. Make option parsing mirror this. Signed-off-by: Luke Diamand <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f95ceaf commit 6a10b6a

File tree

2 files changed

+14
-28
lines changed

2 files changed

+14
-28
lines changed

Documentation/git-p4.txt

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,11 +158,14 @@ OPTIONS
158158

159159
General options
160160
~~~~~~~~~~~~~~~
161-
All commands except clone accept this option.
161+
All commands except clone accept these options.
162162

163163
--git-dir <dir>::
164164
Set the 'GIT_DIR' environment variable. See linkgit:git[1].
165165

166+
--verbose::
167+
Provide more progress information.
168+
166169
Sync options
167170
~~~~~~~~~~~~
168171
These options can be used in the initial 'clone' as well as in
@@ -193,9 +196,6 @@ git repository:
193196
--silent::
194197
Do not print any progress information.
195198

196-
--verbose::
197-
Provide more progress information.
198-
199199
--detect-labels::
200200
Query p4 for labels associated with the depot paths, and add
201201
them as tags in git. Limited usefulness as only imports labels
@@ -249,9 +249,6 @@ Submit options
249249
~~~~~~~~~~~~~~
250250
These options can be used to modify 'git p4 submit' behavior.
251251

252-
--verbose::
253-
Provide more progress information.
254-
255252
--origin <commit>::
256253
Upstream location from which commits are identified to submit to
257254
p4. By default, this is the most recent p4 commit reachable

git-p4.py

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,7 @@ class Command:
662662
def __init__(self):
663663
self.usage = "usage: %prog [options]"
664664
self.needsGit = True
665+
self.verbose = False
665666

666667
class P4UserMap:
667668
def __init__(self):
@@ -727,13 +728,9 @@ def loadUserMapFromCache(self):
727728
class P4Debug(Command):
728729
def __init__(self):
729730
Command.__init__(self)
730-
self.options = [
731-
optparse.make_option("--verbose", dest="verbose", action="store_true",
732-
default=False),
733-
]
731+
self.options = []
734732
self.description = "A tool to debug the output of p4 -G."
735733
self.needsGit = False
736-
self.verbose = False
737734

738735
def run(self, args):
739736
j = 0
@@ -747,11 +744,9 @@ class P4RollBack(Command):
747744
def __init__(self):
748745
Command.__init__(self)
749746
self.options = [
750-
optparse.make_option("--verbose", dest="verbose", action="store_true"),
751747
optparse.make_option("--local", dest="rollbackLocalBranches", action="store_true")
752748
]
753749
self.description = "A tool to debug the multi-branch import. Don't use :)"
754-
self.verbose = False
755750
self.rollbackLocalBranches = False
756751

757752
def run(self, args):
@@ -809,7 +804,6 @@ def __init__(self):
809804
Command.__init__(self)
810805
P4UserMap.__init__(self)
811806
self.options = [
812-
optparse.make_option("--verbose", dest="verbose", action="store_true"),
813807
optparse.make_option("--origin", dest="origin"),
814808
optparse.make_option("-M", dest="detectRenames", action="store_true"),
815809
# preserve the user, requires relevant p4 permissions
@@ -821,7 +815,6 @@ def __init__(self):
821815
self.interactive = True
822816
self.origin = ""
823817
self.detectRenames = False
824-
self.verbose = False
825818
self.preserveUser = gitConfig("git-p4.preserveUser").lower() == "true"
826819
self.isWindows = (platform.system() == "Windows")
827820
self.exportLabels = False
@@ -1644,7 +1637,6 @@ def __init__(self):
16441637
optparse.make_option("--silent", dest="silent", action="store_true"),
16451638
optparse.make_option("--detect-labels", dest="detectLabels", action="store_true"),
16461639
optparse.make_option("--import-labels", dest="importLabels", action="store_true"),
1647-
optparse.make_option("--verbose", dest="verbose", action="store_true"),
16481640
optparse.make_option("--import-local", dest="importIntoRemotes", action="store_false",
16491641
help="Import into refs/heads/ , not refs/remotes"),
16501642
optparse.make_option("--max-changes", dest="maxChanges"),
@@ -1671,7 +1663,6 @@ def __init__(self):
16711663
self.importLabels = False
16721664
self.changesFile = ""
16731665
self.syncWithOrigin = True
1674-
self.verbose = False
16751666
self.importIntoRemotes = True
16761667
self.maxChanges = ""
16771668
self.isWindows = (platform.system() == "Windows")
@@ -2712,9 +2703,7 @@ def __init__(self):
27122703
Command.__init__(self)
27132704
self.options = [
27142705
optparse.make_option("--import-labels", dest="importLabels", action="store_true"),
2715-
optparse.make_option("--verbose", dest="verbose", action="store_true"),
27162706
]
2717-
self.verbose = False
27182707
self.importLabels = False
27192708
self.description = ("Fetches the latest revision from perforce and "
27202709
+ "rebases the current work (branch) against it")
@@ -2911,16 +2900,16 @@ def main():
29112900

29122901
args = sys.argv[2:]
29132902

2914-
if len(options) > 0:
2915-
if cmd.needsGit:
2916-
options.append(optparse.make_option("--git-dir", dest="gitdir"))
2903+
options.append(optparse.make_option("--verbose", dest="verbose", action="store_true"))
2904+
if cmd.needsGit:
2905+
options.append(optparse.make_option("--git-dir", dest="gitdir"))
29172906

2918-
parser = optparse.OptionParser(cmd.usage.replace("%prog", "%prog " + cmdName),
2919-
options,
2920-
description = cmd.description,
2921-
formatter = HelpFormatter())
2907+
parser = optparse.OptionParser(cmd.usage.replace("%prog", "%prog " + cmdName),
2908+
options,
2909+
description = cmd.description,
2910+
formatter = HelpFormatter())
29222911

2923-
(cmd, args) = parser.parse_args(sys.argv[2:], cmd);
2912+
(cmd, args) = parser.parse_args(sys.argv[2:], cmd);
29242913
global verbose
29252914
verbose = cmd.verbose
29262915
if cmd.needsGit:

0 commit comments

Comments
 (0)