How to set different user for each mercurial repository? - iis-7

I install mercurial repository on IIS7 (use cgi). I have two different repos and I want to share the rights for each repository. How do I do? My hgweb.config
[paths]
/ = c:\repos\*
[web]
allow_push = user1
push_ssl = true
allow_archive = gz bz2 zip
style = paper

You can put the [web] section in each individual repository’s .hg/hgrc file. This way you can specify repository-specific users, style, description, etc.

Related

with rstudio and github, issue with renamed repo

I had a repository named tags, I renamed it to tag.
I then created a new repository named tags (the old name of the first one).
Now when commiting from R Studio both projects try to commit to the same repository (tags).
I initiated my projects with :
shell("git remote add origin https://github.com/moodymudskipper/tag.git", intern = TRUE)
shell("git push -u origin master",intern = TRUE)
and
shell("git remote add origin https://github.com/moodymudskipper/tags.git",intern = TRUE)
shell("git push -u origin master",intern = TRUE)
And after this I only committed through Rstudio's API and usethis functions, I don't know much more than that about git.
Links to the packages :
https://github.com/moodymudskipper/tag
https://github.com/moodymudskipper/tags
How can I sort this out ?
I'm hesitant to throw this out as an answer, but: you can manually edit the ./.git/config file to update the [remote ...] section to change the remote URL. I have done this confidently enough with an empty repo ...
Check for presence of the tag with grep -rli tags.git .git/*; if all you get is .git/config, then you're good to edit and move on. If you find other files, though, I don't know for certain that they will be updated as you continue with your git remote work. In that case, it might be helpful to look at https://help.github.com/en/articles/changing-a-remotes-url in order to formally change the URL.

Remove local Git repo when working with JGit

I am building a small tool to propose some Git commands to users not familiar with Git. The commands are not intended to modify the repo, just consult some information.
I am creating the tool in Java, using JGit which seems to be the best match to do this kind of stuff.
The issue I face so far is that I create a temporary folder to host the repo content, but I am unable to delete it automatically at the end of the execution.
Here is the code (I removed the try/catch stuff to simplify the reading):
// Create temporary folder
Path folderPath = Paths.get(System.getProperty("user.dir"));
File localRepoFolder = Files.createTempDirectory(folderPath, "local-repo").toFile();
// Clone the repo
CloneCommand clone = new CloneCommand();
clone.setURI("https://myrepo");
clone.setNoCheckout(true);
clone.setDirectory(localRepoFolder);
clone.setCredentialsProvider(new UsernamePasswordCredentialsProvider("user", "password"));
Git gitRepo = clone.call();
// Do some stuff
[...]
// Cleanup before closing
gitRepo.getRepository().close();
gitRepo.close();
localRepoFolder.deleteOnExit();
I searched quite a lot on this topic, but I get everywhere that it should be automatically deleted... Am I missing something?
I would use something like Apache Commons IO (http://commons.apache.org/proper/commons-io/) which has a FileUtils.deleteDirectory

Listing files under a specific folder from remote repository with JGit

I'm trying to list files from HEAD from a remote repository (Github). I read examples from the JGit documentation, but most of the time these are referencing to a local repository.
The only piece of code I found about remote repository is:
Collection<Ref> refs = Git.lsRemoteRepository()
.setHeads(true)
.setTags(true)
.setRemote("https://github/example/example.git")
.call();
for (Ref ref : refs) {
System.out.println("Ref: " + ref);
}
But this code is just listing references, like HEAD. Could anyone help listing files from a subfolder inside my remote repository?
LsRemoteCommand is the counterpart of git ls-remote and only lists references of a remote repository. In order to list files contained in a repository, you have to first clone the repository .
For example:
Git git = Git.cloneRepository()
.setURI( "https://github.com/eclipse/jgit.git" )
.setDirectory( "/path/to/repo" )
.call();
See this link for more on cloning repositories with JGit: http://www.codeaffine.com/2015/11/30/jgit-clone-repository/

JGit PullCommand Exception

We are using git to maintain our source. URL like git#xx.xx.xx.xx:XYZ.git. I'm using JGit to pull the changes.
UsernamePasswordCredentialsProvider user = new UsernamePasswordCredentialsProvider("xxxx", "xxxx");
localPath = "E:\\murugan\\Test\\GIT_LOCALDEPY";
Git git = new Git(localRepo);
PullCommand pcmd = git.pull();
pcmd.setCredentialsProvider(user);
pcmd.call();
I'm getting the following exception when I execute the code.
org.eclipse.jgit.errors.UnsupportedCredentialItem: ssh://git#xx.xx.xx.xx:22:
org.eclipse.jgit.transport.CredentialItem$StringType:Passphrase for C:\Users\Murugan.SOLVER\.ssh\id_rsa
If username/password security is not an issue, you can specify the credentials as part of the connection in the .git/config file of the local Git repo:
[remote "origin"]
url = ssh://<user>:<pwd>#<host>:22/<remote-path-to-repo>/
fetch = +refs/heads/*:refs/remotes/origin/*
You have to configure your SSH parameters on your machine before using Git. Here is a link, from github, for configuring it.
https://help.github.com/categories/56/articles
especially this one: https://help.github.com/articles/generating-ssh-keys
This will help you set up everything properly (you should adapt everything, since you are probably not connecting to GitHub)

how do I get configuration from buildout in my plone products?

How do I include configuration information from Buildout in my Plone products?
One of the plone products i'm working on reads and writes info to and from the filesystem. It currently does that inside the egg namespace (for example inside plone/product/directory), but that doesn't look quite right to me.
The idea is to configure a place to store that information in a configurable path, just like iw.fss and iw.recipe.fss does.
For example, save that info to ${buildout:directory}/var/mydata.
You could add configuration sections to your zope.conf file via the zope-conf-additional section of the plone.recipe.zope2instance part:
[instance]
recipe = plone.recipe.zope2instance
...
zope-conf-additional =
<product-config foobar>
spam eggs
</product-config>
Any named product-config section is then available as a simple dictionary to any python product that cares to look for it; the above example creates a 'foobar' entry which is a dict with a 'spam': 'eggs' mapping. Here is how you then access that from your code:
from App.config import getConfiguration
config = getConfiguration()
configuration = config.product_config.get('foobar', dict())
spamvalue = configuration.get('spam')

Resources