def activebookmark(repo): if hasattr(repo, "_activebookmark"): return repo._activebookmark elif hasattr(bookmarks, "readactive"): return bookmarks.readactive(repo) else: return bookmarks.readcurrent(repo)
def activebookmark(repo): if hasattr(repo, '_activebookmark'): return repo._activebookmark elif hasattr(bookmarks, 'readactive'): return bookmarks.readactive(repo) else: return bookmarks.readcurrent(repo)
def hg_readactive(repo): if hg_version() >= '3.7': return _readactive(repo,repo._bookmarks) elif hg_version() >= '3.5' and hg_version() < '3.7': return readactive(repo) else: return readcurrent(repo)
def do_list(self, parser): '''List all references in the mercurial repository. This includes the current head, all branches, tags, and bookmarks.''' current_branch = self.repo.dirstate.branch() # Update the head reference head = readcurrent(self.repo) if head: node = self.repo[head] else: # If there is no bookmark for head, mock one head = current_branch node = self.repo['.'] # I think this means an initial clone occured and we haven't # hg updated yet in the local clone if not node: if 'default' in self.repo: node = self.repo['default'] else: # empty repository or head is at 0 commit output() return head = head if head != 'default' else 'master' #self.bookmarks[head] = node self.headnode = (head, node) # Update the bookmark references for bookmark, node in listbookmarks(self.repo).iteritems(): self.bookmarks[bookmark] = self.repo[node] # update the named branch references for branch in self.repo.branchmap(): heads = self.repo.branchheads(branch, closed=True) if heads: self.branches[branch] = heads # list the head reference output("@refs/heads/%s HEAD" % self.headnode[0]) # list the named branch references for branch in self.branches: if branch != "default": output("? refs/heads/branches/%s" % hg_to_git_spaces(branch)) else: output("? refs/heads/master") # list the bookmark references for bookmark in self.bookmarks: if bookmark != "master": output("? refs/heads/%s" % hg_to_git_spaces(bookmark)) # list the tags for tag, node in self.repo.tagslist(): if tag != "tip": output("? refs/tags/%s" % hg_to_git_spaces(tag)) output()
def do_list(self, parser): """List all references in the mercurial repository. This includes the current head, all branches, tags, and bookmarks.""" current_branch = self.repo.dirstate.branch() # Update the head reference if hg_version() >= "4.0.1": head = _readactive(self.repo, self.repo._bookmarks) else: head = readcurrent(self.repo) if head: node = self.repo[head] else: # If there is no bookmark for head, mock one head = current_branch node = self.repo["."] # I think this means an initial clone occured and we haven't # hg updated yet in the local clone if not node: if "default" in self.repo: node = self.repo["default"] else: # empty repository or head is at 0 commit output() return head = head if head != "default" else "master" # self.bookmarks[head] = node self.headnode = (head, node) # Update the bookmark references for bookmark, node in listbookmarks(self.repo).iteritems(): self.bookmarks[bookmark] = self.repo[node] # update the named branch references for branch in self.repo.branchmap(): # FIXME: Probably a git config instead of an env var would make # people happier here. clone_closed = os.environ.get("GITIFYHG_ALLOW_CLOSED_BRANCHES") != None heads = self.repo.branchheads(branch, closed=clone_closed) if heads: self.branches[branch] = heads # list the head reference output("@refs/heads/%s HEAD" % self.headnode[0]) # list the named branch references for branch in self.branches: output( "%s %s" % (self._change_hash(branch_head(self, branch)), name_reftype_to_ref(hg_to_git_spaces(branch), BRANCH)) ) # list the bookmark references for bookmark, changectx in self.bookmarks.items(): if bookmark != "master": output( "%s %s" % (self._change_hash(changectx), name_reftype_to_ref(hg_to_git_spaces(bookmark), BOOKMARK)) ) # list the tags for tag, node in self.repo.tagslist(): if tag != "tip": output("%s %s" % (self._change_hash(self.repo[node]), name_reftype_to_ref(hg_to_git_spaces(tag), TAG))) output()
def do_list(self, parser): '''List all references in the mercurial repository. This includes the current head, all branches, tags, and bookmarks.''' current_branch = self.repo.dirstate.branch() # Update the head reference head = readcurrent(self.repo) if head: node = self.repo[head] else: # If there is no bookmark for head, mock one head = current_branch node = self.repo['.'] # I think this means an initial clone occured and we haven't # hg updated yet in the local clone if not node: if 'default' in self.repo: node = self.repo['default'] else: # empty repository or head is at 0 commit output() return head = head if head != 'default' else 'master' #self.bookmarks[head] = node self.headnode = (head, node) # Update the bookmark references for bookmark, node in listbookmarks(self.repo).iteritems(): self.bookmarks[bookmark] = self.repo[node] # update the named branch references for branch in self.repo.branchmap(): # FIXME: Probably a git config instead of an env var would make # people happier here. clone_closed = os.environ.get( "GITIFYHG_ALLOW_CLOSED_BRANCHES") != None heads = self.repo.branchheads(branch, closed=clone_closed) if heads: self.branches[branch] = heads # list the head reference output("@refs/heads/%s HEAD" % self.headnode[0]) # list the named branch references for branch in self.branches: output("%s %s" % (self._change_hash(branch_head(self, branch)), name_reftype_to_ref(hg_to_git_spaces(branch), BRANCH))) # list the bookmark references for bookmark, changectx in self.bookmarks.items(): if bookmark != "master": output("%s %s" % (self._change_hash(changectx), name_reftype_to_ref( hg_to_git_spaces(bookmark), BOOKMARK))) # list the tags for tag, node in self.repo.tagslist(): if tag != "tip": output("%s %s" % (self._change_hash(self.repo[node]), name_reftype_to_ref(hg_to_git_spaces(tag), TAG))) output()