git p4: fix-up "import/export of labels to/from p4"
The previous one is already in 'next' but was somewhat lacking. The configuration "git-p4.validLabelRegexp" is now called "labelExportRegexp", and its default covers lowercase alphabets as well. Signed-off-by: Luke Diamand <luke@diamand.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Luke Diamand committed
Apr 11, 2012 at 17:21 UTC
c8942a223d41adab336946913f28cf8691ee479a
3 files changed
+23
-25
Documentation/git-p4.txt
+10
-10
@@ -267,7 +267,7 @@ These options can be used to modify 'git p4 submit' behavior.
267
Re-author p4 changes before submitting to p4. This option
268
requires p4 admin privileges.
269
270
---export-labels:
270
+--export-labels::
271
Export tags from git as p4 labels. Tags found in git are applied
272
to the perforce working directory.
273
@@ -442,6 +442,11 @@ git-p4.branchList::
442
by a colon (:). This example declares that both branchA and
443
branchB were created from main:
444
445
+-------------
446
+git config git-p4.branchList main:branchA
447
+git config --add git-p4.branchList main:branchB
448
+-------------
449
+
450
git-p4.ignoredP4Labels::
451
List of p4 labels to ignore. This is built automatically as
452
unimportable labels are discovered.
@@ -449,14 +454,9 @@ git-p4.ignoredP4Labels::
454
git-p4.importLabels::
455
Import p4 labels into git, as per --import-labels.
456
452
-git-p4.validLabelRegexp::
457
+git-p4.labelImportRegexp::
458
Only p4 labels matching this regular expression will be imported. The
454
- default value is '[A-Z0-9_\-.]+$'.
455
-
456
--------------
457
-git config git-p4.branchList main:branchA
458
-git config --add git-p4.branchList main:branchB
459
--------------
459
+ default value is '[a-zA-Z0-9_\-.]+$'.
460
461
git-p4.useClientSpec::
462
Specify that the p4 client spec should be used to identify p4
@@ -515,9 +515,9 @@ git-p4.attemptRCSCleanup:
515
git-p4.exportLabels::
516
Export git tags to p4 labels, as per --export-labels.
517
518
-git-p4.validLabelRegexp::
518
+git-p4.labelExportRegexp::
519
Only p4 labels matching this regular expression will be exported. The
520
- default value is '[A-Z0-9_\-.]+$'.
520
+ default value is '[a-zA-Z0-9_\-.]+$'.
521
522
IMPLEMENTATION DETAILS
523
----------------------
git-p4.py
+11
-13
@@ -15,7 +15,7 @@ import re, shutil
15
verbose = False
16
17
# Only labels/tags matching this will be imported/exported
18
-defaultLabelRegexp = r'[A-Z0-9_\-.]+$'
18
+defaultLabelRegexp = r'[a-zA-Z0-9_\-.]+$'
19
20
def p4_build_cmd(cmd):
21
"""Build a suitable p4 command line.
@@ -1255,11 +1255,10 @@ class P4Submit(Command, P4UserMap):
1255
# Export git tags as p4 labels. Create a p4 label and then tag
1256
# with that.
1257
def exportGitTags(self, gitTags):
1258
- validTagRegexp = gitConfig("git-p4.validTagRegexp")
1259
- if len(validTagRegexp) == 0:
1260
- validTagRegexp = defaultLabelRegexp
1261
- m = re.compile(validTagRegexp)
1262
- commit_re = re.compile(r'\s*\[git-p4:.*change = (\d+)\s*\]')
1258
+ validLabelRegexp = gitConfig("git-p4.labelExportRegexp")
1259
+ if len(validLabelRegexp) == 0:
1260
+ validLabelRegexp = defaultLabelRegexp
1261
+ m = re.compile(validLabelRegexp)
1262
1263
for name in gitTags:
1264
@@ -1269,17 +1268,16 @@ class P4Submit(Command, P4UserMap):
1268
continue
1269
1270
# Get the p4 commit this corresponds to
1272
- changelist = None
1273
- for l in read_pipe_lines(["git", "log", "--max-count=1", name]):
1274
- match = commit_re.match(l)
1275
- if match:
1276
- changelist = match.group(1)
1271
+ logMessage = extractLogMessageFromGitCommit(name)
1272
+ values = extractSettingsGitLog(logMessage)
1273
1278
- if not changelist:
1274
+ if not values.has_key('change'):
1275
# a tag pointing to something not sent to p4; ignore
1276
if verbose:
1277
print "git tag %s does not give a p4 commit" % name
1278
continue
1279
+ else:
1280
+ changelist = values['change']
1281
1282
# Get the tag details.
1283
inHeader = True
@@ -2076,7 +2074,7 @@ class P4Sync(Command, P4UserMap):
2074
print "import p4 labels: " + ' '.join(p4Labels)
2075
2076
ignoredP4Labels = gitConfigList("git-p4.ignoredP4Labels")
2079
- validLabelRegexp = gitConfig("git-p4.validLabelRegexp")
2077
+ validLabelRegexp = gitConfig("git-p4.labelImportRegexp")
2078
if len(validLabelRegexp) == 0:
2079
validLabelRegexp = defaultLabelRegexp
2080
m = re.compile(validLabelRegexp)
t/t9811-git-p4-label-import.sh
+2
-2
@@ -30,7 +30,7 @@ test_expect_success 'basic p4 labels' '
30
31
p4 tag -l TAG_F1_ONLY main/f1 &&
32
p4 tag -l TAG_WITH\$_SHELL_CHAR main/... &&
33
- p4 tag -l this_tag_will_be_skipped main/... &&
33
+ p4 tag -l this_tag_will_be\ skipped main/... &&
34
35
echo f4 >main/f4 &&
36
p4 add main/f4 &&
@@ -50,7 +50,7 @@ test_expect_success 'basic p4 labels' '
50
51
git p4 clone --dest="$git" //depot@all &&
52
cd "$git" &&
53
- git config git-p4.validLabelRegexp ".*TAG.*" &&
53
+ git config git-p4.labelImportRegexp ".*TAG.*" &&
54
git p4 sync --import-labels --verbose &&
55
56
git tag &&