Mercurial > hg
diff hgext/convert/hg.py @ 5934:e495f3f35b2d
convert: hg.clonebranches must pull missing parents (issue941)
author | Patrick Mezard <pmezard@gmail.com> |
---|---|
date | Sat, 26 Jan 2008 19:55:04 +0100 |
parents | 1716c8a0bd09 |
children | 0162c6cc045e |
line wrap: on
line diff
--- a/hgext/convert/hg.py Tue Jan 22 00:16:50 2008 +0100 +++ b/hgext/convert/hg.py Sat Jan 26 19:55:04 2008 +0100 @@ -80,30 +80,43 @@ except OSError: pass - def setbranch(self, branch, pbranch, parents): - if (not self.clonebranches) or (branch == self.lastbranch): + def setbranch(self, branch, pbranches): + if not self.clonebranches: return + setbranch = (branch != self.lastbranch) self.lastbranch = branch - self.after() if not branch: branch = 'default' - if not pbranch: - pbranch = 'default' + pbranches = [(b[0], b[1] and b[1] or 'default') for b in pbranches] + pbranch = pbranches and pbranches[0][1] or 'default' branchpath = os.path.join(self.path, branch) - try: - self.repo = hg.repository(self.ui, branchpath) - except: - if not parents: + if setbranch: + self.after() + try: + self.repo = hg.repository(self.ui, branchpath) + except: self.repo = hg.repository(self.ui, branchpath, create=True) - else: - self.ui.note(_('cloning branch %s to %s\n') % (pbranch, branch)) - hg.clone(self.ui, os.path.join(self.path, pbranch), - branchpath, rev=parents, update=False, - stream=True) - self.repo = hg.repository(self.ui, branchpath) - self.before() + self.before() + + # pbranches may bring revisions from other branches (merge parents) + # Make sure we have them, or pull them. + missings = {} + for b in pbranches: + try: + self.repo.lookup(b[0]) + except: + missings.setdefault(b[1], []).append(b[0]) + + if missings: + self.after() + for pbranch, heads in missings.iteritems(): + pbranchpath = os.path.join(self.path, pbranch) + prepo = hg.repository(self.ui, pbranchpath) + self.ui.note(_('pulling from %s into %s\n') % (pbranch, branch)) + self.repo.pull(prepo, [prepo.lookup(h) for h in heads]) + self.before() def putcommit(self, files, parents, commit): seen = {}