From: Simon Hausmann <simon@lst.de>
To: Tommy Thorn <tommy-git@thorn.ws>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 2/3] git-p4: support exclude paths
Date: Sun, 3 Feb 2008 19:41:16 +0100 [thread overview]
Message-ID: <200802031941.17010.simon@lst.de> (raw)
In-Reply-To: <dd96ea0b47e8ec67ef14e4e954aa9ec7bec3c295.1202029604.git.tommy-git@thorn.ws>
[-- Attachment #1: Type: text/plain, Size: 3529 bytes --]
On Sunday 03 February 2008 10:21:05 Tommy Thorn wrote:
> Teach git-p4 about the -/ option which adds depot paths to the exclude
> list, used when cloning. The option is chosen such that the natural
> Perforce syntax works, eg:
>
> git p4 clone //branch/path/... -//branch/path/{large,old}/...
>
> Trailing ... on exclude paths are optional.
>
> This is a generalization of a change by Dmitry Kakurin (thanks).
>
> Signed-off-by: Tommy Thorn <tommy-git@thorn.ws>
Acked-By: Simon Hausmann <simon@lst.de>
I like it, Perforce'ish syntax. (Not that I like p4 though ;)
Simon
> ---
> contrib/fast-import/git-p4 | 26 ++++++++++++++++++++++----
> 1 files changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
> index 553e237..2340876 100755
> --- a/contrib/fast-import/git-p4
> +++ b/contrib/fast-import/git-p4
> @@ -876,18 +876,25 @@ class P4Sync(Command):
> self.keepRepoPath = False
> self.depotPaths = None
> self.p4BranchesInGit = []
> + self.cloneExclude = []
>
> if gitConfig("git-p4.syncFromOrigin") == "false":
> self.syncWithOrigin = False
>
> def extractFilesFromCommit(self, commit):
> + self.cloneExclude = [re.sub(r"\.\.\.$", "", path)
> + for path in self.cloneExclude]
> files = []
> fnum = 0
> while commit.has_key("depotFile%s" % fnum):
> path = commit["depotFile%s" % fnum]
>
> - found = [p for p in self.depotPaths
> - if path.startswith (p)]
> + if [p for p in self.cloneExclude
> + if path.startswith (p)]:
> + found = False
> + else:
> + found = [p for p in self.depotPaths
> + if path.startswith (p)]
> if not found:
> fnum = fnum + 1
> continue
> @@ -1658,13 +1665,23 @@ class P4Clone(P4Sync):
> P4Sync.__init__(self)
> self.description = "Creates a new git repository and imports from
> Perforce into it" self.usage = "usage: %prog [options]
> //depot/path[@revRange]" - self.options.append(
> + self.options += [
> optparse.make_option("--destination", dest="cloneDestination",
> 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")
> + ]
> self.cloneDestination = None
> self.needsGit = 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]
> @@ -1688,6 +1705,7 @@ class P4Clone(P4Sync):
> self.cloneDestination = depotPaths[-1]
> depotPaths = depotPaths[:-1]
>
> + self.cloneExclude = ["/"+p for p in self.cloneExclude]
> for p in depotPaths:
> if not p.startswith("//"):
> return False
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 189 bytes --]
next prev parent reply other threads:[~2008-02-03 18:41 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-03 9:21 [PATCH 1/3] git-p4: Fix an obvious typo Tommy Thorn
2008-02-03 9:21 ` [PATCH 2/3] git-p4: support exclude paths Tommy Thorn
2008-02-03 9:21 ` [PATCH 3/3] git-p4: no longer keep all file contents while cloning Tommy Thorn
2008-02-03 18:41 ` Simon Hausmann [this message]
2008-02-03 18:55 ` [PATCH 2/3] git-p4: support exclude paths Tommy Thorn
[not found] <48092.216.228.112.21.1199496008.squirrel@numba-tu.com>
2008-02-12 15:53 ` Tommy Thorn
2008-02-15 22:56 ` Simon Hausmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200802031941.17010.simon@lst.de \
--to=simon@lst.de \
--cc=git@vger.kernel.org \
--cc=tommy-git@thorn.ws \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).