Is it possible to manually change/reorder the revision numbers (provided topology remains the same)?

前端 未结 5 957
再見小時候
再見小時候 2020-12-06 19:01

In Mercurial , revision numbers are local-clone specific, and they are provided as a facility to point to a specific changeset in a more user-friendly way than a changeset i

5条回答
  •  粉色の甜心
    2020-12-06 19:39

    I have a similar use case: I came to this question because I pushed a bunch of changesets from different branches at once, and they did not arrive sorted by date. I now have some merges with low-numbered parents that are not in fact that old; scrolling up and down the log to see them is a pain. I followed the approach suggested in @Ry4an's answer-- it's really quite simple, if you can predict (i.e., compute) the changeset order you want.

    If your workflow only merges branch heads, you can get the desired revision order by sorting revsets by date. This you can do with the following command:

    hg log -r 'sort(0:tip, date)' --template '{rev}\n'
    

    You can then clone the repository and use a loop in your favorite scripting language to pull the revisions one by one in chronological order. Rather than init a repository from scratch, I ended up doing it like this:

    hg clone -r 0 messy-repo sorted-repo
    cd sorted-repo
    for REV in `hg log -R ../messy-repo -r 'sort(1:tip, date)' --template '{rev}\n'`
    do 
        hg pull ../messy-repo -r $REV
    done
    

    I should note (before somebody else does :-)) that this will increase the storage size of the repository, because of the way deltas are computed. I don't mind.

提交回复
热议问题