comparison hgext/convert/p4.py @ 25748:baea47cafe75

convert: add support for specifying multiple revs Previously convert could only take one '--rev'. This change allows the user to specify multiple --rev entries. For instance, this could allow converting multiple branches (but not all branches) at once from git. In this first patch, we disable support for this for all sources. Future patches will enable it for select sources (like git).
author Durham Goode <durham@fb.com>
date Wed, 08 Jul 2015 10:27:43 -0700
parents 216fa1ba9993
children 17a9da909186
comparison
equal deleted inserted replaced
25747:5a15236f142a 25748:baea47cafe75
22 yield d 22 yield d
23 except EOFError: 23 except EOFError:
24 pass 24 pass
25 25
26 class p4_source(converter_source): 26 class p4_source(converter_source):
27 def __init__(self, ui, path, rev=None): 27 def __init__(self, ui, path, revs=None):
28 super(p4_source, self).__init__(ui, path, rev=rev) 28 super(p4_source, self).__init__(ui, path, revs=revs)
29 29
30 if "/" in path and not path.startswith('//'): 30 if "/" in path and not path.startswith('//'):
31 raise NoRepo(_('%s does not look like a P4 repository') % path) 31 raise NoRepo(_('%s does not look like a P4 repository') % path)
32 32
33 checktool('p4', abort=False) 33 checktool('p4', abort=False)
47 self.re_keywords = re.compile( 47 self.re_keywords = re.compile(
48 r"\$(Id|Header|Date|DateTime|Change|File|Revision|Author)" 48 r"\$(Id|Header|Date|DateTime|Change|File|Revision|Author)"
49 r":[^$\n]*\$") 49 r":[^$\n]*\$")
50 self.re_keywords_old = re.compile("\$(Id|Header):[^$\n]*\$") 50 self.re_keywords_old = re.compile("\$(Id|Header):[^$\n]*\$")
51 51
52 if revs and len(revs) > 1:
53 raise util.Abort(_("p4 source does not support specifying "
54 "multiple revisions"))
52 self._parse(ui, path) 55 self._parse(ui, path)
53 56
54 def _parse_view(self, path): 57 def _parse_view(self, path):
55 "Read changes affecting the path" 58 "Read changes affecting the path"
56 cmd = 'p4 -G changes -s submitted %s' % util.shellquote(path) 59 cmd = 'p4 -G changes -s submitted %s' % util.shellquote(path)
97 100
98 # handle revision limiting 101 # handle revision limiting
99 startrev = self.ui.config('convert', 'p4.startrev', default=0) 102 startrev = self.ui.config('convert', 'p4.startrev', default=0)
100 self.p4changes = [x for x in self.p4changes 103 self.p4changes = [x for x in self.p4changes
101 if ((not startrev or int(x) >= int(startrev)) and 104 if ((not startrev or int(x) >= int(startrev)) and
102 (not self.rev or int(x) <= int(self.rev)))] 105 (not self.revs or int(x) <= int(self.revs[0])))]
103 106
104 # now read the full changelists to get the list of file revisions 107 # now read the full changelists to get the list of file revisions
105 ui.status(_('collecting p4 changelists\n')) 108 ui.status(_('collecting p4 changelists\n'))
106 lastid = None 109 lastid = None
107 for change in self.p4changes: 110 for change in self.p4changes: