git p4: bring back files in deleted client directory
The code to auto-create the client directory, added in 0591cfa (git-p4: ensure submit clientPath exists before chdir, 2011-12-09), works when the client directory never existed. But if the directory is summarily removed without telling p4, the sync operation will not bring back all the files. Always do "sync -f" if the client directory is newly created. Reported-by: Gary Gibbons <ggibbons@perforce.com> Signed-off-by: Pete Wyckoff <pw@padd.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Pete Wyckoff committed
Apr 29, 2012 at 20:57 UTC
8d7ec3629cb1fc315b3218a8f277545157334a86
2 files changed
+14
-5
git-p4.py
+9
-3
@@ -135,8 +135,8 @@ def p4_system(cmd):
135
def p4_integrate(src, dest):
136
p4_system(["integrate", "-Dt", src, dest])
137
138
-def p4_sync(path):
139
- p4_system(["sync", path])
138
+def p4_sync(f, *options):
139
+ p4_system(["sync"] + list(options) + [f])
140
141
def p4_add(f):
142
p4_system(["add", f])
@@ -1361,12 +1361,18 @@ class P4Submit(Command, P4UserMap):
1361
self.oldWorkingDirectory = os.getcwd()
1362
1363
# ensure the clientPath exists
1364
+ new_client_dir = False
1365
if not os.path.exists(self.clientPath):
1366
+ new_client_dir = True
1367
os.makedirs(self.clientPath)
1368
1369
chdir(self.clientPath)
1370
print "Synchronizing p4 checkout..."
1369
- p4_sync("...")
1371
+ if new_client_dir:
1372
+ # old one was destroyed, and maybe nobody told p4
1373
+ p4_sync("...", "-f")
1374
+ else:
1375
+ p4_sync("...")
1376
self.check()
1377
1378
commits = []
t/t9807-git-p4-submit.sh
+5
-2
@@ -28,6 +28,11 @@ test_expect_success 'submit with no client dir' '
28
rm -rf "$cli" &&
29
git config git-p4.skipSubmitEdit true &&
30
git p4 submit
31
+ ) &&
32
+ (
33
+ cd "$cli" &&
34
+ test_path_is_file file1 &&
35
+ test_path_is_file file2
36
)
37
'
38
@@ -44,7 +49,6 @@ test_expect_success 'submit --origin' '
49
) &&
50
(
51
cd "$cli" &&
47
- p4 sync &&
52
test_path_is_missing "file3.t" &&
53
test_path_is_file "file4.t"
54
)
@@ -79,7 +83,6 @@ test_expect_success 'submit with master branch name from argv' '
83
) &&
84
(
85
cd "$cli" &&
82
- p4 sync &&
86
test_path_is_file "file6.t" &&
87
test_path_is_missing "file7.t"
88
)