git-p4: support excluding paths on sync
The clone subcommand has long had support for excluding subdirectories, but sync has not. This is a nuisance, since as soon as you do a sync, any changed files that were initially excluded start showing up. Move the "exclude" command-line option into the parent class; the actual behavior was already present there so it simply had to be exposed. Signed-off-by: Luke Diamand <luke@diamand.org> Reviewed-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
fdf96a20ac
commit
51334bb094
20
git-p4.py
20
git-p4.py
@ -1915,7 +1915,10 @@ class P4Sync(Command, P4UserMap):
|
||||
optparse.make_option("--keep-path", dest="keepRepoPath", action='store_true',
|
||||
help="Keep entire BRANCH/DIR/SUBDIR prefix during import"),
|
||||
optparse.make_option("--use-client-spec", dest="useClientSpec", action='store_true',
|
||||
help="Only sync files that are included in the Perforce Client Spec")
|
||||
help="Only sync files that are included in the Perforce Client Spec"),
|
||||
optparse.make_option("-/", dest="cloneExclude",
|
||||
action="append", type="string",
|
||||
help="exclude depot path"),
|
||||
]
|
||||
self.description = """Imports from Perforce into a git repository.\n
|
||||
example:
|
||||
@ -1950,6 +1953,12 @@ class P4Sync(Command, P4UserMap):
|
||||
if gitConfig("git-p4.syncFromOrigin") == "false":
|
||||
self.syncWithOrigin = False
|
||||
|
||||
# This is required for the "append" cloneExclude action
|
||||
def ensure_value(self, attr, value):
|
||||
if not hasattr(self, attr) or getattr(self, attr) is None:
|
||||
setattr(self, attr, value)
|
||||
return getattr(self, attr)
|
||||
|
||||
# Force a checkpoint in fast-import and wait for it to finish
|
||||
def checkpoint(self):
|
||||
self.gitStream.write("checkpoint\n\n")
|
||||
@ -3101,9 +3110,6 @@ class P4Clone(P4Sync):
|
||||
optparse.make_option("--destination", dest="cloneDestination",
|
||||
action='store', default=None,
|
||||
help="where to leave result of the clone"),
|
||||
optparse.make_option("-/", dest="cloneExclude",
|
||||
action="append", type="string",
|
||||
help="exclude depot path"),
|
||||
optparse.make_option("--bare", dest="cloneBare",
|
||||
action="store_true", default=False),
|
||||
]
|
||||
@ -3111,12 +3117,6 @@ class P4Clone(P4Sync):
|
||||
self.needsGit = False
|
||||
self.cloneBare = False
|
||||
|
||||
# This is required for the "append" cloneExclude action
|
||||
def ensure_value(self, attr, value):
|
||||
if not hasattr(self, attr) or getattr(self, attr) is None:
|
||||
setattr(self, attr, value)
|
||||
return getattr(self, attr)
|
||||
|
||||
def defaultDestination(self, args):
|
||||
## TODO: use common prefix of args?
|
||||
depotPath = args[0]
|
||||
|
Reference in New Issue
Block a user