def rungitnorepo(ui, args, gitdir=None, configs=None): """Run git command without an optional repo path, using inherited stdio. Passes --quiet and --verbose to the git command. 'configs' is an optional list of configs in '<name>=<value>' format. """ cmd = [gitbinary(ui)] if configs: for config in configs: cmd += ["-c", config] if gitdir is not None: cmd.append("--git-dir=%s" % gitdir) # bundle is followed by a subcommand if args[0] in {"bundle"}: gitcmd = args[0:2] else: gitcmd = args[0:1] cmdargs = args[len(gitcmd):] cmd += gitcmd gitcmd = tuple(gitcmd) # not all git commands support --verbose or --quiet if ui.verbose and gitcmd in {("fetch", ), ("push", )}: cmd.append("--verbose") if ui.quiet and gitcmd in {("fetch", ), ("init", ), ("push", ), ("bundle", "create")}: cmd.append("--quiet") cmd += cmdargs cmd = " ".join(util.shellquote(c) for c in cmd) tracing.debug("running %s\n" % cmd) # use ui.system, which is compatibile with chg, but goes through shell return ui.system(cmd)
def httpcommitlookup(repo, sample): (knownresponse, _stats) = local.edenapi.commitknown(local.name, sample) commonsample = set() for res in knownresponse: tracing.debug( "edenapi commitknown: %s" % str(res), target="exchange::httpcommitlookup", ) if unwrap(res["known"]): commonsample.add(res["hgid"]) return commonsample
def pushkey(self, namespace, key, old, new): changed = False if namespace == "bookmarks": existing = self.listkeyspatterns(namespace, [key]).get(key, b"") if new != existing: self._inner.setbookmark(key, bin(new)) self._flush() changed = True tracing.debug( "pushkey %s %r: %r => %r (%s)" % (namespace, key, old, new, changed and "success" or "fail")) return changed
def listkeyspatterns(self, namespace, patterns): result = util.sortdict() if namespace == "bookmarks": if not isinstance(patterns, list): patterns = sorted(patterns) # XXX: glob patterns are ignored. books = self.edenapi.bookmarks(patterns) for k, v in books.items(): # ex. {'a': '3131313131313131313131313131313131313131', 'b': None} if v is not None: result[k] = v tracing.debug("listkeyspatterns(%s, %r) = %r" % (namespace, patterns, result)) return result
def submodulecheckout(ctx, match=None, force=False): """Checkout commits specified in submodules""" ui = ctx.repo().ui submodules = parsesubmodules(ctx) if match is not None: submodules = [submod for submod in submodules if match(submod.path)] with progress.bar(ui, _("updating"), _("submodules"), len(submodules)) as prog: value = 0 for submod in submodules: prog.value = (value, submod.name) tracing.debug("checking out submodule %s\n" % submod.name) if submod.path not in ctx: continue fctx = ctx[submod.path] if fctx.flags() != "m": continue node = fctx.filenode() submod.checkout(node, force=force) value += 1
def lookup(self, key): node = None if len(key) == 40: # hex node? try: node = bin(key) except Exception: pass if len(key) == 20: # binary node? node = key if node is not None: if self.known([node]) == [True]: return node # NOTE: Prefix match does not work yet. # bookmark? m = self.listkeyspatterns("bookmarks", [key]) node = m.get(key, None) tracing.debug("lookup %s = %s" % (key, node and hex(node))) if node is None: raise error.RepoLookupError(_("unknown revision %r") % (key,)) return node
def dirsyncfixup(dirstate, old, new, repo=repo): p1, p2 = new mirrored = _nodemirrored.get(p1, None) if not mirrored: return paths = sorted(mirrored) wctx = repo[None] ctx = repo[p1] for path in paths: wf = wctx[path] if path in ctx: # Modified. f = ctx[path] wf.write(f.data(), f.flags()) dirstate.normal(path) tracing.debug("rewrite mirrored %s" % path) else: # Deleted. if wf.exists(): wf.remove() dirstate.delete(path) tracing.debug("remove mirrored %s" % path) # The working copy is in sync. No need to fixup again. _nodemirrored.clear()
def _flush(self): self._inner.flush() tracing.debug("flushed") self._reload()
def heads(self): # Legacy API. Should not be used if selectivepull is on. heads = list(self.dag.heads(self.dag.all())) tracing.debug("heads = %r" % (heads,)) return heads