Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version Control Program and Rolling Backup Utility #88

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

jcmendoza2
Copy link

@jcmendoza2 jcmendoza2 commented Sep 30, 2024

vcp

The "vcp" command revolves around the idea of a version control/backup program. A hidden root directory (vctl) is created when the command is ran; within it a sub-directory with the name of the file we are working with is also created. Within this sub-directory a maximum of 3 files can be saved (in essence 3 different versions of the sub-directory's file name).

  • Example: vctl / filename / Version1_filename
    The point is to be able to save the most important versions of a program so that if necessary, the user can come back and review past versions of that exact program and extract the needed info that can be applied in the user's current program. When 3 versions already exist for a specific file and the user wants to save another version, the oldest of the 3 versions will be overwritten upon confirmation that the user agrees upon this process. If agreed, all existing versions will be shifted forward and renamed and the newest version will be added to the version control directory.

  • Example: Version2_filename -> Version1_filename, Version3_filename -> Version2_filename and filename -> Version3_filename

Added Files:
user/vcp.c
// Testing
FogOS-VCP/getlinetest.txt
FogOS-VCP/vcpTest.txt
our lab with broken.c to test long files

Modifications:
FogOS-VCP/Makefile

Flags:

  • (-saveVersion): saves the current state of the file as a new version and label it with its respective version number

  • (-listVersions) : displays a list of all saved versions of the specified file for example: Version3_filename.txt

  • (-viewVersion) : displays the selected file version existing in the list of file versions for the specified file like the format of 'cat [filename]' allowing user to copy and access functions or implementations they wish they didn't get rid of etc. For example: /vcp -viewVersion Version2_filename.txt

How to Test | How it Works | Limitations:
You can refer to the file vcpTest.txt where I included examples of how to test the program within QEMU.
As of now you can only test with files in your OS directory (where your Makefile exists) or with files you create in QEMU with echo. Future implementation will handle accessing files from other directories.
Due to limitations in xv6: only inside QEMU using echo can you really see the multiple versions of saving, viewing, and listing [refer to vcpTest.txt for why]. Saving, viewing, and listing can also be done for files in OS but not in the way the program was designed [vcpTest.txt]

If testing in OS, ensure the file is added to your Makefile fs.img: 2nd line only. Do not make clean after you save versions as this will erase all versions and directories you've saved with vcp (due to xv6 limitations). You can exit QEMU and then rerun QEMU and the data will still be there.
Inside QEMU:

  • /vcp -saveVersion filename.txt
  • /vcp -listVersions filename.txt
  • /vcp -viewVersion Version1_filename.txt
    The program will work like normal, saving max 3 versions and overwriting but all versions will have same content (but they are separate files [refer to vcpTest.txt])

If testing inside QEMU: create a program with content like so

  • echo "content you want" > filename.txt (any extension)
  • /vcp -saveVersion filename.txt
  • echo "different content" > filename.txt (to change the file content)
  • /vcp -saveVersion filename.txt
  • Now you can /vcp -listVersions filename.txt
  • and then you can view each version. If you want to try overwriting, save more than 3 versions and then check if everything has been shifted forward.

@n-t-eastham
Copy link

I can code review this.

@evadethomas
Copy link

I can code review this!

@n-t-eastham
Copy link

High Level Checks:

  • [✓] PR fully resolves the task/issue
  • [✓] Does the PR have tests?
  • [✓] Does the PR follow project code formatting standards?
  • [✓] Does the OS still compile and run?
  • [✓] Is documentation included?

Code Checks:

  • [✓] Does the code achieve its intended purpose?
  • [✓] Were all edge cases considered?
  • [✓] Is the code organized and maintainable?
  • [✓] Does the code maintain the same level of performance? (no performance regressions)

Using the updated version of Issue #69, this request fully resolves all purposed tasks. The request has a few test files, the vcpTest.txt provides a detailed example on how to use one's own OS to test the command. I saw no formatting flaws making it very easy to track dataflow. Documentation is included and very thorough, but I'd suggest adding a file to the docs directory documenting the command. I believe the code achieves its intended purpose. I realized the scope needed to be narrowed slightly, but this was till a huge accomplishment. I tried my best to find an edge case that had gone unconsidered, but it seems they might be all accounted for. The code is extremely well organized, though I think some modularity could be added to the saveVersion function.

@evadethomas
Copy link

evadethomas commented Oct 7, 2024

High Level Checks:

  • [✓] PR fully resolves the task/issue
  • [✓] Does the PR have tests?
  • [✓] Does the PR follow project code formatting standards?
  • [✓] Does the OS still compile and run?
  • [✓] Is documentation included?

Code Checks:

  • [✓] Does the code achieve its intended purpose?
  • [✓] Were all edge cases considered?
  • [✓] Is the code organized and maintainable?
  • [✓] Does the code maintain the same level of performance? (no performance regressions)

Wow! Great job. This request fully resolves all tasks, has multiple tests, follows formatting standards, compiles and runs and documentation is included. Instructions to run this program were super easy to follow, and many edge cases were considered, but I was especially impressed by the way it handles overwriting the saved versions when the user creates more than 3 versions.

The code achieves its intended purpose, is organized and maintainable and maintains the same level of performance.

I think its cool you can run this program both in qemu and in the OS space, but as I was running it I was a little confused about the difference between the two as the OS space was behaving a little differently, but this was outlined here in the PR "Saving, viewing, and listing can also be done for files in OS but not in the way the program was designed [vcpTest.txt]". I think the fact that it runs in the OS is above and beyond and it is really cool they executed such a large scope. This is a seemingly simple task but I can see there there are many edge cases that need to looked at that are handled beautifully. Some functions were a little chunky and could have been broken up, but besides that everything looks great!

#define MAX_VERS 3

/**
* Ensure the root directory "vctl" exists. This will be the root directory for all future

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really nice documentation!

* @param filename: current file name
* @return verCount: total number of versions currently in directory
*/
int retrieveVer_Count(char *filename) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function is pretty large, could break it up a bit for readability.

}

/**
* Function that will implement that -saveVersion command/flag

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing here, this function could be broken up a little for reusability and readability.

return;
}
int fd_source = open(filename, O_RDONLY);
if (fd_source < 0) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice error checking throughout the whole project!

@malensek
Copy link
Contributor

This is a cool idea and I appreciate how you built all the necessary infrastructure around it to make it work despite xv6's limitations.

saveVersion has a lot of repeated code that could be condensed with helper functions. For instance, reading + writing the files follows a similar pattern over and over, so you could clean that up.

I feel like isValidVersion should just do a straight strcmp to avoid the character checking for 'version' / 'VERSION'.

Overall very cool project! These are minor issues, nice work!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants