[PATCH 3 of 3] convert: p4: ignore purged files with p4d 2012.2 and later

Mads Kiilerich mads at kiilerich.com
Sun Aug 24 20:30:16 CDT 2014


# HG changeset patch
# User Mads Kiilerich <madski at unity3d.com>
# Date 1408930071 -7200
#      Mon Aug 25 03:27:51 2014 +0200
# Node ID 7a4c63d9090d8b3a2f35e4bcade538523d49c7b8
# Parent  15d37065fe2f87cb6f7f08ec502365b616d4c4f1
convert: p4: ignore purged files with p4d 2012.2 and later

Perforce has the concept of "+Sn" files where only the last revisions of the
file is stored. In p4d 2012.1 old purged revisions were not included in the
"manifest". With 2012.2 they started being included and convert's getfile
failed to recognize the "purged" flag and saw it as an empty file. That made
test-convert-p4-filetypes.t fail.

There is no point in storing an empty file as placeholder for a purged file so
we restore the old behaviour by checking the flag and letting getfile consider
purged files deleted.

(It is questionable whether it makes sense to convert not-yet-purged +S files
to mercurial ... but that is another question.)

diff --git a/hgext/convert/p4.py b/hgext/convert/p4.py
--- a/hgext/convert/p4.py
+++ b/hgext/convert/p4.py
@@ -164,6 +164,8 @@ class p4_source(converter_source):
                 raise IOError(d["generic"], data)
 
             elif code == "stat":
+                if d.get("action") == "purge":
+                    return None, None
                 p4type = self.re_type.match(d["type"])
                 if p4type:
                     mode = ""


More information about the Mercurial-devel mailing list