TortoiseHg - How to create patch without committing first
Asked Answered
W

4

21

When I want to create a patch from uncommitted changes, do I really have to first commit? Does TortoiseHg not allow creating a patch without performing a commit?

Worlock answered 23/3, 2011 at 14:0 Comment(0)
P
22

TortoiseHg 2.0.2: in workbench you can right-click on the Working Directory line and select Export / Copy patch from the contextual menu - the resulting diff will be placed in clipboard.

Of course, you won't have the changeset header and the commit message at the beginning of the patch like you will get from the same operation made on a commit:

# HG changeset patch
# User John Doe <[email protected]>
# Date 1300889184 -7200
# Node ID 0050250004150030450034543labc23598235325
# Parent  098140937509174fbca7089686d986986e06f097
Sample commit message ...

Thanks to xanatos:

You can enable the "git format" for diffs (that include binary data) in the workbench: File->Settings->Compare->Git Format = True (the default value is unspecified, that seems to be equal to False)

Protest answered 23/3, 2011 at 15:9 Comment(0)
D
4

Is hg diff -g what you are looking for?

Taken from "How can I diff and patch files?" of https://developer.mozilla.org/en/Mercurial_FAQ

Datnow answered 23/3, 2011 at 14:13 Comment(0)
K
1

for a single file in your workbench (tortoisehg), you click on you working directory and the in the file list pane, right click on the file, and as @alexandrul said click Copy Patch

Klump answered 22/2, 2013 at 5:51 Comment(1)
Next, Repository> Import Patches has an button 'Import from clipboard'Bacon
C
0

Although that feature has been requested for a long time, TortoiseHg still doesn't offer a direct way to do that as of 6.4.2 (2023).

You can however use the Working Directory line's contextual menu to select Export -> Copy patch then paste the resulting diff from the clipboard to a new file (using a text editor such as Notepad).

Be aware that:

  1. such patches will exclude binary file diffs, unless Git Format is enabled. Git Format can be enabled in File->Settings, in the Diff tab. (Thanks alexandrul and xanatos)
  2. such patches will exclude new files, even if they are selected. This can be worked around by scheduling these for addition.
  3. non-ASCII characters in file contents may be misencoded. This can be worked around by using the command line instead (hg diff). Alternatively, the gratis Atlassian Sourcetree also offers to create patches, graphically. Despite what the website suggests, it does support Mercurial, although it's proprietary.
Cheek answered 19/5, 2023 at 14:48 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.