solving Mercurial and IntelliJ IDEA project root mismatch? - mercurial

I have a mercurial repository which has several projects (from an IntelliJ IDEA sense) within it. for example, I might have:
foo/
projects/
project1/
.idea/
project2/
.idea/
I can push,pull,commit etc fine with command-line and TortoiseHG. I've enabled Mercurial (hg4idea plugin) within IntelliJ yet almost nothing seems to be working. If I add a source code file it doesn't get added, for files I've added manually they show no changes. In IntelliJ the Mercurial menu is enabled but "add to VCS" is always greyed out. However, IntelliJ correctly lists available changesets from a remote repository.
In the Version Control window for commands like "hg status" I get errors like:
abort: repository C:/foo/projects/project1 not found!
Commands like "hg incoming" seem to be succeeding.
I suspect this might be because the project root (project1) is below the repository root (foo). Does anyone know how to resolve this problem? Is there a configuration change I can make? If so, where in the settings is it?
I'm using the latest (10.0.3) IntelliJ IDEA Community edition.

I managed to work this one out myself. When you enable the project for Mercurial, IntelliJ sets the project root by default as the mercurial repository directory. With the help of this help page I worked out this was what I needed to change.
Go to the Settings dialog (File-Settings)
Choose Version Control
At the top level it shows a list of Directories and VCS's, mine said "project root" and "Mercurial"
Click "Remove" to remove the existing mapping.
Click "Add" to add a mapping, and use the "..." button to choose the mercurial root - "foo" in the example above.
This changes the vcs.xml file in the .idea directory.

The steps provided by Nick work for me in a similar setup with multiple projects living in the same Mercurial repository.
I was worried that IDEA would use absolute paths in vcs.xml but it's more intelligent:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="hg4idea" />
</component>
</project>

Related

How to disable version control in phpstorm?

I am playing around with phpstorm and somehow I activated version control. I don't need it. Now all my tabs are different: orange text on gray background. All files in the file view are orange. How do I disable version control?
Go to Settings -> Version Control and remove the folder from which you would like to remove version control tracking (coloring tabs etc.) It will naturally not remove version control from your project (as in deleting the .git/ folder for instance).
The ultimate way is to disable all version control plugins (under Settings -> Plugins): CVS Integration, Git Integration, GitHub, hg4idea, Perforce Integration, Subversion Integration. After restarting PhpStorm Settings -> Version Control tab will be gone.
Note that this will disable version control for all of your projects.
You can just remove vcs.xml from .idea folder and then restart PhpStorm
In phpStorm 2022.1.3+, go to
Preferences > Version Control > Directory Mappings
Then remove the directories you don't want to watch, as Greg suggested.
Go to Settings -> Version Control and remove the folder from which you would liek to remove version control.
I have not enough reputation to +1 Greg's answer or comment, but... for those who are interrested : the same goes for Webstorm.
I had this problem and I used from 2 of notes in these answers in these page together.
As Greg has mentioned in one of replies, your git repository is in .git sub directory inside directory that you want to manage it with version control system. When you define a git repository, PhpStorm automatically generate it and with creating this sub directory, it adds a file for handling mapping between itself and version control system. It calls vcs.xml and it's located in .idea sub directory.
It's not enough to remove only .git directory. When you remove .git, you will get an error in PhpStorm every time that you open your project due to not matching vcs.xml for mapping between PhpStorm and git repository of your project. So after removing .git directory, you must also remove vcs.xml files from .idea and now you won't have any error or warning in your PhpStorm.
It doesn't need to restart PhpStorm at all and after this, colors of all of files that was mentioned in questions return to normal colors in PhpStorm.

My intellij java project can't find misc.xml

I have a java project in Intellij and use Hg/Mercurial for version control. I ignored some files with this .hgignore file
syntax: glob
target/*
.idea/*
*.iml
and deleted all these files which was committed before. but now I can't execute my project, cause it can not find the file misc.xml.
What should I do?
Updated answer for IntelliJ 14+: File-> New-> Project from Existing Sources... (choose your project directory) and follow the wizard Q&A.
Restarting Intellij should fix the problem. Just make sure you click on the "Import Project" pop-up that appears on the top right.
At first, you shouldn't really ignore everything under .idea but instead only .idea/workspace.xml and .idea/tasks.xml, as it JetBrains states: http://devnet.jetbrains.com/docs/DOC-1186
To solve your problem and get your project back to working state there are possibly two solutions:
Checkout the last commit that contains the files under .idea folder with
hg checkout SHA,
where SHA is the commit id.
After that reset your working space to the head:
hg reset HEAD
Edit your .hgignore in the way that was recommended before, add project files to stage, and commit them:
hg commit -am "Reverted project settings"
If there is no commit with the project settings, you can just import your code back.
Start Intellij IDEA and choose "Import Project". Choose the folder with your code, and choose the appropriate SDK after.
I met this problem when I did rm -rf project command, then when I git clone a new project to my working space, maybe quit the idea and then import the project again. This can easily solve this
I have found that for this error and also for some other cases where the IDE project behavior is inconsistent with command line behavior, the following often helps: close the project's Intellij IDEA window, delete .idea/, and open the project again. IntelliJ often flashes up a message saying it didn't find a project root but generally this disappears after a few seconds and IntelliJ automatically rebuilds the .idea directory.
Recreating the .idea folder
File -> Close project
File -> Open -> Choose pom.xml under the project folder -> Open as project -> Delete existing project and import

Why do VCS changes disappear from the changes view when using IntelliJ 11 and Mercurial?

I'm using IntelliJ Ultimate 11.1 with the bundled HG plugin. When I change a file it appears in the changes view but disappears when I switch to another app. TortoiseHG still sees the change, i.e. 'hg status' shows the files, but IntelliJ just doesn't show it.
I have tried changing the configuration options but without success.
The solution was setting IntelliJ to monitor the repository root and not the source code root.

mercurial-reviewboard plugin no longer working with TortoiseHg 2.4.3

I had just barely gotten the Mercurial-Reviewboard plugin working with TortoiseHG 2.4.2 when I upgraded to TortoiseHG 2.4.3 and it stopped working.
It's now throwing the following error when I click the "Post Review" button.
"postreview plugin version 4.1.0"
"'module' object has no attribute 'findoutgoing'"
I've tried many different branches of the plugin and have had zero luck. The one I have right now is Fredrik Haard's and can be found here:https://bitbucket.org/haard/mercurial-reviewboard
Unfortunately he hasn't updated it in some time.
I've tried looking through the source for the plugin but know next to nothing about Python in general and Mercurial plugins in specific.
If anyone can help in any way I'd greatly appreciate it.
I had this same error "'module' object has no attribute 'findoutgoing'", using the following:
TortoiseHG: 2.4.3 (with Mercurial-2.3.2, Python-2.7.3, PyQt-4.9.3, Qt-4.8.2)
Reviewboard: 1.6.13
Mercurial-reviewboard plugin: windix-mercurial-reviewboard (4.1.0) from 2012-08-30 and with the following change in reviewboard.py at line 400:
self._api_post('/account/login/', {
instead of
self._api_post('/api/json/accounts/login/', {
I only have a local repository, towards which Reviewboard points using the path on the disk.
The problem was fixed as soon as I added in the .hg/hgrc file of that repository, the following:
[paths]
default = http://localhost:8003
where 8003 is the port I configured for the same repo, in the same file inside that repo.
I have two more local repos, in the same situation - no remote base - configured for 8000 and 8005 respectively, I am now able to post review requests from the TortoiseHG user interface for all of them (after having added for each of these repos, the [paths] section and the default url like above).
I hope this helps!
While still having some problems, 'my' fork works for me right now although there are encoding errors for source files that are non-ascii. If it does not work for you (commit from 2012-24-10), and the problems you have are not related to encoding (working on those), could you please describe what is happening/provide log messages?

Can Jenkins store artifacts outside the job directory?

I currently have Jenkins set up with a number of jobs, but it's proving difficult to back up because the artifacts are stored within the job directory. I'd like to back up the job configurations and artifacts separately. I'm sure I remember reading somewhere that Jenkins now has an option to store them outside the job, but I can't find this.
Is there any configuration option that does this while still making the artifacts visible from within the job on the Jenkins interface? (ie rather than merely an add-in that copies the artifacts elsewhere)
Go to your jenkins configuration page, e.g.
http://mybuildserver.acme.com/configure
At the top of the configuration page there is a "home directory" setting. Click the "advanced..." button below it.
Now set the "Workspace Root Directory" to e:\jenkins-workspaces\${ITEM_FULL_NAME}, and "Build Record Root Directory" to e:\jenkins-builds\${ITEM_FULL_NAME} or something similar.
Warning: I run Jenkins 2.7.2 and noticed that certain features don't work properly after configuring Jenkins like that. I saw problems with folders and problems with the multi-branch project plugin. Check the status of those issues if your rely on these features.
As you can see here, there are many plugins to deploy artifacts anywhere you want/need, on FTP, CIFS, Confluence, Artifactory.... especially the ArtifactsDeployer that will allow you to make a copy of the artifacts in the Jenkins Home.
Thank you Sam, for your post, which directed me into the right direction to solve my problem.
Have been searching for a way on how can I make a symlink to the Job-Archive of a build for multibranch projects. Up to now, we used to manually search for the correct folder basename in the filesystem and added that one to the Jenkinsfile.
Now, I can simply use
jobOutputFolder = currentBuild.rawBuild.artifactsDir.path
and use that in my script.
If security is a concern, I could implement that as a shared library additionally.
Try the Use Custom Workspace build option. From the Jenkins popup help:
For each job on Jenkins, Jenkins allocates a unique "workspace
directory." This is the directory where the code is checked out and
builds happen. Normally you should let Jenkins allocate and clean up
workspace directories, but in several situations this is problematic,
and in such case, this option lets you specify the workspace location
manually.
This option is also available under advanced project properties of multi-configuration project builds.
A groovy script under "Prepare an environment for the run" will always run on the master, and this groovy script can create a symlink to where you really want artifacts archiving to archive_to which SHOULD include the job name and build number:
if (! Files.createSymbolicLink(Paths.get(currentBuild.artifactsDir.path),
Paths.get(archive_to.getCanonicalPath()))) {
throw new RuntimeException("Can't create symlink to archive dir")
}
Of course (sadly) when old builds are purged by Jenkins the old artifacts are left because jenkins will not follow a symlink when purging, even if jenkins owns the symlink and the target (shame).
I workaround for that may be to point a symlink back from the new archive dir, then, when jenkins purges it's archive dir, the new symlink will dangle and a cron job can then later delete the new job archive dir
Copy Artifact Plugin (https://wiki.jenkins-ci.org/display/JENKINS/Copy+Artifact+Plugin) adds a build step for retrieving files from another project's workspace to current and work from there.