• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Servant of the Lord

Proper usage of branching in [hg]mercurial

12 posts in this topic

I'm no Distributed Version Control System expert, but in my experience with git, I tend to use "main" branches in a way that sort of facilitates the idealized waterfall model of development -- that is, I have a stable, test, and merge branch that run in parallel through the life of the project -- and feature work is branched off individually from the merge branch. So, a feature is completed and tested in isolation, is promoted to the merge branch where any changes necessary to merge the feature happen (will branch those off too), that gets committed, and then promoted to the test branch (new tests written, etc), and when all is well there the whole shebang gets promoted to stable. That's just one of many ways you can use DCVSs.

 

In general, the idea of DCVSs is that you should be creating branches literally all the time, even as a single developer. New feature or experiment? New branch. If you just do a linear progression of code, the benefits of DVCSs tend to fade, but the flexibility of DVCSs really enables you to use whatever workflow you want -- even one that behaves more like a traditional Centralized VCS.

 

As to art assets -- I believe pretty firmly that the distributed model of version control systems isn't terribly suited for art assets. As such, I actually prefer to keep them separately in a Subversion repository. This is for a couple reasons: Firstly, the centralized checkin-checkout model seems more suited to artists workflow, secondly, few artists really grok the concept of branch-merge and how it affects their workflow, thirdly, an individual artist doesn't need the source artwork and history for all assets and the amount of data is huge. Finally, you don't have to worry about a non-technical person borking your entire source code tree. 

2

Share this post


Link to post
Share on other sites

For the artwork, the reason why I have it in the mercurial repository is merely because my entire project is in there. It's a backup of my entire project that can be rolled forward or rolled back. I don't need the history of individual pieces of art, but using two separate source control systems seems like an unnecessary complication that'd confuse me alot! Would one VCS then contain the other VCS's repository? huh.png

 

I get what you are saying about a feature getting completed in isolation and then merged - that's what I'd like to do... But what seems to happen to me alot is that if I'm working on the feature in a separate branch, and I make a non-feature-related bug fix or add a new helper function to the common/core library that's unrelated to the feature, I need to somehow make that bugfix or function addition be applied to the main branch immediately, instead of when the feature branch gets merged, if it gets merged at all. How do you handle that kind of situation in your workflow?

0

Share this post


Link to post
Share on other sites

Personally, I don't find it too confusing to have a separate VCS for art, but I get what you're saying -- personal preferences and all.

 

I think the main thing with DVCSs is that you really have to commit to a certain worldview, and be pedantic about it. In your example, if you found that you suddenly needed to make a fix that's not really part of the feature work, the "prescribed" approach would be to quickly make a different branch for that thing (from whatever other branch is appropriate), and then go back to your feature branch and pull that change you made back down into the feature branch. I forget exactly how you do this, but that's the workflow that hg/git pros would probably recommend.

0

Share this post


Link to post
Share on other sites

In your example, if you found that you suddenly needed to make a fix that's not really part of the feature work, the "prescribed" approach would be to quickly make a different branch for that thing (from whatever other branch is appropriate), and then go back to your feature branch and pull that change you made back down into the feature branch.

So, I'm in 'FeatureX'. I have to:
- Commit my current changes in FeatureX (if I forget this step, and I lose work) (hg commit -m "saving my progress")
- Switch over to the stable branch (hg update StableBranch)
- Branch the stable branch into TinyFixQ (hg branch TinyFixQ)
- Change one line of code
- Commit the change (and remember to --close-branch) (hg commit -m "Fixed the thing" --close-branch)
- Change over to the stable branch again (hg update StableBranch)
- Merge TinyFixQ into the stable branch (hg merge TinyFixQ)
- Commit the stable branch (hg commit -m "applied the fix to the stable branch")
- Change back to FeatureX (hg update FeatureX)
- Pull TinyFixQ into FeatureX (hg merge TinyFixQ)
- Commit to FeatureX (hg commit -m "applied the fix to the developmental feature")

And then be back on my merry way! Did I miss a step? You can why I find it easier to just develop on a single branch.

There has to be a more succinct way to do it - I'm sure it's just my inexperience with Mercurial that makes it require so many steps.

 

Maybe I can use the graft command for this?

- Commit my current changes in FeatureX (if I forget this step, and I lose work) (hg commit -m "saving my progress")

- Write the bugfix

- hg commit -m "Fixed bug" (and remember the revision number)

hg update StableBranch

- hg graft <revision-number>

hg commit -m "applied the fix to the stable branch"

hg update FeatureX

 

Does that work? Did I get it correct? If so, it saved me a number of steps... but is still too many.

 

Why can't I just go:

- Commit my current changes in FeatureX (if I forget this step, and I lose work) (hg commit -m "saving my progress")

- Write the bugfix

hg commit -m "Fixed bug" (and remember the revision number)

hg graft <revision-number> StableBranch --and-commit (grafting and committing the single revision to a different branch than the one I am in, without me having to change between branches)

 

The red underlined part is stuff I'm making up. Are there any equivalent commands?

0

Share this post


Link to post
Share on other sites

I lack the hg-fu to tell you how to do this easily, but as best as I understand, the whole idea of fast branch and merge is that you have easy atomic sandboxes, and you're meant to use them. They're argued to be lightweight enough that its not a hassle. Its more or less a matter of policy just how related a change has to be to be considered part of an existing atomic unit or its own, but if by whatever standard it is "different" then it ought to be in a different branch logically, otherwise your history is a tangled mess of things.

 

By that same token, you shouldn't ever be making "intermediate" commits with partially complete features to save your progress -- if you're doing that, you're using the tool in a fundamentally wrong way. One which is not much better than a glorified backup. A commit is all or nothing, it implements a some subset of code completely. You might break a large functional area down (possibly using sub-branches, even) into smaller pieces, but they're always "complete" for some definition of complete -- a commit should never represent an interruption.

 

If you have some misunderstanding about how to best use these tools, you wouldn't be the first. I'm certainly no authority. But the way of working that's prescribed by DVCSs is markedly different than Centralized VCSs, and to most simple ways that people have collaborated in the past. It sometimes seems completely insane to have to do all these little steps up front to do seemingly simple things, but the argument is that the cost you pay now is less than the delayed cost of heavy branches and endless merge conflicts under the old paradigm.

0

Share this post


Link to post
Share on other sites

I think the workflow could be more like this, that would prevent polluting the repository with temporary things:

hg shelve

hg up stable

edit in the fix

hg commit

hg up devel

hg unshelve

hg commit

hg merge

 

Btw., branches in mercurial are like svn branches and are meant to be long running things which are not removed, like for example the default branch for developing, a stable branch for the next oldest version which just gets bugfixes or similar. For adding a single feature or bugfix you can use bookmarks, which are more similar to git branches and can be deleted when you dont need them anymore.

1

Share this post


Link to post
Share on other sites

I think the workflow could be more like this, that would prevent polluting the repository with temporary things:

 

Slightly altered from actual quote:

hg shelve 
hg update Stable
edit in the fix
hg commit
hg update ExperimentalFeatureX
hg unshelve
hg commit
hg merge

 


I'm not sure I understand. ('shelve' is a Mercurial extension)

 

'shelve' just stores away what I was working on without committing, right?

Why not just commit?

And how does the bugfix or feature addition that I'm making to Stable get back into ExperimentalFeatureX at the same time? I want to commit changes made to a specific file into both branches.

 

Also, what's that merge for at the end? I'm not wanting to merge ExperimentalFeatureX into Stable - at least not yet. Or are you merging Stable into ExpermentalFeatureX, to bring ExperimentalFeatureX up to date? Huh, I *think* I get that.

 

But why use shelve at all? Why not just:

  1. hg commit
  2. hg update Stable
  3. edit in the fix
  4. hg commit
  5. hg update ExperimentalFeatureX
  6. hg merge
0

Share this post


Link to post
Share on other sites

commit means you're putting that interruption into your history. That's not something you want to preserve; right now you care about coming back to that point in your would-be "history" so you can pick back up on feature work, but tomorrow or 6 months from now you're never going to want to come back into the point where you were interrupted. Every time you commit, you're creating a mile-marker that you can return to should ever the need arise. You don't want to litter the roadside with irrelevant markers -- its particularly harmful if you wanted to go back in history to a point *just before* the next feature you add, which you would logically assume is commit X-1 -- but committing the interruption would actually make it commit X-2.

 

shelve gives you the same kind of workflow without polluting your history.

Edited by Ravyne
1

Share this post


Link to post
Share on other sites

Yes, thats why I was suggesting this.

 

The merge at end could be different things depending on how you want to continue. Possibly merging the fix and then the feature into default development branch, merging the feature into the stable (though that would be a little weird naming for a branch where you add new features) or merging the fix into the feature branch at a logical point when/if you need it there to continue developing that feature. Not completely sure if that works on mercurial but you could also merge over the fix before unshelving to have the branches a little less intermingled.

0

Share this post


Link to post
Share on other sites

I'm still not seeing how the patch gets applied to both the Stable and the Development branch?

  1. hg shelve <-- Checkpoint current ExperimentalFeatureX work
  2. hg up stable <-- Load the stable branch
  3. edit in the fix <-- Fix the bug or add the function into the stable branch
  4. hg commit  <-- Save the stable branch
  5. hg up devel <-- Load the ExperimentalFeatureX branch. This unloads the fix I just did...
  6. hg unshelve <-- Reload the checkpoint of where I was before.
  7. hg commit <-- Save the work
  8. hg merge <--- What am I merging, exactly?

Sorry for being thickheaded, I just am not fully grasping how this accomplishes what I want (Adding a single patch into two or more branches, without merging the branches with each other). What am I missing?

Edited by Servant of the Lord
0

Share this post


Link to post
Share on other sites

If you are not maintaining releases and do not have many people working on the code-base, there is no reason to branch - especially not with a modern tool like hg or git.

In hg or git every commit is like a microbranch so you are already befitting in a small way from branch technology.

On small projects at home I never branch. At work we have to maintain a shitload of branches.

 

If you do a release then you should tag that commit (so you can find it easy) then if-and-when you need to fix a bug you can create a branch to support that release and release 1.0.1, 1.0.2, etc...

If the project is large and stable and you want to develop a big new feature, then you can create a 'development branch' to keep the experimental work on that branch until you deem it high enough quality to merge to the mainline.

 

If you have lots of developers simultaneously developing features then you can create 'feature branches' to keep each feature's development from interfering from one-another as they break things.

 

If you had to fix a bug in the 1.0 release then odds are it's still in the mainline code so you'd want to merge that bug fix back to the mainline.

 

If you make development branches then you want to periodically merge the mainline to the development branch first to work out compatibility issues on the development branch (made other people have merge big ass development branches in the mean-time.) Once you have a recent main->branch merge then you do a branch->main merge (this ensure the merge to main is easy).

 

When you're doing small feature branches you might just go-for-it and merge the feature back to the trunk (and if you have trouble, then abort the merge and merge the trunk to the feature branch).

 

I never use the command line for merge management; you really want to see what you are doing.

With hg, merging a branch is not really any different from merging two check-ins on the trunk.

Edited by Shannon Barber
1

Share this post


Link to post
Share on other sites
Thanks everyone, this is really helpful.

If you do a release then you should tag that commit (so you can find it easy) then if-and-when you need to fix a bug you can create a branch to support that release and release 1.0.1, 1.0.2, etc...

Right, I forget about tagging

If you had to fix a bug in the 1.0 release then odds are it's still in the mainline code so you'd want to merge that bug fix back to the mainline.

How do you do that? Do you just merge the entire 1.x release branch back into the mainline?

If you make development branches then you want to periodically merge the mainline to the development branch first to work out compatibility issues on the development branch (made other people have merge big ass development branches in the mean-time.) Once you have a recent main->branch merge then you do a branch->main merge (this ensure the merge to main is easy).

That makes sense! I think I'm starting to understand.
 

I never use the command line for merge management; you really want to see what you are doing.

So far, I've never had any conflicts, since I haven't used Hg long. I'll definitely use something like WinMerge for sourcecode conflicts!
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0