comparison mercurial/commands.py @ 6161:bc1ba9124799

Reverse the way backout is doing the merge Currently, backout is creating a backout revision as a child node of the backed out node and will leave you at this new head. This has several drawbacks: * this changes the current head * when there is a long history between the backed out node and the current head, this will generate a huge number of diffs that are scary at first sight, and not very natural to review before commit. The change consists to switch back to the original node as soon as the backout node (which becomes the new tip) has been created. Then the --merge option can just merge this new tip in the current node. * the current head/node is not changed from the user's point of view * even without using the --merge option, the backout revision is still easy to locate, as this is the tip * the merge is much more intuitive as diffs of the merge is right you are looking to backout
author Gilles Moris <gilles.moris@free.fr>
date Thu, 21 Feb 2008 08:52:52 +0100
parents e3dd35d3603b
children 1f733c2f0165
comparison
equal deleted inserted replaced
6160:3ee3bc5d06c5 6161:bc1ba9124799
175 175
176 Commit the backed out changes as a new changeset. The new 176 Commit the backed out changes as a new changeset. The new
177 changeset is a child of the backed out changeset. 177 changeset is a child of the backed out changeset.
178 178
179 If you back out a changeset other than the tip, a new head is 179 If you back out a changeset other than the tip, a new head is
180 created. This head is the parent of the working directory. If 180 created. This head will be the new tip and you should merge this
181 you back out an old changeset, your working directory will appear 181 backout changeset with another head (current one by default).
182 old after the backout. You should merge the backout changeset
183 with another head.
184 182
185 The --merge option remembers the parent of the working directory 183 The --merge option remembers the parent of the working directory
186 before starting the backout, then merges the new head with that 184 before starting the backout, then merges the new head with that
187 changeset afterwards. This saves you from doing the merge by 185 changeset afterwards. This saves you from doing the merge by
188 hand. The result of this merge is not committed, as for a normal 186 hand. The result of this merge is not committed, as for a normal
241 def nice(node): 239 def nice(node):
242 return '%d:%s' % (repo.changelog.rev(node), short(node)) 240 return '%d:%s' % (repo.changelog.rev(node), short(node))
243 ui.status(_('changeset %s backs out changeset %s\n') % 241 ui.status(_('changeset %s backs out changeset %s\n') %
244 (nice(repo.changelog.tip()), nice(node))) 242 (nice(repo.changelog.tip()), nice(node)))
245 if op1 != node: 243 if op1 != node:
244 hg.clean(repo, op1, show_stats=False)
246 if opts['merge']: 245 if opts['merge']:
247 ui.status(_('merging with changeset %s\n') % nice(op1)) 246 ui.status(_('merging with changeset %s\n') % nice(repo.changelog.tip()))
248 hg.merge(repo, hex(op1)) 247 hg.merge(repo, hex(repo.changelog.tip()))
249 else: 248 else:
250 ui.status(_('the backout changeset is a new head - ' 249 ui.status(_('the backout changeset is a new head - '
251 'do not forget to merge\n')) 250 'do not forget to merge\n'))
252 ui.status(_('(use "backout --merge" ' 251 ui.status(_('(use "backout --merge" '
253 'if you want to auto-merge)\n')) 252 'if you want to auto-merge)\n'))