simple branch problem
Peter Arrenbrecht
peter.arrenbrecht at gmail.com
Thu Jan 15 09:46:02 CST 2009
On Thu, Jan 15, 2009 at 2:35 PM, jarek.jpa <jarek.jpa at gmail.com> wrote:
>
> Hi,
> I've got a simple question concerning branching in hg.
> Imagine a simple project we develop on various architectures (e.g. machines
> - desktop and laptop). What we need is different versions of some files for
> different machines (imagine e.g. file paths). What I would like to achieve
> is to keep those specific files on a branch (named or not) and conduct the
> main development in the main branch.
> In short: on laptop, I would like to have the working directory updated with
> few files from branch "laptop" and then checkin other files into the main
> (default) branch.
> When I do: "hg update laptop" I cannot checkin into the default branch.
> When I do: "hg merge laptop" from the default branch, I cannot checkin new
> changes without commiting a merge, which I don't want to do - it would
> obviously spoil the default branch with files from laptop.
>
> Meaby (probably) I'm wrong somewhere, so I'd appreciate somebody explain how
> to do this simple task properly.
I guess you could do the following:
hg update laptop
... work work ...
... test ...
Then, when you want to commit, you do:
hg update default # this rebases your working copy on default
hg commit
hg update laptop
hg merge default
hg commit -m "merged default"
The key is the `hg update default` before committing, which should
rebase your changes on default. But not that you tested the changes on
laptop first. This assumes that the rebasing really cannot break
anything you tested while based on laptop.
This will likely not work if laptop is not directly descended from tip
of default (not fully merged, that is). You might get a "crosses
branches" warning, which would kill this approach. But as long as
laptop is properly based on tip of default, this works. I just tried
it:
~~~~~~ hg init ble
~~~~~~ cd ble
~~~~~~ echo 1 >one
~~~~~~ hg ci -Am1
adding one
~~~~~~ hg branch laptop
marked working directory as branch laptop
~~~~~~ echo 2 >laptop
~~~~~~ hg ci -Amlaptop
adding laptop
~~~~~~ echo 2 >>one
~~~~~~ hg stat
M one
~~~~~~ hg up default
0 files updated, 0 files merged, 1 files removed, 0 files unresolved
~~~~~~ hg stat
M one
~~~~~~ hg diff
diff --git a/one b/one
--- a/one
+++ b/one
@@ -1,1 +1,2 @@
1
+2
~~~~~~ hg ci -Am2
created new head
~~~~~~ hg up laptop
2 files updated, 0 files merged, 0 files removed, 0 files unresolved
~~~~~~ hg merge default
1 files updated, 0 files merged, 0 files removed, 0 files unresolved
(branch merge, don't forget to commit)
~~~~~~ hg ci -m merged
~~~~~~ hg glog
@ 3 merged [laptop] peter 3 seconds
|\
| o 2 2 [] peter 14 seconds
| |
o | 1 laptop [laptop] peter 41 seconds
|/
o 0 1 [] peter 57 seconds
~~~~~~
-parren
More information about the Mercurial
mailing list