I'm working on an Android game with the folder structure:
\bin
\data (contains game graphics)
\libs (libgdx engine jars)
\src
----\com
--------\brand
------------\game
(*.class files)
Foolishly, I created a mercurial repository (hg init) in the \src directory. Thus, if I update any of the graphics (small file sizes), they aren't added to the repo when I commit. My question is: how can I change the root of the repo to include the \data directory as well as the \src directory, but without including the \libs directory as that includes 10-20mb jars?
There are two ways to do this.
1) Start a new repo. It's quick and easy but you'll lose your history.
2) Use hg rename. This is effectively a move command.
Rename the src directory to be something meaningful and then do this.
hg rename MyProject/com MyProject/src/com
Copy all the files/folders into the MyProject/ directory.
Mark bin and libs as ignorable and
Add everything else.
hg commit
If you don't want to just do an hg rename, you can do it with the convert extension (which comes by default with Mercurial, you just need to enable it in your .hgrc).
Run it with the --filemap parameter and a filemap file that has something like:
rename com src/com
You will end up with a new repository with all of your history, but with your com directory moved into src/com. You can then copy you bin, data and libs folders in there, run hg addremove and you should be all good to go.
Warning: the new repo is completely different than the old one -- changeset IDs and such will be different, so anybody you worked with in the past will have to get on the new repo.
Related
I am new to Sourcetree and source control in general. I am working on an Android project with a few other people and use bitbucket as the repository. I have learned the basics but don't want to track certain files in my local, specifically a lot of the gradle and iml files. But i think Stop tracking will remove those from the repo. Is there a way to just have source tree ignore any changes i make to certain files locally but not delete them from the repo ?
Thank you in advance
You can create a file and name it .gitignore in the root of the project and in that file place every directory to exclude by git like:
my_folder
my_folder2
The above would be excluded from git tracked files.
If you are already tracking files this command will remove them from index:
git rm -r --cached <folder>
Using eGit...
When I perform the initial Commit and Push from Eclipse, a new directory appears in the remote repo. Inside that directory is the root of the project directory. It makes a big mess because when someone clones it (again using eGit) the src folder is munged into a name containing then project folder name, which mucks up the package references in the class files.
eGit assumes you don't want an entire git repository for a single workspace project. Doing so would be wasteful and cumbersome for almost anything nontrivial. https://wiki.eclipse.org/EGit/User_Guide#Implications
You also didn't commit the .classpath file, which would have indicated what the source folders were.
I've just recently started using Mercurial and would like to keep my projects as independent from IDE as possible.
Therefore, I would like to only include my src, test src, and doc directory in the repository.
I've managed to only book these directories into the repository by ignoring all project related files.
The problem is that when I then clone it onto another system, Netbeans 7 wants to create a new project from these files. It does so by creating the project file inside of the repo instead of on the cloned name, since it cannot create a project on a directory that already exists.
Is there a standard way of booking in these folders and then when cloning them to create a project from them?
What about creating the project in Netbeans first and the cloning the files into it?
To avoid Mercurial complaining about the clone destination not being empty, use init + pull in the project directory instead of clone, this is equivalent:
$ cd myproject
$ hg init
$ hg pull -u http://example.org/myrepo
You could also just clone into a separate directory and then move all files (including the hidden .hg directory) into the Netbeans project. You could even just move the .hg directory, because that’s really all that Mercurial cares about.
Although actually I’m surprised you can’t start a project that is already on the file system. I’m not familiar with Netbeans, but can’t you import an existing project from the file system?
I have a directory structure like:
project_root
data/
src/
.hg/
utils/
math/
graphics/
...
README.txt
LICENCE.txt
As you can see from the location of .hg/, only src/ is under Hg control. I'd like to move the repository root up from src/ to its parent directory project_root, so I can track data/, README.txt, and LICENCE.txt as well.
A hacky way to do this would be to move everything down a directory rather than moving .hg up:
Move the contents of src down to a new directory src/src/
Move the contents of project_root (other than src/) down to src/
Rename src to new_project_root
Move new_project_root out of project_root, delete project_root
Is there a better way? I can't be the first person with this problem, and the above solution seems overly involved.
You should try hg convert. You will be "converting" your existing Mercurial repo into a new one. You specify rules for the conversion, which in your case will be that all files from the original repo go to a src directory in the new repo. Then you can manually copy and hg add the other files to the new repo.
This has the advantage that it won't be reflected as separate changes in your history. The possible disadvantage is that it will cause your changeset IDs to be regenerated, and existing clones will no longer be able to pull from the new repo.
Your plan is fine. It may seem involved, but it should take less than 20 minutes (worst case) and only happens once.
In the first step when you move the files that are tracked, you should use hg rename (alias hg move) to move them, as Mercurial will remember what each file was before and after the move. This will help with merging changes on file prior to the move with the new files after the move. Works best when renaming/copying is not accompanied by changes to the contents in the same changeset.
I recommend cloning the actual repo (or copying the entire project directory) before proceeding.
hg's Detect Renames works a treat nowadays.
Clone the repo so that you can mess things up without worry.
Using your example:
create the src/src subdir
move utils, math, graphics etc into src/src
Then open the commit window.
the moved files will appear in their old directory with a ! and in their new directory with a ?
right click on any file and choose "Detect Renames..."
slide the Min Similarity slider to 100%
Click the Accept All Matches button, and close the Detect Copies/Renames window
the moved files should now appear with an R in the old directory and an A in their new directory
commit this change
Then I moved data, Readme.txt etc down into src (not src/src)
committed the adds.
Finally, now that I have the repo as I want it, push the changes back to the originally cloned repo. Don't forget you'll need to Update the original repo to see the changes in the working directory.
I need to delete my "uploads" folder from the repository with all its history because it contains only junk testing data.
Please help.
You'll want to use the convert extension that ships with mercurial. Since you want to scrub a directory from the history you'll have to completely filter you're existing repository, CONVERTing it into a new one.
Assume the following made up structure of your repo:
/
src
doc
images
upload
Create a simple text file with the following content
exclude upload
You can do more with this file but keep it simple to get to your goal. The path to be excluded is relative to the repository root
Now run mercurial convert
hg convert --filemap path/to/the/textfile old-repo new-repo
Change to the directory of the new repo. Notice that mercurial created a bare/null rev repo (no content but the .hg directory). Run the following to update to your latest changset. Notice the upload directory is gone!
cd path/to/new/repo
hg update
WARNING: I do not know how this handles named branches or tags. You're on your own. At least you're not modifying the original repo. Make as many copies as you need to get it right.