comparison hgext/convert/p4.py @ 28371:630f5f04bc74

convert: p4 use absolute_import
author timeless <timeless@mozdev.org>
date Wed, 02 Mar 2016 15:31:15 +0000
parents aaa33ec3c951
children a0939666b836
comparison
equal deleted inserted replaced
28370:c1878afb063a 28371:630f5f04bc74
2 # 2 #
3 # Copyright 2009, Frank Kingswood <frank@kingswood-consulting.co.uk> 3 # Copyright 2009, Frank Kingswood <frank@kingswood-consulting.co.uk>
4 # 4 #
5 # This software may be used and distributed according to the terms of the 5 # This software may be used and distributed according to the terms of the
6 # GNU General Public License version 2 or any later version. 6 # GNU General Public License version 2 or any later version.
7 7 from __future__ import absolute_import
8 from mercurial import util, error 8
9 from mercurial.i18n import _
10
11 from common import commit, converter_source, checktool, NoRepo
12 import marshal 9 import marshal
13 import re 10 import re
11
12 from mercurial import (
13 error,
14 util,
15 )
16 from mercurial.i18n import _
17
18 from . import common
14 19
15 def loaditer(f): 20 def loaditer(f):
16 "Yield the dictionary objects generated by p4" 21 "Yield the dictionary objects generated by p4"
17 try: 22 try:
18 while True: 23 while True:
35 replacements = [('%2A', '*'), ('%23', '#'), ('%40', '@'), ('%25', '%')] 40 replacements = [('%2A', '*'), ('%23', '#'), ('%40', '@'), ('%25', '%')]
36 for k, v in replacements: 41 for k, v in replacements:
37 filename = filename.replace(k, v) 42 filename = filename.replace(k, v)
38 return filename 43 return filename
39 44
40 class p4_source(converter_source): 45 class p4_source(common.converter_source):
41 def __init__(self, ui, path, revs=None): 46 def __init__(self, ui, path, revs=None):
42 # avoid import cycle 47 # avoid import cycle
43 import convcmd 48 from . import convcmd
44 49
45 super(p4_source, self).__init__(ui, path, revs=revs) 50 super(p4_source, self).__init__(ui, path, revs=revs)
46 51
47 if "/" in path and not path.startswith('//'): 52 if "/" in path and not path.startswith('//'):
48 raise NoRepo(_('%s does not look like a P4 repository') % path) 53 raise common.NoRepo(_('%s does not look like a P4 repository') %
49 54 path)
50 checktool('p4', abort=False) 55
56 common.checktool('p4', abort=False)
51 57
52 self.p4changes = {} 58 self.p4changes = {}
53 self.heads = {} 59 self.heads = {}
54 self.changeset = {} 60 self.changeset = {}
55 self.files = {} 61 self.files = {}
140 parents = [lastid] 146 parents = [lastid]
141 else: 147 else:
142 parents = [] 148 parents = []
143 149
144 date = (int(d["time"]), 0) # timezone not set 150 date = (int(d["time"]), 0) # timezone not set
145 c = commit(author=self.recode(d["user"]), 151 c = common.commit(author=self.recode(d["user"]),
146 date=util.datestr(date, '%Y-%m-%d %H:%M:%S %1%2'), 152 date=util.datestr(date, '%Y-%m-%d %H:%M:%S %1%2'),
147 parents=parents, desc=desc, branch=None, 153 parents=parents, desc=desc, branch=None,
148 extra={"p4": change}) 154 extra={"p4": change})
149 155
150 files = [] 156 files = []
151 copies = {} 157 copies = {}
152 copiedfiles = [] 158 copiedfiles = []
153 i = 0 159 i = 0