comparison hgext/convert/bzr.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 56b2bcea2529
comparison
equal deleted inserted replaced
25747:5a15236f142a 25748:baea47cafe75
31 supportedkinds = ('file', 'symlink') 31 supportedkinds = ('file', 'symlink')
32 32
33 class bzr_source(converter_source): 33 class bzr_source(converter_source):
34 """Reads Bazaar repositories by using the Bazaar Python libraries""" 34 """Reads Bazaar repositories by using the Bazaar Python libraries"""
35 35
36 def __init__(self, ui, path, rev=None): 36 def __init__(self, ui, path, revs=None):
37 super(bzr_source, self).__init__(ui, path, rev=rev) 37 super(bzr_source, self).__init__(ui, path, revs=revs)
38 38
39 if not os.path.exists(os.path.join(path, '.bzr')): 39 if not os.path.exists(os.path.join(path, '.bzr')):
40 raise NoRepo(_('%s does not look like a Bazaar repository') 40 raise NoRepo(_('%s does not look like a Bazaar repository')
41 % path) 41 % path)
42 42
93 93
94 def _bzrbranches(self): 94 def _bzrbranches(self):
95 return self.sourcerepo.find_branches(using=True) 95 return self.sourcerepo.find_branches(using=True)
96 96
97 def getheads(self): 97 def getheads(self):
98 if not self.rev: 98 if not self.revs:
99 # Set using=True to avoid nested repositories (see issue3254) 99 # Set using=True to avoid nested repositories (see issue3254)
100 heads = sorted([b.last_revision() for b in self._bzrbranches()]) 100 heads = sorted([b.last_revision() for b in self._bzrbranches()])
101 else: 101 else:
102 revid = None 102 revid = None
103 for branch in self._bzrbranches(): 103 for branch in self._bzrbranches():
104 try: 104 try:
105 r = RevisionSpec.from_string(self.rev) 105 r = RevisionSpec.from_string(self.revs[0])
106 info = r.in_history(branch) 106 info = r.in_history(branch)
107 except errors.BzrError: 107 except errors.BzrError:
108 pass 108 pass
109 revid = info.rev_id 109 revid = info.rev_id
110 if revid is None: 110 if revid is None:
111 raise util.Abort(_('%s is not a valid revision') % self.rev) 111 raise util.Abort(_('%s is not a valid revision') % self.revs[0])
112 heads = [revid] 112 heads = [revid]
113 # Empty repositories return 'null:', which cannot be retrieved 113 # Empty repositories return 'null:', which cannot be retrieved
114 heads = [h for h in heads if h != 'null:'] 114 heads = [h for h in heads if h != 'null:']
115 return heads 115 return heads
116 116