[Chicago] Need Mercurial help

Augie Fackler durin42 at gmail.com
Mon Jan 18 17:01:41 CET 2010


On Jan 18, 2010, at 7:24 AM, skip at pobox.com wrote:

>
> I attempted to use Mercurial to manage the version control of the  
> lockfile
> package (http://pypi.python.org/pypi/lockfile), but I seem to have  
> gotten my
> repository all screwed up.  I think I'm going to go back to  
> Subversion or
> CVS, anything would be simpler than the mess I have now.
>
> Is there some Mercurial expertise here I can lean on to try and get  
> things
> straightened out?
>
> 1. My repository has a bunch of different heads:
>
>    % hg heads
>    changeset:   120:9cc71194b52a
>    branch:      python-package
>    tag:         tip
>    parent:      82:20939e395812
>    user:        Ben Finney <ben at benfinney.id.au>
>    date:        Fri Jan 15 21:51:09 2010 +1100
>    summary:     Merge from lockfile.python-package/.
>
>    changeset:   119:7f1c13ffa03f
>    user:        Ben Finney <ben at benfinney.id.au>
>    date:        Fri Jan 15 21:46:06 2010 +1100
>    summary:     Increment to version 0.9 and make a release entry.
>
>    changeset:   109:fc18c8d7aea1
>    branch:      pidlockfile
>    user:        Ben Finney <ben at benfinney.id.au>
>    date:        Sat Sep 26 20:34:27 2009 +1000
>    summary:     Implement ?TimeoutPIDLockFile? for advance  
> specification of lock acquire timeout.
>
>    changeset:   99:cf798a2c6a22
>    branch:      timeout-raises-already-locked
>    user:        Ben Finney <ben+python at benfinney.id.au>
>    date:        Sat Jul 04 23:43:30 2009 +1000
>    summary:     Fix trailing whitespace.
>
>    changeset:   92:5719e4379589
>    branch:      generalise-path
>    user:        Ben Finney <ben+python at benfinney.id.au>
>    date:        Tue Apr 21 21:57:59 2009 +1000
>    summary:     Refactor more fixtures to scenarios.
>
> How can I whittle them down?

Two choices here. Either merge the heads together, or if you don't  
want to keep anything but one of the heads, do 'hg clone -r  
<revision>' to get a repo that has only that head. If you want to  
merge heads X and Y, do the following:

hg co X
hg merge Y
<resolve conflicts as needed>
hg commit -m Merge

> 2. I have multiple parents:
>
>    % hg parents
>    changeset:   82:20939e395812
>    user:        Skip Montanaro <skip at pobox.com>
>    date:        Sun Apr 05 14:43:05 2009 -0500
>    summary:     a couple more python 2/3 diffs
>
>    changeset:   109:fc18c8d7aea1
>    branch:      pidlockfile
>    user:        Ben Finney <ben at benfinney.id.au>
>    date:        Sat Sep 26 20:34:27 2009 +1000
>    summary:     Implement ?TimeoutPIDLockFile? for advance  
> specification of lock acquire timeout.

This looks like you started a merge.

> and local mods:
>
>    % hg status
>    M MANIFEST
>    M PKG-INFO
>    M README
>    M RELEASE-NOTES
>    M doc/lockfile.rst
>    M lockfile.py
>    M pidlockfile.py
>    M setup.py
>    M test/__init__.py
>    M test/scaffold.py
>    M test/test_pidlockfile.py
>    A test/test_lockfile.py
>    R test_lockfile.py
>
> How can I get rid of changeset 109 as a parent and just be left with
> changeset 82 as a parent while not losing any current local  
> modifications?

This is extremely tricky, but can be (sort of) done. First though, is  
there a reason you don't want the merge?

What I'd recommend is that you do is this:
hg diff --git > /tmp/mychanges.diff # stash all the changes to a  
tempfile. I'd recommend inspecting its contents to ensure they look  
sane.
hg up --clean 82 # This throws out all your changes and moves you to  
having a checkout of revision 82
hg import --no-commit /tmp/mychanges.diff # This applies the patch we  
created in step one.


That said, I don't know how well that will work. It could be worth a  
shot, but I'd recommend backing up your working area before trying  
just in case so you don't lose work.

For future reference, the usual practice with Mercurial (and Git) is  
to merge as a single operation, and not have any other edits go into  
that commit (except, depending on who you talk to, to fix tests before  
finishing the merge). That helps keep changes single-topic and easy to  
backout, as well as preventing this kind of problem.

I hope this helps!

Augie

> Thx,
>
> Skip
> _______________________________________________
> Chicago mailing list
> Chicago at python.org
> http://mail.python.org/mailman/listinfo/chicago



More information about the Chicago mailing list