Ahmed A
Ahmed A

Reputation: 3652

Move changesets from "default" branch to another branch created from it

In my main repo (on the server), there is the usual "default" branch, and an new one created from it called "my-dev". I will be pushing changes to "my-dev" branch. Periodically I would like to pull in changes from "default" branch, to keep the two branches synced with respect to default. My initial steps are:

hg clone default
hg update my-dev
// Make changes 
// Commit, push changesets into my-dev branch.

Now time to sync "default" and "my-dev".

  1. Pull in changes from the "default" branch in repo to local workspace. (Is it "hg pull -b default" ?).
  2. Move over the newly pulled down changesets from "default" to "my-dev".

Can someone please suggest me the commands/options for step 1 and 2.

In git, for step 2 I would do a "git rebase". All the new changesets in "my-dev" since the creation of "my-dev" are undone, changesets are brought in from "default" branch (no conflict occurs and should not occur). Then my changesets are applied back one by one. Any conflict that occurs, I need to fix each one. Bottom line, the changesets brought in from "default" stay intact (same hash, no modification needed as a result of merge conflict). However, I might require updating my changesets (which is ok) that I pushed into "my-dev".

UPDATE: After completion of feature in my-dev branch (in a few months), I would like to move all the changesets in my-dev back onto default.

Upvotes: 1

Views: 387

Answers (1)

Lazy Badger
Lazy Badger

Reputation: 97280

Preface:

The faster you forget Git-habits and Git-style, the easier it will be to grok HG-Style: Mercurial and Git share only common category of tool (DVCS) and some very general bases, but: differ in many concepts and (even worse) use the the same terms for different objects and operations (f.e. "branch" and "rebasing")

Face:

In Mercurial you have more than one way for transferring changesets as-is between different parent-nodes in DAG:

but, for your task ("periodically bring changes from BRANCH to BRANCH"), in Mercurial-world we most often use old good merge (more reabable and clean and short DAG) as "the natural way"

Branch Merges

(in this real-world sample I used Cleanup branch for separate task /proofreading/ and periodically bring polished text into WIP-mainline)

Notes:

For simplicity and tranquility I prefer to pull my-dev also (theoretically, 3-rd party changesets may appear in shared branch) before pushing it. Maybe, the lazy way of pulling the whole repo will be OK also (a bit of branches, small intensity of changes)

Upvotes: 1

Related Questions