diff --git a/hgext3rd/p4fastimport/p4.py b/hgext3rd/p4fastimport/p4.py --- a/hgext3rd/p4fastimport/p4.py +++ b/hgext3rd/p4fastimport/p4.py @@ -325,6 +325,30 @@ self._data = data self._depotfile = depotfile + # used in Perforce prior to 99.1 + self._keyword_to_typemod = { + 'text': ('text', ''), + 'xtext': ('text', 'x'), + 'ktext': ('text', 'k'), + 'kxtext': ('text', 'kx'), + 'binary': ('binary', ''), + 'xbinary': ('binary', 'x'), + 'ctext': ('text', 'C'), + 'cxtext': ('text', 'Cx'), + 'symlink': ('symlink', ''), + 'resource': ('resource', ''), + 'uresource': ('resource', 'F'), + 'ltext': ('text', 'F'), + 'xltext': ('text', 'Fx'), + 'ubinary': ('binary', 'F'), + 'uxbinary': ('binary', 'Fx'), + 'tempobj': ('binary', 'FSw'), + 'ctempobj': ('binary', 'Sw'), + 'xtempobj': ('binary', 'FSwx'), + 'xunicode': ('unicode', 'x'), + 'xutf16': ('utf16', 'x'), + } + # @property # def branchcl(self): # return self._parsed[1] @@ -353,21 +377,33 @@ def revisions(self): return sorted(self._data.keys()) + def _get_type_modifiers(self, filetype): + try: + filetype, modifiers = self._keyword_to_typemod[filetype] + except KeyError: + filetype, plus, modifiers = filetype.partition('+') + return filetype, modifiers + + def _get_type(self, filetype): + return self._get_type_modifiers(filetype)[0] + + def _get_modifiers(self, filetype): + return self._get_type_modifiers(filetype)[1] + def isdeleted(self, clnum): return self._data[clnum]['action'] in ['move/delete', 'delete'] def isexec(self, clnum): t = self._data[clnum]['type'] - return 'xtext' == t or '+x' in t + return 'x' in self._get_modifiers(t) def issymlink(self, clnum): t = self._data[clnum]['type'] - return 'symlink' in t + return 'symlink' == self._get_type(t) def iskeyworded(self, clnum): t = self._data[clnum]['type'] - return (re.compile('kx?text').match(t) or - re.compile('\+kx?').search(t)) is not None + return 'k' in self._get_modifiers(t) ACTION_EDIT = ['edit', 'integrate'] ACTION_ADD = ['add', 'branch', 'move/add'] diff --git a/tests/test-p4fastimport-import-lfs-sqlite.t b/tests/test-p4fastimport-import-lfs-sqlite.t --- a/tests/test-p4fastimport-import-lfs-sqlite.t +++ b/tests/test-p4fastimport-import-lfs-sqlite.t @@ -49,6 +49,7 @@ $ cd $hgwd $ hg init --config 'format.usefncache=False' $ hg p4fastimport --debug -P $P4ROOT hg-p4-import + updating the branch cache (?) loading changelist numbers. 2 changelists to import. loading list of files. @@ -70,7 +71,7 @@ changelist 2: writing manifest. node: 31c95d82cc49 p1: 0637b0361958 p2: 000000000000 linkrev: 1 changelist 2: writing changelog: second writing lfs metadata to sqlite - updating the branch cache (?) + updating the branch cache 2 revision(s), 3 file(s) imported. Verify diff --git a/tests/test-p4fastimport-import-lfs.t b/tests/test-p4fastimport-import-lfs.t --- a/tests/test-p4fastimport-import-lfs.t +++ b/tests/test-p4fastimport-import-lfs.t @@ -48,6 +48,7 @@ $ cd $hgwd $ hg init --config 'format.usefncache=False' $ hg p4fastimport --debug -P $P4ROOT hg-p4-import + updating the branch cache (?) loading changelist numbers. 2 changelists to import. loading list of files. @@ -60,7 +61,6 @@ writing filelog: a80d06849b33, p1 b789fdd96dc2, linkrev 1, 4 bytes, src: *, path: Main/a (glob) writing filelog: 149da44f2a4e, p1 000000000000, linkrev 0, 2 bytes, src: *, path: Main/b/c (glob) writing filelog: b11e10a88bfa, p1 149da44f2a4e, linkrev 1, 4 bytes, src: *, path: Main/b/c (glob) - updating the branch cache (?) writing filelog: ee08366a1a83, p1 000000000000, linkrev 0, 44 bytes, src: rcs, path: Main/largefile largefile: Main/largefile, oid: dde0d1d11f099d6572fa47fcbd1cae324aeaad7409cb107461b09ba4eb2177ac writing filelog: a33f052256c3, p1 ee08366a1a83, linkrev 1, 88 bytes, src: rcs, path: Main/largefile diff --git a/tests/test-p4fastimport-import-modes.t b/tests/test-p4fastimport-import-modes.t --- a/tests/test-p4fastimport-import-modes.t +++ b/tests/test-p4fastimport-import-modes.t @@ -37,6 +37,14 @@ edit //depot/Main/b/c#2 edit //depot/Main/d#2 Change 2 submitted. + $ echo "full-exec" > Main/full-exec + $ p4 add -t text+Fx Main/full-exec + //depot/Main/full-exec#1 - opened for add + $ p4 submit -d third + Submitting change 3. + Locking 1 files ... + add //depot/Main/full-exec#1 + Change 3 submitted. Simple import @@ -44,26 +52,31 @@ $ hg init --config 'format.usefncache=False' $ hg p4fastimport --debug -P $P4ROOT hg-p4-import loading changelist numbers. - 2 changelists to import. + updating the branch cache (?) + updating the branch cache (?) + 3 changelists to import. loading list of files. - 3 files to import. + 4 files to import. + reading filelog * (glob) reading filelog * (glob) reading filelog * (glob) reading filelog * (glob) importing repository. writing filelog: b789fdd96dc2, p1 000000000000, linkrev 0, 2 bytes, src: *, path: Main/a (glob) writing filelog: a80d06849b33, p1 b789fdd96dc2, linkrev 1, 4 bytes, src: *, path: Main/a (glob) - updating the branch cache (?) writing filelog: 1f6b5bb93f1d, p1 000000000000, linkrev 0, 4 bytes, src: *, path: Main/b/c (glob) writing filelog: c29ae1cbd245, p1 1f6b5bb93f1d, linkrev 1, 2 bytes, src: *, path: Main/b/c (glob) writing filelog: a9092a3d84a3, p1 000000000000, linkrev 0, 2 bytes, src: *, path: Main/d (glob) writing filelog: f83f0637e55e, p1 a9092a3d84a3, linkrev 1, 4 bytes, src: *, path: Main/d (glob) + writing filelog: f011293652b8, p1 000000000000, linkrev 2, 10 bytes, src: *, path: Main/full-exec (glob) changelist 1: writing manifest. node: 05414d16d473 p1: 000000000000 p2: 000000000000 linkrev: 0 changelist 1: writing changelog: initial changelist 2: writing manifest. node: 9408cdd6d4f7 p1: 05414d16d473 p2: 000000000000 linkrev: 1 changelist 2: writing changelog: second - updating the branch cache (?) - 2 revision(s), 3 file(s) imported. + changelist 3: writing manifest. node: c3be37ee7f64 p1: 9408cdd6d4f7 p2: 000000000000 linkrev: 2 + changelist 3: writing changelog: third + updating the branch cache + 3 revision(s), 4 file(s) imported. Verify @@ -72,7 +85,7 @@ checking manifests crosschecking files in changesets and manifests checking files - 3 files, 2 changesets, 6 total revisions + 4 files, 3 changesets, 7 total revisions $ hg update 0 3 files updated, 0 files merged, 0 files removed, 0 files unresolved @@ -92,6 +105,10 @@ c29ae1cbd245c01122ab671684e87b26183de12b 644 Main/b/c f83f0637e55e3c48e9922f14a016761626d79d3d 755 * Main/d + $ hg update tip + 4 files updated, 0 files merged, 0 files removed, 0 files unresolved + $ test -x Main/full-exec + End Test stopping the p4 server