Update BinaryDelta formatting for creating/applying logs

This commit is contained in:
Zorg committed 2015-04-19 17:29:51 -04:00
1 parent b780b476c6
commit e978cb0a3a
3 files changed
+20 -12

No files matched your search

+6 -6
View File
@@ -153,7 +153,7 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
}
if (!hasExtractKeyAvailable && !xar_prop_get(file, DELETE_KEY, &value)) {
if (verbose) {
fprintf(stderr, "\n❌ %s (Removed)", [path fileSystemRepresentation]);
fprintf(stderr, "\n❌ %s %s", VERBOSE_DELETED, [path fileSystemRepresentation]);
}
continue;
}
@@ -168,7 +168,7 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
}
if (verbose) {
fprintf(stderr, "\n🔨 %s (Delta)", [path fileSystemRepresentation]);
fprintf(stderr, "\n🔨 %s %s", VERBOSE_PATCHED, [path fileSystemRepresentation]);
}
} else if ((hasExtractKeyAvailable && !xar_prop_get(file, EXTRACT_KEY, &value)) ||
(!hasExtractKeyAvailable && xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value))) { // extract and permission modifications don't coexist
@@ -180,13 +180,13 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
if (verbose) {
if (fileExisted) {
fprintf(stderr, "\n✏️ %s (Replaced)", [path fileSystemRepresentation]);
fprintf(stderr, "\n✏️ %s %s", VERBOSE_UPDATED, [path fileSystemRepresentation]);
} else {
fprintf(stderr, "\n✅ %s (Added)", [path fileSystemRepresentation]);
fprintf(stderr, "\n✅ %s %s", VERBOSE_ADDED, [path fileSystemRepresentation]);
}
}
} else if (verbose && removedFile) {
fprintf(stderr, "\n❌ %s (Removed)", [path fileSystemRepresentation]);
fprintf(stderr, "\n❌ %s %s", VERBOSE_DELETED, [path fileSystemRepresentation]);
}
if (!xar_prop_get(file, MODIFY_PERMISSIONS_KEY, &value)) {
@@ -197,7 +197,7 @@ int applyBinaryDelta(NSString *source, NSString *destination, NSString *patchFil
}
if (verbose) {
fprintf(stderr, "\n👮 %s (Mode: 0%o)", [path fileSystemRepresentation], mode);
fprintf(stderr, "\n👮 %s %s (0%o)", VERBOSE_MODIFIED, [path fileSystemRepresentation], mode);
}
}
}
+8
View File
@@ -31,6 +31,14 @@
#define BEFORE_TREE_SHA1_OLD_KEY "before-sha1"
#define AFTER_TREE_SHA1_OLD_KEY "after-sha1"
#define VERBOSE_DELETED "Deleted" // file is deleted from the file system when applying a patch
#define VERBOSE_REMOVED "Removed" // file is set to be removed when creating a patch
#define VERBOSE_ADDED "Added" // file is added to the patch or file system
#define VERBOSE_DIFFED "Diffed" // file is diffed when creating a patch
#define VERBOSE_PATCHED "Patched" // file is patched when applying a patch
#define VERBOSE_UPDATED "Updated" // file's contents are updated
#define VERBOSE_MODIFIED "Modified" // file's metadata is modified
#define MAJOR_VERSION_IS_AT_LEAST(actualMajor, expectedMajor) (actualMajor >= expectedMajor)
// Each major version will be assigned a name of a color
+6 -6
View File
@@ -367,7 +367,7 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
xar_prop_set(newFile, DELETE_KEY, "true");
if (verbose) {
fprintf(stderr, "\n❌ %s (Removed)", [key fileSystemRepresentation]);
fprintf(stderr, "\n❌ %s %s", VERBOSE_REMOVED, [key fileSystemRepresentation]);
}
continue;
}
@@ -382,7 +382,7 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
xar_prop_set(newFile, MODIFY_PERMISSIONS_KEY, [[NSString stringWithFormat:@"%u", [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]] UTF8String]);
if (verbose) {
fprintf(stderr, "\n👮 %s (Mode: 0%o -> 0%o)", [key fileSystemRepresentation], [originalInfo[INFO_PERMISSIONS_KEY] unsignedShortValue], [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]);
fprintf(stderr, "\n👮 %s %s (0%o -> 0%o)", VERBOSE_MODIFIED, [key fileSystemRepresentation], [originalInfo[INFO_PERMISSIONS_KEY] unsignedShortValue], [newInfo[INFO_PERMISSIONS_KEY] unsignedShortValue]);
}
}
} else {
@@ -404,9 +404,9 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
if (verbose) {
if (originalInfo) {
fprintf(stderr, "\n✏️ %s (Replaced)", [key fileSystemRepresentation]);
fprintf(stderr, "\n✏️ %s %s", VERBOSE_UPDATED, [key fileSystemRepresentation]);
} else {
fprintf(stderr, "\n✅ %s (Added)", [key fileSystemRepresentation]);
fprintf(stderr, "\n✅ %s (%s)", VERBOSE_ADDED, [key fileSystemRepresentation]);
}
}
}
@@ -431,7 +431,7 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
}
if (verbose) {
fprintf(stderr, "\n🔨 %s (Delta)", [[operation relativePath] fileSystemRepresentation]);
fprintf(stderr, "\n🔨 %s %s", VERBOSE_DIFFED, [[operation relativePath] fileSystemRepresentation]);
}
xar_file_t newFile = xar_add_frompath(x, 0, [[operation relativePath] fileSystemRepresentation], [resultPath fileSystemRepresentation]);
@@ -443,7 +443,7 @@ int createBinaryDelta(NSString *source, NSString *destination, NSString *patchFi
xar_prop_set(newFile, MODIFY_PERMISSIONS_KEY, [[NSString stringWithFormat:@"%u", [operation.permissions unsignedShortValue]] UTF8String]);
if (verbose) {
fprintf(stderr, "\n👮 %s (Mode: 0%o -> 0%o)", [[operation relativePath] fileSystemRepresentation], operation.oldPermissions.unsignedShortValue, operation.permissions.unsignedShortValue);
fprintf(stderr, "\n👮 %s %s (0%o -> 0%o)", VERBOSE_MODIFIED, [[operation relativePath] fileSystemRepresentation], operation.oldPermissions.unsignedShortValue, operation.permissions.unsignedShortValue);
}
}
}