def update_hg_bookmarks(self, refs): try: oldbm = getattr(bookmarks, 'parse', None) if oldbm: bms = bookmarks.parse(self.repo) else: bms = self.repo._bookmarks heads = dict([(ref[11:],refs[ref]) for ref in refs if ref.startswith('refs/heads/')]) for head, sha in heads.iteritems(): # refs contains all the refs in the server, not just # the ones we are pulling if sha not in self.git.object_store: continue hgsha = bin(self.map_hg_get(sha)) if not head in bms: # new branch bms[head] = hgsha else: bm = self.repo[bms[head]] if bm.ancestor(self.repo[hgsha]) == bm: # fast forward bms[head] = hgsha if heads: if oldbm: bookmarks.write(self.repo, bms) else: self.repo._bookmarks = bms bookmarks.write(self.repo) except AttributeError: self.ui.warn(_('creating bookmarks failed, do you have' ' bookmarks enabled?\n'))
def local_heads(self): try: if getattr(bookmarks, 'parse', None): bms = bookmarks.parse(self.repo) else: bms = self.repo._bookmarks return dict([(bm, hex(bms[bm])) for bm in bms]) except AttributeError: #pragma: no cover return {}
def update_hg_bookmarks(self, refs): try: oldbm = getattr(bookmarks, 'parse', None) if oldbm: bms = bookmarks.parse(self.repo) else: bms = self.repo._bookmarks heads = dict([(ref[11:],refs[ref]) for ref in refs if ref.startswith('refs/heads/')]) for head, sha in heads.iteritems(): # refs contains all the refs in the server, not just # the ones we are pulling if sha not in self.git.object_store: continue hgsha = bin(self.map_hg_get(sha)) if not head in bms: # new branch bms[head] = hgsha else: bm = self.repo[bms[head]] if bm.ancestor(self.repo[hgsha]) == bm: # fast forward bms[head] = hgsha # if there's a branch bookmark suffix, # then add it on to all bookmark names # that would otherwise conflict with a branch # name if self.branch_bookmark_suffix: real_branch_names = self.repo.branchmap() bms = dict( ( bm_name + self.branch_bookmark_suffix if bm_name in real_branch_names else bm_name, bms[bm_name] ) for bm_name in bms ) if heads: if oldbm: bookmarks.write(self.repo, bms) else: self.repo._bookmarks = bms if getattr(bms, 'write', None): # hg >= 2.5 bms.write() else: # hg < 2.5 bookmarks.write(self.repo) except AttributeError: self.ui.warn(_('creating bookmarks failed, do you have' ' bookmarks enabled?\n'))
def update_hg_bookmarks(self, refs): try: oldbm = getattr(bookmarks, 'parse', None) if oldbm: bms = bookmarks.parse(self.repo) else: bms = self.repo._bookmarks heads = dict([(ref[11:], refs[ref]) for ref in refs if ref.startswith('refs/heads/')]) for head, sha in heads.iteritems(): # refs contains all the refs in the server, not just # the ones we are pulling if sha not in self.git.object_store: continue hgsha = bin(self.map_hg_get(sha)) if not head in bms: # new branch bms[head] = hgsha else: bm = self.repo[bms[head]] if bm.ancestor(self.repo[hgsha]) == bm: # fast forward bms[head] = hgsha # if there's a branch bookmark suffix, # then add it on to all bookmark names # that would otherwise conflict with a branch # name if self.branch_bookmark_suffix: real_branch_names = self.repo.branchmap() bms = dict((bm_name + self.branch_bookmark_suffix if bm_name in real_branch_names else bm_name, bms[bm_name]) for bm_name in bms) if heads: if oldbm: bookmarks.write(self.repo, bms) else: self.repo._bookmarks = bms bookmarks.write(self.repo) except AttributeError: self.ui.warn( _('creating bookmarks failed, do you have' ' bookmarks enabled?\n'))