Re: [PATCH 7/8] git-p4: decode p4 wildcard characters

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Feb 5, 2011 at 11:52 PM, Pete Wyckoff <pw@xxxxxxxx> wrote:
> There are four wildcard characters in p4. ÂFiles with these
> characters can be added to p4 repos using the "-f" option.
> They are stored in %xx notation, and when checked out, p4
> converts them back to normal.
>
> This patch does the same thing when importing into git,
> converting the four special characters. ÂWithout this change,
> the files appear with literal %xx in their names.
>
> Signed-off-by: Pete Wyckoff <pw@xxxxxxxx>
> ---
> Âcontrib/fast-import/git-p4 | Â 13 +++++++++++++
> Ât/t9800-git-p4.sh     Â|  22 ++++++++++++++++++++++
> Â2 files changed, 35 insertions(+), 0 deletions(-)
>
> diff --git a/contrib/fast-import/git-p4 b/contrib/fast-import/git-p4
> index 04e6c3d..5b08cd6 100755
> --- a/contrib/fast-import/git-p4
> +++ b/contrib/fast-import/git-p4
> @@ -884,6 +884,18 @@ class P4Sync(Command):
> Â Â Â Â if gitConfig("git-p4.syncFromOrigin") == "false":
> Â Â Â Â Â Â self.syncWithOrigin = False
>
> + Â Â# The p4 wildcards are not allowed in filenames. ÂIt complains
> + Â Â# if you try to add them, but you can override with "-f", in
> + Â Â# which case it translates them into %xx encoding. ÂSearch for
> + Â Â# and fix just these four characters. ÂDo % last so it does
> + Â Â# not inadvertantly create new %-escapes.
> + Â Âdef wildcard_decode(self, path):
> + Â Â Â Âpath = path.replace("%23", "#") \
> + Â Â Â Â Â Â Â Â Â .replace("%2A", "*") \

This probably works fine on UNIX platforms, but the asterisk '*'
character is not allowed in windows filenames. I don't really know
what perforce does in that scenario. Does it make the most sense to
just keep the %2A in the filename if we are running on windows (??)

    -- Tor Arvid

> + Â Â Â Â Â Â Â Â Â .replace("%40", "@") \
> + Â Â Â Â Â Â Â Â Â .replace("%25", "%")
> + Â Â Â Âreturn path
> +
> Â Â def extractFilesFromCommit(self, commit):
> Â Â Â Â self.cloneExclude = [re.sub(r"\.\.\.$", "", path)
> Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âfor path in self.cloneExclude]
> @@ -962,6 +974,7 @@ class P4Sync(Command):
> Â Â Â Â Â Âreturn
>
> Â Â Â Â relPath = self.stripRepoPath(file['depotFile'], self.branchPrefixes)
> + Â Â Â ÂrelPath = self.wildcard_decode(relPath)
> Â Â Â Â if verbose:
> Â Â Â Â Â Â sys.stderr.write("%s\n" % relPath)
>
> diff --git a/t/t9800-git-p4.sh b/t/t9800-git-p4.sh
> index 41e57bb..72c38af 100755
> --- a/t/t9800-git-p4.sh
> +++ b/t/t9800-git-p4.sh
> @@ -65,6 +65,28 @@ test_expect_success 'exit when p4 fails to produce marshaled output' '
> Â Â Â Âtest_must_fail grep -q Traceback errs
> Â'
>
> +test_expect_success 'add p4 files with wildcards in the names' '
> + Â Â Â cd "$cli" &&
> + Â Â Â echo file-wild-hash >file-wild#hash &&
> + Â Â Â echo file-wild-star >file-wild\*star &&
> + Â Â Â echo file-wild-at >file-wild@at &&
> + Â Â Â echo file-wild-percent >file-wild%percent &&
> + Â Â Â p4 add -f file-wild* &&
> + Â Â Â p4 submit -d "file wildcards" &&
> + Â Â Â cd "$TRASH_DIRECTORY"
> +'
> +
> +test_expect_success 'wildcard files git-p4 clone' '
> + Â Â Â "$GITP4" clone --dest="$git" //depot &&
> + Â Â Â cd "$git" &&
> + Â Â Â test -f file-wild#hash &&
> + Â Â Â test -f file-wild\*star &&
> + Â Â Â test -f file-wild@at &&
> + Â Â Â test -f file-wild%percent &&
> + Â Â Â cd "$TRASH_DIRECTORY" &&
> + Â Â Â rm -rf "$git" && mkdir "$git"
> +'
> +
> Âtest_expect_success 'shutdown' '
> Â Â Â Âpid=`pgrep -f p4d` &&
> Â Â Â Âtest -n "$pid" &&
> --
> 1.7.2.3
>
> --
> To unsubscribe from this list: send the line "unsubscribe git" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]