74554

Mercurial show diff against 2 parents or base during merge

Question:

Our teem recently faced with merge that removes one leaf of merge and we "lost" changes (as if you perform hg merge --tool internal:local).

This happen because we don't experienced with hg merge command.

hg diff shown only one difference, but not other.

BASE --- HEAD1 --- MERGE \---- HEAD2 --/

Suppose in <em>HEAD1</em> I merge <em>HEAD2</em> but has not yet commit changes.

<em>HEAD2</em> diff against <em>MERGE</em> I see by hg diff. It is -r BASE:HEAD2 patch.

How can I see diff between current local merge state with <em>HEAD1</em> as if we merge from <em>HEAD2</em>

How can I see diff between current local merge state with <em>BASE</em>?

Answer1:

Thanks @Vince for suggestion. I reread hg help diff and hg help revset and get that I want.

Assume that you at <em>MERGE</em> before commit and perform merge from <em>HEAD1</em>.

To compare diff against <em>HEAD1</em> use one of:

hg diff hg diff -r . hg diff -r HEAD1

Check:

hg log -r .

To compare diff against <em>HEAD1</em> use one of:

hg diff -r HEAD2

If you have only 2 heads in current branch last expression can be written without <em>HEAD2</em> name:

hg diff -r 'branch(.) & head() - .'

Check:

hg log -r 'branch(.) & head() - .'

To compare against <em>BASE</em>:

hg log -r 'ancestor(HEAD1, HEAD2)'

If you have only 2 heads in current branch last expression can be written without <em>HEAD1</em>/<em>HEAD2</em> names::

hg diff -r 'ancestor(branch(.) & head())'

Check:

hg log -r 'ancestor(branch(.) & head())'

I wander if there are any shortcut for second parent of current merge. For first - just dot sign...

<strong>UPDATE</strong> Hm... p1() and p2() are awesome! I rewrote my examples in way that they have no concrete names <em>HEAD1</em>/<em>HEAD2</em>:

hg diff -r 'p1()' hg diff -r 'p2()' hg diff -r 'ancestor(p1(), p2())'

Recommend

  • how to use ajax in JQuery
  • How to make fixed table header scroll horizontally in sync with tbody data?
  • ssrs url path string manipulation
  • Redirect URI not redirecting correctly
  • Manually binding data to Gridview
  • QGraphicsLineItem::paint() artifacts
  • Shuffling an linked list Java
  • Merge multiple data frames with different dimensions using Pandas
  • Performance of small sets in Python
  • How to write files in C:\\Windows\\System32 with full permissions
  • UILabel Refresh
  • How to add header line to CSV without loading whole file?
  • Why am I getting a “package could not be registered” deployment error on Windows 10 UWP?
  • Read and Write DOCX file
  • Source file (.py) not compiling (.pyc not updated)
  • angularJS library for drawing bar charts with logarithmic scale
  • how to handle large size of update query in mysql with laravel
  • How to show a specific VC , more like navigate to a stack of VC
  • Adding independent aspx/asmx pages into DotNetNuke
  • How to merge keras sequential models with same input?
  • How to create two column output from a single column
  • hibernate sets dirty flag (and issues update) even though client did not change value
  • Can I have a variable number of URI parameters or key-value pairs in Laravel 4?
  • How can I get the choice “H2” back in the H2 consol?
  • How can Delete be both a DDL and a DML statement
  • In matplotlib, how do you change the fontsize of a single figure?
  • how do i write assembly code from c#?
  • Spring: No transaction manager has been configured
  • Approximate Order-Preserving Huffman Code
  • as3-flash: any way to access all the instances placed in different frames from document class?
  • accepts_nested_attributes_for practical form use for in Rails 3
  • Java color detection
  • Object and struct member access and address offset calculation
  • zope_i18n_compile_mo_files doesn't work on a Zeo configuration
  • OOP Javascript - Is “get property” method necessary?
  • Does it make sense to call System.gc() and Thread.sleep() when working on Bitmaps?
  • Caching attributes in superclass
  • Scrapy recursive link crawler
  • Why can't I rebase on to an ancestor of source changesets if on a different branch?
  • Is there any way to bind data to data.frame by some index?