15

How can I combine the Mercurial commands hg pull and hg update into one?

Petrus Theron
  • 27,855
  • 36
  • 153
  • 287

4 Answers4

30

Obviously, hg pull -u is the answer here.

However, there's a caveat that deserves mentioning: hg pull -u is not exactly equivalent to hg pull && hg update. This is briefly mentioned in the documentation, but it can be surprising if you first run into it; if there's nothing to pull (e.g. no new changesets came in), then hg pull -u doesn't update. This can be slightly confusing if you weren't on a head before issuing the command.

djc
  • 11,603
  • 5
  • 41
  • 54
  • 1
    Does TortoiseHg have an equivalent? – User Dec 10 '13 at 00:30
  • Unfortunately, since `hg pull -u` does exactly what djc describes, I have had to resort to the `hg pull && hg update` as the only way to get this to work like "git pull", thanks for the tip. – rogerdpack May 21 '14 at 16:58
  • 1
    @User - In TortoiseHg you can go to 'Settings' > 'Sync' > 'After Pull Operation' and select "update" from the drop down to do an automatic update after a pull. The hints at the bottom of the page say that it "equates" to `pull --update`. – Tim Tisdall Nov 26 '15 at 14:06
4

type hg help pull and you will see the -u switch

adrianm
  • 14,468
  • 5
  • 55
  • 102
2

You can use:

hg pull -u

Read the documentation for more options.

Eldad Assis
  • 10,464
  • 11
  • 52
  • 78
1

The hg fetch extension will do the same once enabled. However, it has fallen out of favor and is noted as an "unloved feature" by the Mercurial team.

rogerdpack
  • 62,887
  • 36
  • 269
  • 388
Mark
  • 452
  • 2
  • 9