Merge branch 'ld/p4-exclude-in-sync'
Like the "clone" subcommand, allow excluding subdirectories in the "sync" subcommand. * ld/p4-exclude-in-sync: git-p4: support excluding paths on sync
This commit is contained in:
commit
7706d85453
@ -241,6 +241,9 @@ Git repository:
|
|||||||
Use a client spec to find the list of interesting files in p4.
|
Use a client spec to find the list of interesting files in p4.
|
||||||
See the "CLIENT SPEC" section below.
|
See the "CLIENT SPEC" section below.
|
||||||
|
|
||||||
|
-/ <path>::
|
||||||
|
Exclude selected depot paths when cloning or syncing.
|
||||||
|
|
||||||
Clone options
|
Clone options
|
||||||
~~~~~~~~~~~~~
|
~~~~~~~~~~~~~
|
||||||
These options can be used in an initial 'clone', along with the 'sync'
|
These options can be used in an initial 'clone', along with the 'sync'
|
||||||
@ -254,9 +257,6 @@ options described above.
|
|||||||
--bare::
|
--bare::
|
||||||
Perform a bare clone. See linkgit:git-clone[1].
|
Perform a bare clone. See linkgit:git-clone[1].
|
||||||
|
|
||||||
-/ <path>::
|
|
||||||
Exclude selected depot paths when cloning.
|
|
||||||
|
|
||||||
Submit options
|
Submit options
|
||||||
~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~
|
||||||
These options can be used to modify 'git p4 submit' behavior.
|
These options can be used to modify 'git p4 submit' behavior.
|
||||||
|
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',
|
optparse.make_option("--keep-path", dest="keepRepoPath", action='store_true',
|
||||||
help="Keep entire BRANCH/DIR/SUBDIR prefix during import"),
|
help="Keep entire BRANCH/DIR/SUBDIR prefix during import"),
|
||||||
optparse.make_option("--use-client-spec", dest="useClientSpec", action='store_true',
|
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
|
self.description = """Imports from Perforce into a git repository.\n
|
||||||
example:
|
example:
|
||||||
@ -1950,6 +1953,12 @@ class P4Sync(Command, P4UserMap):
|
|||||||
if gitConfig("git-p4.syncFromOrigin") == "false":
|
if gitConfig("git-p4.syncFromOrigin") == "false":
|
||||||
self.syncWithOrigin = 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
|
# Force a checkpoint in fast-import and wait for it to finish
|
||||||
def checkpoint(self):
|
def checkpoint(self):
|
||||||
self.gitStream.write("checkpoint\n\n")
|
self.gitStream.write("checkpoint\n\n")
|
||||||
@ -3101,9 +3110,6 @@ class P4Clone(P4Sync):
|
|||||||
optparse.make_option("--destination", dest="cloneDestination",
|
optparse.make_option("--destination", dest="cloneDestination",
|
||||||
action='store', default=None,
|
action='store', default=None,
|
||||||
help="where to leave result of the clone"),
|
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",
|
optparse.make_option("--bare", dest="cloneBare",
|
||||||
action="store_true", default=False),
|
action="store_true", default=False),
|
||||||
]
|
]
|
||||||
@ -3111,12 +3117,6 @@ class P4Clone(P4Sync):
|
|||||||
self.needsGit = False
|
self.needsGit = False
|
||||||
self.cloneBare = 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):
|
def defaultDestination(self, args):
|
||||||
## TODO: use common prefix of args?
|
## TODO: use common prefix of args?
|
||||||
depotPath = args[0]
|
depotPath = args[0]
|
||||||
|
71
t/t9817-git-p4-exclude.sh
Executable file
71
t/t9817-git-p4-exclude.sh
Executable file
@ -0,0 +1,71 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
test_description='git p4 tests for excluded paths during clone and sync'
|
||||||
|
|
||||||
|
. ./lib-git-p4.sh
|
||||||
|
|
||||||
|
test_expect_success 'start p4d' '
|
||||||
|
start_p4d
|
||||||
|
'
|
||||||
|
|
||||||
|
# Create a repo with the structure:
|
||||||
|
#
|
||||||
|
# //depot/wanted/foo
|
||||||
|
# //depot/discard/foo
|
||||||
|
#
|
||||||
|
# Check that we can exclude a subdirectory with both
|
||||||
|
# clone and sync operations.
|
||||||
|
|
||||||
|
test_expect_success 'create exclude repo' '
|
||||||
|
(
|
||||||
|
cd "$cli" &&
|
||||||
|
mkdir -p wanted discard &&
|
||||||
|
echo wanted >wanted/foo &&
|
||||||
|
echo discard >discard/foo &&
|
||||||
|
p4 add wanted/foo discard/foo &&
|
||||||
|
p4 submit -d "initial revision"
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'check the repo was created correctly' '
|
||||||
|
test_when_finished cleanup_git &&
|
||||||
|
git p4 clone --dest="$git" //depot/...@all &&
|
||||||
|
(
|
||||||
|
cd "$git" &&
|
||||||
|
test_path_is_file wanted/foo &&
|
||||||
|
test_path_is_file discard/foo
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'clone, excluding part of repo' '
|
||||||
|
test_when_finished cleanup_git &&
|
||||||
|
git p4 clone -//depot/discard/... --dest="$git" //depot/...@all &&
|
||||||
|
(
|
||||||
|
cd "$git" &&
|
||||||
|
test_path_is_file wanted/foo &&
|
||||||
|
test_path_is_missing discard/foo
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'clone, then sync with exclude' '
|
||||||
|
test_when_finished cleanup_git &&
|
||||||
|
git p4 clone -//depot/discard/... --dest="$git" //depot/...@all &&
|
||||||
|
(
|
||||||
|
cd "$cli" &&
|
||||||
|
p4 edit wanted/foo discard/foo &&
|
||||||
|
date >>wanted/foo &&
|
||||||
|
date >>discard/foo &&
|
||||||
|
p4 submit -d "updating" &&
|
||||||
|
|
||||||
|
cd "$git" &&
|
||||||
|
git p4 sync -//depot/discard/... &&
|
||||||
|
test_path_is_file wanted/foo &&
|
||||||
|
test_path_is_missing discard/foo
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'kill p4d' '
|
||||||
|
kill_p4d
|
||||||
|
'
|
||||||
|
|
||||||
|
test_done
|
Loading…
Reference in New Issue
Block a user