提交 7706d854 编写于 作者: J Junio C Hamano

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
......@@ -241,6 +241,9 @@ Git repository:
Use a client spec to find the list of interesting files in p4.
See the "CLIENT SPEC" section below.
-/ <path>::
Exclude selected depot paths when cloning or syncing.
Clone options
~~~~~~~~~~~~~
These options can be used in an initial 'clone', along with the 'sync'
......@@ -254,9 +257,6 @@ options described above.
--bare::
Perform a bare clone. See linkgit:git-clone[1].
-/ <path>::
Exclude selected depot paths when cloning.
Submit options
~~~~~~~~~~~~~~
These options can be used to modify 'git p4 submit' behavior.
......
......@@ -1915,7 +1915,10 @@ def __init__(self):
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 @@ def __init__(self):
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 @@ def __init__(self):
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 @@ def __init__(self):
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]
......
#!/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
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册