Wednesday, December 1, 2010

More Repositories, Sharing And Global .hgignore

Now that we know how to create repositories it is simple enough to create new ones by right-clicking in the main folder and selecting TortoiseHg - Create Repository Here.
But what about sharing those files with others, including the changes?
It looks like there are two ways to make a copy of the repository.  One is to use Windows explorer and copy the folder to the new location, the other is to use TortoiseHg's Clone tool.
They both appear to accomplish the same thing, but I would guess that it is safer to use the Clone tool. Now another user can go to the shared location and copy/clone the folder to their machine for editing.  All of the revisions you made will be available to them if they have TortoiseHg installed, otherwise they will only be able to access the latest one.
What if you make changes to your local design and want to apply it to the shared one?  To do this you need to use the push and pull tools.  The safest way to make a change to a shared design is to first pull any updates from the shared repository to your local one.
Step1: Right-click in your local repository and select Synchronize
Step 2: In the Sychronize window hit the Repo: button and browse to the shared repository folder
Step 3: Hit the Pull button to pull any changes from the share repository in to your local one
If you just want to see what changes will be pulled in without actually pulling them you can use the Incoming button.
Now that you have the latest revision of files you can make your changes and save and commit them to your local repository.  In order to share the changes you need to apply them to the shared repository by pushing them.  To push them open the Synchronize window again, browse to the shared repository and hit the Push button.
If you want to see what changes will be pushed before you do the push select the Outgoing button.  Congratulations, you can now share change controlled files with others.

While researching the .hgignore file I found something that may be useful if you are going to have a lot of repositories and don't want to change the .hgignore file every time you create a new one.  Mercurial has the option to use a global .hgignore file.  In your Windows home folder (something like C:\Users\yourusename) there should be a mercurial.ini file.  Open this file in a text editor (like Notebook) and find the section labeled [ui] and add this line:
ignore.other = ~\.hgignore_sw
Now create a new text file called .hgignore_sw that contains the ignore text you use in your repositories.  Here is what we had from our first one:
# use glob syntax.
syntax: glob


# ignore temporary files
~*
Now every repository you create will ignore files that begin with a ~ when you commit your design.

3 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. I am evaluating Mercurial/TortoiseHg for use to provide revision control of SolidWorks files. Have you used Mercurial to maintain SolidWorks files in a multi-user environment? It is fairly easy for one user to make changes to an assembly file and push it to the repository, and have another user who attempts to do the same thing (with independent changes). There is no easy way to merge binary files, and I haven't found an elegant means to resolve the problems associated with this issue. Please comment if you have solutions or experience in this area.

    ReplyDelete
  3. Hi RK, thanks for you question. I obviously haven't contributed to this blog in a while, but I do remember messing with the merging of SolidWorks file and not having a lot of success. I looks like the information in this post may be useful.
    http://stackoverflow.com/questions/992287/mercurial-internalmerge-and-binary-file-conflicts

    I'll play around with it and put up another post if I get it working.

    ReplyDelete