diff --git a/hgext3rd/p4fastimport/p4.py b/hgext3rd/p4fastimport/p4.py --- a/hgext3rd/p4fastimport/p4.py +++ b/hgext3rd/p4fastimport/p4.py @@ -408,8 +408,9 @@ ACTION_EDIT = ['edit', 'integrate'] ACTION_ADD = ['add', 'branch', 'move/add'] ACTION_DELETE = ['delete', 'move/delete'] +ACTION_PURGE = ['purge'] ACTION_ARCHIVE = ['archive'] -SUPPORTED_ACTIONS = ACTION_EDIT + ACTION_ADD + ACTION_DELETE +SUPPORTED_ACTIONS = ACTION_EDIT + ACTION_ADD + ACTION_DELETE + ACTION_PURGE class P4Changelist(object): def __init__(self, origclnum, clnum, user, commit_time_diff): @@ -483,7 +484,13 @@ """ a, m, r = [], [], [] for fname, info in self.parsed['files'].iteritems(): - if info['action'] in ACTION_EDIT: + if info['action'] in ACTION_EDIT + ACTION_PURGE: + # A changelist reports a file as "purged" when the file data no + # longer exists due to the +S filetype attribute. However, on + # the Hg side, we do want to record that the file is part of + # the changeset. For one thing, we already imported the + # filelog, and now we need a changeset for that revision in the + # index file to link to. m.append(fname) elif info['action'] in ACTION_ADD: a.append(fname) diff --git a/tests/test-p4fastimport-import.t b/tests/test-p4fastimport-import.t --- a/tests/test-p4fastimport-import.t +++ b/tests/test-p4fastimport-import.t @@ -48,6 +48,10 @@ $ p4 archive -t -D archive //depot/Main/d Archiving //depot/Main/d#2 to //archive/depot/Main/d. Archiving //depot/Main/d#1 to //archive/depot/Main/d. + $ p4 filelog //depot/Main/d | cut -d ' ' -f 2- + //depot/Main/d + #2 change 2 archive on * by *@hg-p4-import (text) 'second' (glob) + #1 change 1 archive on * by *@hg-p4-import (text) 'initial' (glob) Test keyword extension $ cat >test.c < tmpattrib.txt + $ p4 add -t +S tmpattrib.txt + //depot/tmpattrib.txt#1 - opened for add + $ p4 submit -d "tmpattrib 1" + Submitting change 5. + Locking 1 files ... + add //depot/tmpattrib.txt#1 + Change 5 submitted. + $ p4 edit tmpattrib.txt + //depot/tmpattrib.txt#1 - opened for edit + $ echo rev2 > tmpattrib.txt + $ p4 submit -d "tmpattrib 2" + Submitting change 6. + Locking 1 files ... + edit //depot/tmpattrib.txt#2 + Change 6 submitted. + $ p4 filelog //depot/tmpattrib.txt | cut -d ' ' -f 2- + //depot/tmpattrib.txt + #2 change 6 edit on * by *@hg-p4-import (text+S) 'tmpattrib 2' (glob) + #1 change 5 purge on * by *@hg-p4-import (text+S) 'tmpattrib 1' (glob) + Simple import $ cd $hgwd $ hg init --config 'format.usefncache=False' $ hg p4fastimport --bookmark master --debug -P $P4ROOT hg-p4-import loading changelist numbers. - 4 changelists to import. + 6 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) @@ -107,6 +135,8 @@ writing filelog: b11e10a88bfa, p1 149da44f2a4e, linkrev 1, 4 bytes, src: *, path: Main/b/c (glob) writing filelog: 7083c74fbb1d, p1 000000000000, linkrev 2, 68 bytes, src: *, path: test.c (glob) writing filelog: 67de97119b9e, p1 7083c74fbb1d, linkrev 3, 68 bytes, src: *, path: test.c (glob) + writing filelog: b80de5d13875, p1 000000000000, linkrev 4, 0 bytes, src: *, path: tmpattrib.txt (glob) + writing filelog: e866cbe6aaa7, p1 b80de5d13875, linkrev 5, 5 bytes, src: *, path: tmpattrib.txt (glob) changelist 1: writing manifest. node: a9ab65129a6d p1: 000000000000 p2: 000000000000 linkrev: 0 changelist 1: writing changelog: initial changelist 2: writing manifest. node: aff99eae550e p1: a9ab65129a6d p2: 000000000000 linkrev: 1 @@ -115,9 +145,13 @@ changelist 3: writing changelog: before_expand changelist 4: writing manifest. node: 6bd331e4b9db p1: 25805ee52828 p2: 000000000000 linkrev: 3 changelist 4: writing changelog: after_expand + changelist 5: writing manifest. node: dfcbd947663f p1: 6bd331e4b9db p2: 000000000000 linkrev: 4 + changelist 5: writing changelog: tmpattrib 1 + changelist 6: writing manifest. node: 1861e05e6835 p1: dfcbd947663f p2: 000000000000 linkrev: 5 + changelist 6: writing changelog: tmpattrib 2 writing bookmark updating the branch cache - 4 revision(s), 3 file(s) imported. + 6 revision(s), 4 file(s) imported. $ hg cat -r tip test.c $Id$ $Header$ @@ -135,16 +169,17 @@ checking manifests crosschecking files in changesets and manifests checking files - 3 files, 4 changesets, 6 total revisions + 4 files, 6 changesets, 8 total revisions $ hg update master - 3 files updated, 0 files merged, 0 files removed, 0 files unresolved + 4 files updated, 0 files merged, 0 files removed, 0 files unresolved (activating bookmark master) $ hg manifest -r master Main/a Main/b/c test.c + tmpattrib.txt End Test