Death to "hg update -C"

Gilles Moris gilles.moris at free.fr
Tue Jul 21 11:23:20 CDT 2009


On Tue July 21 2009 17:15:03 L. David Baron wrote:
> I'd love to have a safer way to update across branches (i.e., one
> that checked that there weren't diffs in my tree and gave an error
> if there were) and get out of the habit of typing "hg up -C" all the
> time.
> 

It is already permitted to cross named branches from a clean work tree
without -C, but not between regular heads of the same named branch,
which is inconsistent.
If crossing heads from a clean work tree was permitted, use of -C would
only be restricted to discard changes.

May be something like this :

diff --git a/mercurial/merge.py b/mercurial/merge.py
--- a/mercurial/merge.py
+++ b/mercurial/merge.py
@@ -441,13 +441,9 @@
                 pass # all good
             elif p1.branch() == p2.branch():
                 if wc.files() or wc.deleted():
-                    raise util.Abort(_("crosses branches (use 'hg merge' or "
-                                       "'hg update -C' to discard changes)"))
-                raise util.Abort(_("crosses branches (use 'hg merge' "
-                                   "or 'hg update -C')"))
+                    raise util.Abort(_("uncommitted local changes"))
             elif wc.files() or wc.deleted():
-                raise util.Abort(_("crosses named branches (use "
-                                   "'hg update -C' to discard changes)"))
+                raise util.Abort(_("uncommitted local changes"))
             else:
                 # Allow jumping branches if there are no changes
                 overwrite = True

This way, head crossing is allowed and we even don't ask people to use
that dangerous option.

Regards.
Gilles.


More information about the Mercurial mailing list