View Javadoc

1   package com.aragost.javahg.merge;
2   
3   import com.aragost.javahg.commands.ResolveCommand;
4   
5   public class MergeConflict extends MergeFile {
6   
7       private boolean resolved = false;
8   
9       public MergeConflict(ConflictResolvingContext mergeState, String file) {
10          super(mergeState, file);
11      }
12  
13      public boolean isResolved() {
14          return resolved;
15      }
16  
17      /**
18       * Attempt to resolve conflict with Mercurial's internal merge
19       * tool
20       * 
21       * @return true if the conflict was resolved, false otherwise
22       */
23      public boolean resolveWithInternalMerge() {
24          return resolveWith("internal:merge");
25      }
26  
27      /**
28       * Attempt to resolve conflict with the specified tool.
29       * 
30       * @return true if the conflict was resolved, false otherwise
31       */
32      public boolean resolveWith(String tool) {
33          ResolveCommand cmd = ResolveCommand.on(getRepository()).tool(tool);
34          cmd.execute(getFilename());
35          this.resolved = cmd.getReturnCode() == 0;
36          return this.resolved;
37      }
38  
39      /**
40       * Mark this merge conflict as resolved
41       */
42      public void markResolved() {
43          ResolveCommand.on(getRepository()).mark(getFilename());
44      }
45  
46  }