I am trying to resolve the merge conflicts programmatically, i.e force merge.
After resolving merge conflicts, if i try to commit i get the below exception:
org.eclipse.jgit.api.errors.WrongRepositoryStateException: Cannot commit into a repository with state: MERGING.
How do I change the repository status or am I missing something.
Code snippet:
if((RepositoryState.SAFE == pullCommand.getRepository().getRepositoryState())) {
PullResult result = pullCommand.call();
if(MergeStatus.CONFLICTING == result.getMergeResult().getMergeStatus()){
mgCmd = git.merge();
mgCmd.include(repo.getRef("refs/remotes/origin/development"));
mgCmd.setStrategy(MergeStrategy.OURS);
mgCmd.setCommit(true);
res = mgCmd.call();
System.out.println("Failing Path ==="+res.getFailingPaths());
pullCommand.getRepository().resolve("C:\\CODE\\thin\\thinclient\\.git");
if(res.getMergeStatus().equals(MergeResult.MergeStatus.CONFLICTING)){
System.out.println("Merge status=========+++"+res.getMergeStatus());
}
The MergeCommand is not meant to resolve merge conflicts. The contrary is true, it will cause merge conflicts if the included ref(s) cannot be merged without conflicts.
The PullCommand is a composite command that first fetches commits from upstream and then tries to merge them using the MergeCommand.
In order to programmatically resolve merge conflicts, you need to change files in the local work directory accordingly, add them to the index, and then issue a merge commit.
Information about conflicting files can be found in pullResult.getMergeResult(). A merge commit can be created with the regular CommitCommand.
Related
I am trying to use JGit to add all files to the index (stage area).
By doing git.add().addFilepattern(".").call() I get to add modified and new ones. But not deleted ones.
How to add all deleted ones as well?
I tried git.add().addFilepattern("-u") but it does not work.
Related question (about adding specific deleted files, not all deleted files): How can I use JGit to add deleted files to the index?
Have you tried using setUpdate(boolean) ?
// fair warning : not tested, I only read JGit's doc
git.add().setUpdate(true).call()
// or
git.add().setUpdate(true).addFilepattern(".").call()
===Update: Using org.reflections:reflections:0.9.11
Looking to use the following line to pull a list of class names from Kotlin source...
Reflections.getSubTypesOf(Any::class.java)
However I receive a message that Kotlin class files aren't being seen when I run the following script...
val classLoader = URLClassLoader(this.getDirectoryUrls(), null)
println("retrieved class loader")
val config = getConfig(classLoader)
println("retrieved source config")
val reflections = Reflections(config)
println("retrieved reflections")
// For 3 paths: Reflections took 3 ms to scan 3 urls, producing 0 keys and 0 values
=== Update: The 3 urls added by "getDirectoryUrls()" are directories containing kotlin class source files.
Below is my config... ideas?
private fun getConfig(classLoader: ClassLoader): ConfigurationBuilder {
val config = ConfigurationBuilder().setUrls(ClasspathHelper.forClassLoader(classLoader))
// .setScanners(SubTypesScanner(false), ResourcesScanner())
if (!packagePath.isNullOrBlank()){
System.out.println("looking in package [$packagePath]")
config.filterInputsBy(FilterBuilder().include(FilterBuilder.prefix(packagePath)))
}
config.addClassLoader(classLoader)
config.setScanners(SubTypesScanner(), TypeAnnotationsScanner())
return config
}
Setting SubTypesScanner(false) seems to be required to get any types with getSubTypesOf(Any::class.java) (that parameter itself stands for excludeObjectClass). Looking at the bytecode of Kotlin classes you immediately see, that they are actually looking the same as Java classes. There is no Any-superclass there. Note that Kotlins Any is actually also in other means very similar to Javas Object (but not the same, check also the following answer to 'does Any == Object'). So, we need to include the Object-class when scanning for subtypes of Any (i.e. excludeObjectClass=false).
Another problem could be the setup of your URL array. I just used the following to setup the reflections util:
val reflections = Reflections(ConfigurationBuilder()
.addUrls(ClasspathHelper.forPackage("my.test.package"))
.setScanners(TypeAnnotationsScanner(), SubTypesScanner(false)))
which will resolve all matching subtypes and will return subtypes also for Any.
reflections.getSubTypesOf(MyCustomSuperType::class.java).forEach(::println)
reflections.getSubTypesOf(Any::class.java).forEach(::println)
Analysing further: you mention "Kotlin class source files"... if that means you are pointing to the directory containing the .kt-files, then that is probably your problem. Try to use the directory which contains the .class-files instead. Moreover, ensure that the classes are on the classpath.
Maybe you know already, maybe not? Note also that if you have a (classes) directory, say /sample/directory, which is on the classpath and which contains a package, say org.example (which corresponds to the folder structure org/example or full path /sample/directory/org/example) then you must ensure that you add an URL similar to the following:
YourClass::class.java.classLoader.getResource("")
and not:
YourClass::class.java.classLoader.getResource("org.example")
// nor:
YourClass::class.java.classLoader.getResource("org/example")
You basically require the "base" directory (in the example /sample/directory or from the view of the classloader just "")) where to lookup the packages and not the package itself. If you would supply one of the latter URLs, only classes that are in the default package (within /sample/directory/org/example) would actually be found, which however is a rather uncommon setup.
What would cause multiple documents on my catalog to have the same "unique id"? Effectively an error like this:
ERROR Products.ZCatalog A different document with value
'xxxx341a9f967070ff2b57922xxxx' already exists in the index.'
And how do I go about fixing it?
I had the same error today.
In short: the UID index in portal_catalog (ZCatalog UUIDIndex) complains that you are trying to index multiple objects with the same UID
In my case it was caused by a zexp import of a folder that contained images that where already available in another folder.
To reproduce:
copy production buildout, database and blobstorage to staging server
do some changes to staging.com/folder1
move staging.com/galleries/gallery1 to staging.com/folder1
export staging.com/folder1 to folder1.zexp
remove production.com/folder1
use ZMI import/export on production.com/manage to import folder1.zexp
you'll get these errors for the gallery1 folder and all of its content items:
2015-06-15T17:58:22 ERROR Products.ZCatalog A different document with value '618a9ee3544a4418a1176ac0434cc63b' already exists in the index.'
diagnosis
production.com/resolveuid/618a9ee3544a4418a1176ac0434cc63b
will take you to production.com/galleries/gallery1/image1
whereas staging/resolveuid/618a9ee3544a4418a1176ac0434cc63b
will take you to staging.com/folder1/gallery1/image1
production.com/folder1/gallery1/image1 did get cataloged too, but because it has the same uid as production.com/galleries/gallery/image1 results of resolveuid, catalog queries, internal links and such stuff might be random
how to repair
In my case I think it's probably the best to either
delete production.com/galleries/gallery1 and run a clear and rebuild on the portal catalog.
or replace production.com/folder1/gallery by production.com/galleries/gallery1 (delete, cut, paste)
If the objects with the same UID are not actually the same (as in my case) you might be able to give them new and uniques UIDS using object._setUID('new-uid') and rebuild the catalog afterwards.
There are two problems with SAP HANA custom dictonaries.
Updating and recompiling the dictionary has no effect on the full-text-index table (even by dropping and generating the full-text-index again)
using custom dictionaries & configuration may lead to an empty fulltext-index-table
For the 1. Problem
deleting the configuration file and replace it with a new file (same content but different file name) then activating all changes (activates the deletion of the old config and adds the new config) seems to be a work-around.
Note: this means you also have to change the configuration name in the SQL command.
For the 2. Problem
Check this trace file:
/usr/sap/HDB/HDB00/hanadb/trace/preprocessor_alert_hanadb.trc
This error message:
File read Error '/usr/sap/HDB/SYS/global/hdb/custom/config/lexicon//EXTRACTION_CORE_MOD2', error='Storage object does not exist: $STORAGEOBJECT$'
occurs if the configuration file EXTRACTION_CORE_MOD2 is not properly activated in the repository under sap.hana.ta.config. So double check the repository if the configuration file exists in the specified path.
For the first problem, I have the same scenario in which I need to make some changes in the custom dictionary and activated it. It did not affect my index table unit I run the following statement:
ALTER INDEX MYINDEX REBUILD;
I have checked it and the changes affect the index table by this statement. So you do not have to remove your index or save the changes of your custom dictionary in a file with new name.
One file gets upload when the node is created via standard Drupal.
Later, 2 files are added to the node via:
file_save(std Class)
file_usage_add(std Class, 'module', 'node', $node_id)
At the end, I end up with 3 entries in file_managed and file_usage.
Problem: when I delete the node via standard Drupal, the file that was added during the initial node creation gets removed, but not the 2 that were added later. These files remain in both tables, and physically on the disk.
Is there some flag that is being set to keep the files even if the node is deleted? If so, where is this flag, and how do I set it correctly (to be removed along with the node)?
The answer is in the file_delete() function, see this comment:
// If any module still has a usage entry in the file_usage table, the file// will not be deleted
As your module has declared an interest in the file by using file_usage_add() it will not be deleted unless your module explicitly says it's OK to do so.
You can either remove the call to file_usage_add() or implement hook_file_delete() and use file_usage_delete() to ensure the file can be deleted:
function mymodule_file_delete($file) {
file_usage_delete($file, 'mymodule');
}
You can force deleting of file.
file_delete($old_file, TRUE);
But make sure that this file is not used in other nodes using:
file_usage_list($file);