When actions should be enabled

Simple cases

  • Open - always

Apart from Open, everything depends in the first instance on having a valid local work path -- this will be assumed below.

  • Refresh - always
  • Preview - whenever a remote URL is set
  • Pull - whenever a remote URL is set
  • Push - whenever a remote URL is set

More complicated things

  • Revert - whenever a file has been modified, added, or removed since commit
  • Commit - whenever a file has been modified, added, or removed since commit

Some of the remaining functions look like they should behave differently depending on whether the Work tab or History tab is active. However, I think that's probably confusing -- they should behave the same regardless of which tab is selected; that behaviour should be the "most obvious" behaviour where possible; and they should notify you quite clearly of what you are about to do in a confirmation dialog (which should be the same dialog as asks for your commit message, if appropriate).

Generally speaking, when I've characterised in the past behaviour as varying by tab, that's because I've been imagining having a separate selection in both tabs. But I think that's wrong -- there should be no selection in the History tab. If you want to use a specific changeset in a function, there should be a right-button menu for that. There are no "beginner" functions that need a specific changeset, only "expert" ones. (What should go in such a right-button menu?)

  • Add - when at least one untracked file is selected, and no other files are
  • Remove - when at least one tracked file is selected, and no untracked files are

N.B. the latter implies we need to be able to show unmodified, tracked files.

  • Update - in principle, should be active only when current branch has something to update to. In practice that may be too complicated, so probably just make it active always.
  • Merge - only when the current branch has more than one head? otherwise, use context menu in History tab

Review this.

Diff

  • No changes since commit - inactive
  • No modified files selected - show diff for folder against parent
  • Modified files selected - show diff for files against parent

Functions currently missing entirely

  • Create branch
  • Tag
  • Rename

How to determine some things

Whether a default merge makes sense:

hg heads `hg branch`

and see whether (a) exactly two heads are returned and (b) the current revision is one of them.

Whether a no-args update would do anything:

hg heads `hg branch`

and see whether the current parent is not among the returned heads. (what if more than one parent?)