def checkhghelps(ui): errorcnt = 0 for names, sec, doc in helptable: if callable(doc): doc = doc(ui) errorcnt += checkseclevel(ui, doc, "%s help topic" % names[0], initlevel_topic) errorcnt += checkcmdtable(ui, table, "%s command", initlevel_cmd) for name in sorted( list(extensions.enabled()) + list(extensions.disabled())): try: mod = extensions.load(ui, name, None) except ImportError: continue if not mod.__doc__: ui.note(("skip checking %s extension: no help document\n") % name) continue errorcnt += checkseclevel(ui, mod.__doc__, "%s extension" % name, initlevel_ext) cmdtable = getattr(mod, "cmdtable", None) if cmdtable: errorcnt += checkcmdtable(ui, cmdtable, "%%s command of %s extension" % name, initlevel_ext_cmd) return errorcnt
def reposetup(ui, repo): exts = extensions.enabled() for ext in _incompatible_exts: if ext in exts: ui.warn( _( "The hgevents extension is incompatible with the %s " "extension and has been disabled.\n" ) % ext ) return if not repo.local(): return # Ensure there is a Watchman client associated with the repo that # state_update() can use later. try: watchmanclient.createclientforrepo(repo) except Exception as ex: ui.log("hgevents", "Watchman exception: %s\n", ex) return class hgeventsrepo(repo.__class__): def wlocknostateupdate(self, *args, **kwargs): return super(hgeventsrepo, self).wlock(*args, **kwargs) def wlock(self, *args, **kwargs): l = super(hgeventsrepo, self).wlock(*args, **kwargs) if not self._eventreporting: return l if not self.ui.configbool("experimental", "fsmonitor.transaction_notify"): return l if l.held != 1: return l origrelease = l.releasefn def staterelease(): if origrelease: origrelease() if l.stateupdate: with perftrace.trace("Watchman State Exit"): l.stateupdate.exit() l.stateupdate = None try: l.stateupdate = None l.stateupdate = watchmanclient.state_update(self, name="hg.transaction") with perftrace.trace("Watchman State Enter"): l.stateupdate.enter() l.releasefn = staterelease except Exception: # Swallow any errors; fire and forget pass return l repo.__class__ = hgeventsrepo
def reposetup(ui, repo): # We don't work with largefiles or inotify exts = extensions.enabled() for ext in _blacklist: if ext in exts: ui.warn( _( "The fsmonitor extension is incompatible with the %s " "extension and has been disabled.\n" ) % ext ) return # We only work with local repositories if not repo.local(): return # For Eden-backed repositories the eden extension already handles optimizing # dirstate operations. Let the eden extension manage the dirstate in this case. if "eden" in repo.requirements: return # Check if fsmonitor is explicitly disabled for this repository fsmonitorstate = state.state(repo) if fsmonitorstate.mode == "off": return try: watchmanclient.createclientforrepo(repo) except Exception as ex: _handleunavailable(ui, fsmonitorstate, ex) return repo._fsmonitorstate = fsmonitorstate dirstate, cached = localrepo.isfilecached(repo, "dirstate") if cached: # at this point since fsmonitorstate wasn't present, # repo.dirstate is not a fsmonitordirstate makedirstate(repo, dirstate) class fsmonitorrepo(repo.__class__): def status(self, *args, **kwargs): orig = super(fsmonitorrepo, self).status return overridestatus(orig, self, *args, **kwargs) repo.__class__ = fsmonitorrepo
def shelveenabled(repo, ctx, **args): """Bool. Return true if shelve extension is enabled""" return "shelve" in extensions.enabled().keys()
def unamend(ui, repo, **opts): """undo the last amend operation on the current commit Reverse the effects of an :hg:`amend` operation. Hides the current commit and checks out the previous version of the commit. :hg:`unamend` does not revert the state of the working copy, so changes that were added to the commit in the last amend operation become pending changes in the working copy. :hg:`unamend` cannot be run on amended commits that have children. In other words, you cannot unamend an amended commit in the middle of a stack. .. note:: Running :hg:`unamend` is similar to running :hg:`undo --keep` immediately after :hg:`amend`. However, unlike :hg:`undo`, which can only undo an amend if it was the last operation you performed, :hg:`unamend` can unamend any draft amended commit in the graph that does not have children. .. container:: verbose Although :hg:`unamend` is typically used to reverse the effects of :hg:`amend`, it actually rolls back the current commit to its previous version, regardless of whether the changes resulted from an :hg:`amend` operation or from another operation, such as :hg:`rebase`. """ unfi = repo.unfiltered() # identify the commit from which to unamend curctx = repo["."] # identify the commit to which to unamend if mutation.enabled(repo): prednodes = curctx.mutationpredecessors() if not prednodes: prednodes = [] else: prednodes = [ marker.prednode() for marker in predecessormarkers(curctx) ] if len(prednodes) != 1: e = _("changeset must have one predecessor, found %i predecessors") raise error.Abort(e % len(prednodes)) prednode = prednodes[0] if extensions.enabled().get("commitcloud", False): repo.revs("cloudremote(%s)" % nodemod.hex(prednode)) predctx = unfi[prednode] if curctx.children(): raise error.Abort(_("cannot unamend in the middle of a stack")) with repo.wlock(), repo.lock(): ctxbookmarks = curctx.bookmarks() changedfiles = [] wctx = repo[None] wm = wctx.manifest() cm = predctx.manifest() dirstate = repo.dirstate diff = cm.diff(wm) changedfiles.extend(diff.iterkeys()) tr = repo.transaction("unamend") with dirstate.parentchange(): dirstate.rebuild(prednode, cm, changedfiles) # we want added and removed files to be shown # properly, not with ? and ! prefixes for filename, data in diff.iteritems(): if data[0][0] is None: dirstate.add(filename) if data[1][0] is None: dirstate.remove(filename) changes = [] for book in ctxbookmarks: changes.append((book, prednode)) repo._bookmarks.applychanges(repo, tr, changes) if obsolete.isenabled(repo, obsolete.createmarkersopt): obsolete.createmarkers(repo, [(curctx, (predctx, ))]) visibility.remove(repo, [curctx.node()]) visibility.add(repo, [predctx.node()]) tr.close()
def allextensionnames(): return extensions.enabled().keys() + extensions.disabled().keys()
def _maybepull(repo, hexrev): if extensions.enabled().get("commitcloud", False): repo.revs("cloudremote(%s)" % hexrev)