4

I have two repos, dev and testing. In dev, I've made several commits since the last push to testing. However, now I want to shelve all those commits, make a different change, push it to testing, and then get those commits back. Shelving only works on uncommitted files.

What should I do? Backout or rollback or revert each commit in reverse order? Rename dev, clone testing to dev, make changes, push to testing, push to renamed dev, delete dev, rename renamed dev back to dev?

What's the cleanest/easiest way to do this?

StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
Kev
  • 15,899
  • 15
  • 79
  • 112
  • It may seem strange, but with our current setup I need "dev" to remain "dev" during certain parts of the build process, hence the renaming suggestion. – Kev Jan 15 '13 at 15:42

2 Answers2

3

For clarity to other readers: the actual HG shelve command is not the correct approach for this situation; it does not work on already-committed changes, but nor is it necessary to use in this case.

Here's what you can do:

  1. In dev, update to the version before the commits you don't want to push to testing.
  2. Make your desired changes in dev and commit. This will create a new head (which will also be the new tip).
  3. Push to testing
  4. In dev, merge the tip with the other head that contains the changes you have avoided pushing, then commit.

Original suggestion (not possible to implement in this case):

  1. Clone dev into a new repo and update to the version before the commits (or just clone testing instead)
  2. Make the change you want, commit and push to both testing and dev
  3. Discard the clone
  4. Pull the testing from testing into dev and merge the heads at your leisure, establishing a single head once more
StayOnTarget
  • 11,743
  • 10
  • 52
  • 81
Jon
  • 428,835
  • 81
  • 738
  • 806
  • This sounds good, except that I need "dev" to be called "dev" during the build process. I.e. I need it to look, temporarily, as if I had never made these commits, and instead made today's commit only. The build process then automatically pushes changes to testing. Further I think it won't run the rest of the build process if there aren't any changes. – Kev Jan 15 '13 at 15:50
  • Is it possible to do 1. but update dev (rather than the clone) to the pre-commits version, then somehow pull the changes back from the clone later? – Kev Jan 15 '13 at 15:53
  • @Kev: I see. How does the build server pick what to build? Does it use `tip`? – Jon Jan 15 '13 at 15:55
  • yes, always the tip, and checks there's nothing outstanding using `hg status` and `hg in` – Kev Jan 15 '13 at 16:05
  • @Kev: Updated the answer. You will create a new head just for the new changes, then merge with the previous head (which contains your earlier commits) to continue working. – Jon Jan 15 '13 at 16:11
  • Oh, okay, brilliant. This feels like how hg is supposed to work, smoothly. I don't often deal with new heads and such--thanks for helping clarify this for me! – Kev Jan 15 '13 at 16:15
  • Seems to be working, it's in the middle of the build but the hg end looks right so far. I'm glad you could understand what I was saying, I feel like I wasn't writing terribly clearly. Thanks for your help! – Kev Jan 15 '13 at 16:34
  • Step 3 isn't best - without additional options push commit all changesets (both anonymous branches) and hangs on "push add new heads". `hg push -r tip` in order to skip second branch – Lazy Badger Jan 15 '13 at 17:00
  • @LazyBadger, not sure what you mean--committing all changesets seems to be the best thing to do here. Now that it's done, I can see the second head and will later see the merge appear in testing, just as it appears in dev, which is an accurate and clear record of what happened. – Kev Jan 15 '13 at 21:08
  • Not the best, if you anyway push all there aren't needs for anonymous branching and second head... If you really want **delayed push** of earlier commits **after** new tip and in separate push – Lazy Badger Jan 15 '13 at 21:34
0

Another workflow may be: Use MQ extension

Community
  • 1
  • 1
Lazy Badger
  • 94,711
  • 9
  • 78
  • 110