how to know if there's nothing to merge

j w jwdevel at gmail.com
Thu Jan 24 23:24:18 UTC 2008


On Jan 24, 2008 2:50 PM, Kelly O'Hair <Kelly.Ohair at sun.com> wrote:
> But 'hg update' will fail and tell you when a merge is needed.
> If 'hg update' returns 0, then it has updated your working set
> files to the 'tip' and no merge is necessary.
>
> Why wouldn't you want your working set files to be the tip version?
>

Hmm.. perhaps this example will explain my situation better:

    C:\>mkdir test_merge_kto
    C:\>cd test_merge_kto
    C:\test_merge_kto>hg ini
    C:\test_merge_kto>echo fooooo > foo.txt
    C:\test_merge_kto>hg add
    adding foo.txt
    C:\test_merge_kto>hg ci -m "added foo"
    C:\test_merge_kto>hg branch other
    marked working directory as branch other
    C:\test_merge_kto>echo othertext > foo.txt
    C:\test_merge_kto>hg ci -m "other text"
    C:\test_merge_kto>hg up -C default
    1 files updated, 0 files merged, 0 files removed, 0 files unresolved
    C:\test_merge_kto>echo defaulttext > foo.txt
    C:\test_merge_kto>hg ci -m "default branch change"
    C:\test_merge_kto>hg heads
    changeset:   2:d066117de814
    tag:         tip
    parent:      0:483829e1d134
    user:        jw
    date:        Thu Jan 24 15:19:07 2008 -0800
    summary:     default branch change

    changeset:   1:f27ec754263f
    branch:      other
    user:        jw
    date:        Thu Jan 24 15:18:57 2008 -0800
    summary:     other text

    C:\test_merge_kto>hg up
    0 files updated, 0 files merged, 0 files removed, 0 files unresolved
    C:\test_merge_kto>echo %ERRORLEVEL%
    0

^^^ that did not tell me that a merge was needed

    C:\test_merge_kto>hg up other
    abort: update spans branches, use 'hg merge' or 'hg update -C' to
lose changes
    C:\test_merge_kto>echo %ERRORLEVEL%
    -1
    C:\test_merge_kto>

^^^ that told me a merge was needed, but in the case where it was
*not* needed, it would have changed my working branch to "other", and
changed the files in my working directory, which I don't want. Of
course in that case I could just issue "hg up default", but that
switch-then-switch-back takes time and seems unnecessary.

Does that make sense?

-John



More information about the Mercurial mailing list