74 lines
3.3 KiB
Diff
74 lines
3.3 KiB
Diff
diff --git a/java/com/google/copybara/hg/HgDestination.java b/java/com/google/copybara/hg/HgDestination.java
|
|
--- a/java/com/google/copybara/hg/HgDestination.java
|
|
+++ b/java/com/google/copybara/hg/HgDestination.java
|
|
@@ -237,22 +237,30 @@ public class HgDestination implements De
|
|
|
|
Operation diffOp = diff.getOperation();
|
|
|
|
- if (diffOp.equals(Operation.ADD)) {
|
|
- Path targetPath = localRepo.getHgDir().getParent().resolve(diff.getName());
|
|
- Files.createDirectories(targetPath.getParent());
|
|
- Files.copy(workDir.resolve(diff.getName()),
|
|
- targetPath, StandardCopyOption.COPY_ATTRIBUTES, StandardCopyOption.REPLACE_EXISTING);
|
|
- }
|
|
+ switch (diffOp) {
|
|
+ case ADD:
|
|
+ Path targetPath = localRepo.getHgDir().getParent().resolve(diff.getName());
|
|
+ Files.createDirectories(targetPath.getParent());
|
|
+ Files.copy(
|
|
+ workDir.resolve(diff.getName()),
|
|
+ targetPath,
|
|
+ StandardCopyOption.COPY_ATTRIBUTES,
|
|
+ StandardCopyOption.REPLACE_EXISTING);
|
|
+ break;
|
|
|
|
- if (diffOp.equals(Operation.MODIFIED)) {
|
|
- Files.copy(workDir.resolve(diff.getName()),
|
|
- localRepo.getHgDir().getParent().resolve(diff.getName()), StandardCopyOption.REPLACE_EXISTING);
|
|
- }
|
|
+ case MODIFIED:
|
|
+ case TYPE_CHANGED:
|
|
+ Files.copy(
|
|
+ workDir.resolve(diff.getName()),
|
|
+ localRepo.getHgDir().getParent().resolve(diff.getName()),
|
|
+ StandardCopyOption.REPLACE_EXISTING);
|
|
+ break;
|
|
|
|
- if (diffOp.equals(Operation.DELETE)) {
|
|
- if (!diff.getName().equals(".hg_archival.txt")) {
|
|
- Files.delete(localRepo.getHgDir().getParent().resolve(diff.getName()));
|
|
- }
|
|
+ case DELETE:
|
|
+ if (!diff.getName().equals(".hg_archival.txt")) {
|
|
+ Files.delete(localRepo.getHgDir().getParent().resolve(diff.getName()));
|
|
+ }
|
|
+ break;
|
|
}
|
|
}
|
|
} catch (InsideGitDirException e) {
|
|
@@ -280,8 +288,10 @@ public class HgDestination implements De
|
|
localRepo.cleanUpdate(remoteFetch);
|
|
|
|
// Set the default path of the local repo to be the remote repo, so we can push to it
|
|
- Files.write(localRepo.getHgDir().getParent().resolve(".hg/hgrc"),
|
|
- String.format("[paths]\ndefault = %s\n\n[phases]\npublish = False\n", repoUrl).getBytes(StandardCharsets.UTF_8));
|
|
+ Files.write(
|
|
+ localRepo.getHgDir().getParent().resolve(".hg/hgrc"),
|
|
+ String.format("[paths]\ndefault = %s\n\n[phases]\npublish = False\n", repoUrl)
|
|
+ .getBytes(StandardCharsets.UTF_8));
|
|
|
|
console.progress("Hg Destination: Computing diff");
|
|
getDiffAndStageChanges(destinationFiles, workdir, localRepo);
|
|
diff --git a/java/com/google/copybara/util/DiffUtil.java b/java/com/google/copybara/util/DiffUtil.java
|
|
--- a/java/com/google/copybara/util/DiffUtil.java
|
|
+++ b/java/com/google/copybara/util/DiffUtil.java
|
|
@@ -119,7 +119,8 @@ public class DiffUtil {
|
|
public enum Operation {
|
|
ADD("A"),
|
|
DELETE("D"),
|
|
- MODIFIED("M");
|
|
+ MODIFIED("M"),
|
|
+ TYPE_CHANGED("T");
|
|
|
|
private final String charType;
|
|
|