Writing a Bazaar plugin - register command? - plugins

I'm having a problem with writing my Bazaar plugin.
I've been trying a few different things, and this is the current state of my file:
''' Testing Bzr plugins '''
from bzrlib.commands import Command, register_command
version_info = (0,0,1, 'dev')
class cmd_test_foo(Command):
''' Testing is painful. '''
def run(self):
print "hi"
register_command(cmd_test_foo)
Here's what happens when I try to execute my command:
$bzr test-foo
hi
bzr: ERROR: unknown command "test-foo"
So that's really weird - it's obviously running my command, but tells me it's unknown?
Are there any good sources for plugin examples? I've looked at the builtins.py as suggested here but nothing there seemed to help.

Since I couldn't find any real information on this error on the web or SO, I decided I should post and answer my own question.
When Bazaar imports a plugin it creates a .pyc file just like normally importing from Python. If something magical happens - like editing it in one directory and forgetting to copy it, and then creating a symlink - it will never import the modifications. The register_command(cmd_test_foo) call is necessary for bazaar to register the command, where cmd_test_foo is your command name. When you call bzr help commands it will also show up like so:
$ bzr help commands
... (snip commands)
test-foo Testing is painful. [testCmd]
... (snip other commands)
and also
$ bzr plugins
testCmd 0.0.1.dev
Testing Bzr plugins
of course on that last one you'll also see any other plugins you may have installed.

Related

Strange source command when start Julia REPL

I am a bit fresh to Julia (and stack overflow), so it might be a dummy question. I am using VS code in ubuntu 18.04.
Every time I start Julia REPL from VS code (Ctrl+shift+P, then "Julia: Start REPL"), the Julia REPL starts with a strange command "source /home/$user_name/bin/activate" and then an error (of course source is not defined in Julia) :
ERROR: UndefVarError: source not defined
Stacktrace:
[1] top-level scope
# REPL[1]:1
This problem was shown a couple of weeks ago but it does not affect my code at least for now. I have tried to search the problem but haven't found any similar questions. Any hints on what's going on? Many thanks!
Edit:
I think I might have used Conda somewhere.
Do "which Julia", I got:
/home/$user_name/julia-1.7.2/bin//julia
There is no "/home/$user_name/.julia/config/startup.jl" file, all the directories under "/home/$user_name/.julia/" are as follow:
artifacts compiled dev logs prefs scratchspaces
clones conda environments packages registries
Then I found a "startup.jl" file under "$JULIA_INSTALL_FOLDER\etc\julia\startup.jl", with following content (seems like not helping on my problem).
# This file should contain site-specific commands to be executed on Julia startup;
# Users may store their own personal commands in `~/.julia/config/startup.jl`.
Solved by following #SundarR's suggestion.
The problem was caused by the VSCode-Python extension installed.
Please see the comment above for the details and thanks again!

command not found: flow

I followed the Flow installation guide for npm & babel and when I get to the second stage where you flow init I keep getting the error message zsh command not found: flow. I installed flow into my project (a branch of my Gatsby blog) for testing/debugging purposes. It is not installed globally, which is what the Flow docs state is the best practice:
Flow works best when installed per-project with explicit versioning rather than globally.
I have been having a similar issue with Lume that returns zsh command not found: lume
If I enter echo $PATH
The colon delimited list should have user/local/.deno/bin:$PATH but it is not there. If I add it by running:
export PATH="/Users/yourUserName/.deno/bin:$PATH"
Than I am able to run lume commands. However, when I try to run lume commands the next day I have to go through the whole process once more as the error crops up again...
My question here today is regarding the Flow error and getting it sorted. I only mention the Lume error because it makes me fairly certain something is messed up in $Path or my Zsh config. I am just not sure what. The only caveat to that hunch though is that Deno is a global install, whereas Flow is installed directly into my project...
So, maybe the two errors while the same syntax are totally separate?
Thank you in advance for any guidance/suggestions. Cheers!
I came across this video from 2017 no less and the host had issues with flow not working within the project and so he installed it globally. I gave it a shot and the flow error zsh command not found: flow has been resolved...

Confusion: GitHub Project broken(?), Instructions not clear: Mercurial setup(?)

first of all, i've never done something with github, this is my first try, so please be polite and help me on the train.
I would like to use this github-project:
https://github.com/jmmcatee/cracklord which is completly in go language.
from the instructions:
If you'd like to get things build from source, it will first require you to have a working Go build environment with the GOPATH setup. Additionally, you'll probably want Git and Mercurial setup to gather the various libraries and plugins that we've used in the code.
Here are my Questions:
I've done installing git and i'm able to clone the repro, which works fine.
I've installed mercurial, but have no idea how to "setup" mercurial.
Can someone explain what mercurial setup togehter with this githubproject example means?
why i'm asking
after creating a directory git-repos
changing into this directory with cd git-repos
path is now /root/git-repos
# set GOPATH to /root/git-repos
export GOPATH=/root/git-repos
and doing go get github.com/jmmcatee/cracklord
gives this error-message:
go get github.com/jmmcatee/cracklord
can't load package: package github.com/jmmcatee/cracklord: no Go files in /root/git-repos/src/github.com/jmmcatee/cracklord
okay.
So, when i'm following the instructions i'm not able to finish. Can someone explain what i'm doing wrong?
Thank you
Paul
You don't need to set gopath anymore, it is set by default to:
~/go
You don't say which os you're using, but given your paths I assume linux. I suspect you haven't exported the environment variable correctly. You might want to try setting up a simpler package first and verifying you have your go setup right. Follow the instructions here (including verifying your setup is working, and just using the default gopath):
https://golang.org/doc/install
And try downloading and running something simpler (which doesn't require several components installed) to verify your setup first.

how to get autocomplete programmatically?

I would like to get autocomplete suggestions for a command line (e.g. git)
but through code in nodejs
so basically, I want to write code that given a command line, gets the autocomplete result.
for example: git b should output bisect blame branch bundle
so far I've tried using shelljs with the following:
shell.exec('git b\t\t', function(code, output){
console.log(output);
})
but I keep getting errors from git. 'b' is not a git command. See 'git --help'.
EDIT
currently I am using solution from:
Accessing bash completions for specific commands programmatically
but this solution is very specific to OS and command.
I am still interested in a library that will do it for me or some real easy solution.
how to get this done? is there a better way to resolve this?

How do I get the latest Mercurial tag from within Powershell

If i run the following command from a DOS prompt:
hg parents --template {latesttag}
then I get the latest tag value returned as expected. However if I run the same command from within a powershell console I get the following error:
hg parents: option -i not recognized
I need the command to run in powershell so I can get it's results as a variable to use. Any idea what I need to do to get the command running?
You should just need to surround the argument to --template in quotes so that Powershell knows it's a string:
hg parents --template '{latesttag}'
Sometimes, however, with the way Powershell parses things you have to make doubly sure that double-quotes survive (such as passing an argument that contains spaces but should be 1 argument instead of many, like paths or a longer template):
hg parents --template '"{latesttag}"'
This answer comes with a huge disclaimer:
There might be better/different ways than this one, harnessing only PowerShell code, but I'm no PowerShell expert
I am the author of the following class library
I have made a .NET class library, Mercurial.Net that allows a .NET program to wrap around the hg command line client without having to deal with all the intricacies of doing all of that, waiting for the program to complete, etc. Note: You will need Mercurial installed, and available through the PATH for the class library to work.
It can be installed through Nuget package.
Since I'm no PowerShell expert, I'll show how to do this with C# code and my library.
Considering that the library does not implement all options (yet), sadly the parents command cannot be used by my library, but the log command can, although it will probably have more overhead. You will have to be the judge of whether this is acceptable.
The reason the parents command cannot be used is that I have, for now, decided not to implement support for the templating syntax in Mercurial, because then I know what kind of output to expect and can parse that back into proper .NET instances.
Here's the .NET code that would find the tipmost tag:
var repo = new Repository(".");
var tags = repo.Log(new LogCommand().WithRevision("tag()")).First().Tags.ToArray();
This will populate tags with an array of tag-names. The log command returns the log in reverse order, newest changesets first, so .First() will find the newest changeset.
If you need the closest tag that is also an ancestor of the current working folder, here's the changed code:
repo.Log(new LogCommand().WithRevision("tag() and ancestors(.)")).First().Tags...
^---------------^
This includes the revision of the working folder if that has a tag. If you need the ancestor, not including the revision of the working folder:
repo.Log(new LogCommand().WithRevision("tag() and ancestors(.) and not .")).First().Tags...
^--------^