tags:

views:

34

answers:

1

Using a Macbook, I am worried that if the hard drive is on the road and it goes bad, then 3 days of code can all be lost.

So I actually have a tmp repository on our main server computer, and I can hg push to it. The dilemma is, I can't push unless I commit first, and from previous experience, we shouldn't commit unless we are ready to push to a central server (to share code with coworkers, merge, etc) (the reason is, we can't push selected files -- we have to push all committed files or push nothing). So how to solve this?

Is there a way to say, "copy all MODIFIED FILES (and added files) to /user/peter/2010-06-18 on the central server?)" or not commit but somehow get it onto the server?

+3  A: 

The normal way is to just commit. With a DVCS one is urged to "commit early, commit often". Commit locally often, then for backup purposes push to your tmp repo on the server frequently. When you're happy with your work, then you push from your tmp repo to your shared "central" server.

There's no need to make sure everything compiles after each changeset, the norm is to just make sure that each back of changesets you push leaves the 'tip' in a compileable state. Generally one triggers the continuous integration build server to turn a builds after each group of changesets (changegroup) arrives, and it only considers the 'tip'.

If you really, really can't stand having changesets that can't stand on their own, then a mercurial pro would use mercurial queues to keep a versioned patch pushed to a separate queue repository while working on it. Someone willing to play with fire would use the collapse extension to merge the sequence of changesets into a single changeset before pushing to the shared repos.

Of the three options presented:

  1. fix your workflow so that the central repo can handle changesets that don't compile, so long as they're part of a changegroup that compiles
  2. use mercurial queues to keep a patch in a versioned patch repository
  3. use the collapse extension to rewrite history (play with fire)

I think the first is most commonly done, and generally the "right" way.

Ry4an
oh, but if commit all 5 files, and when you are ready to push to a central server later... and you only want to push 3 files, then backout the other 2 files you don't want to push?
動靜能量
If the 5 files are related you shouldn't push to the central server until they're all ready. If they're unrelated, you should commit just the three of them, `hg update -r -2` (goes back one changeset) and then commit the other two. Now they're in different, sibling changesets with the same parent -- anonymous branches according to http://stevelosh.com/blog/2009/08/a-guide-to-branching-in-mercurial/ -- and you'll be able to push one cset without the other using `push -r`.Commit early, commit often, branch often.
Ry4an