After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 447582 - Mercurial VC plugin error: "hg diff --git"
Mercurial VC plugin error: "hg diff --git"
Status: RESOLVED FIXED
Product: meld
Classification: Other
Component: filediff
1.1.x
Other Linux
: Normal normal
: ---
Assigned To: Vincent Legoll
Stephen Kennedy
Depends on:
Blocks:
 
 
Reported: 2007-06-14 15:53 UTC by Ross Burton
Modified: 2009-04-11 22:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
slightly different implementation, allow to easily test (807 bytes, patch)
2009-04-04 23:51 UTC, Vincent Legoll
none Details | Review

Description Ross Burton 2007-06-14 15:53:42 UTC
[from http://bugs.debian.org/428843]


When trying to compare files managed with mercurial, meld issues the
following error message:

Could not read from '/bc/w/eagle.work/-r d1406689352c daemon/src/global.h'

The error was: [Errno 2] No such file or directory:
'/bc/w/eagle.work/-r d1406689352c daemon/src/global.h'

Instead of comparing the local file with the version it has
correctly extracted in :
/tmp/tmpVoVDza-meld/-r\ d1406689352c\ daemon/src/global.h
meld does the comparison with a local inexistent file.

meld is using the current directory instead of the temporary generated
one in /tmp/tmpVoVDza-meld when it tries to open the file.
Comment 1 Stephen Kennedy 2007-06-14 21:03:37 UTC
Looks like the mercurial flags or patch format has changed again :(
I haven't looked yet, but it's likely that PATCH_INDEX_RE needs
to be updated.
Comment 2 Stephen Kennedy 2007-07-31 22:28:23 UTC
PATCH_INDEX_RE has been updated so normal diffs work.

New files still generate a warning about not being able to read the nonexistant "patched file".
Comment 3 Al 2008-12-17 16:06:27 UTC
Hello,

Problem still exist for meld version 1.2.1 which does not work with mercurial version 1.0.1.

The following simple patch corrects the issue:

--- vc/mercurial.py.org	2008-12-17 16:56:11.000000000 +0100
+++ vc/mercurial.py	2008-12-17 16:56:24.000000000 +0100
@@ -30,7 +30,7 @@
     CMD = "hg"
     NAME = "Mercurial"
     PATCH_STRIP_NUM = 1
-    PATCH_INDEX_RE = "^diff -r \w+ (.*)$"
+    PATCH_INDEX_RE = "^diff --git a/(.*) b/.*$"
 
     def __init__(self, location):
         while location != "/":

Seems mercurial now decided to use the same format as git. Should be easier for the future.
Comment 4 Al 2008-12-17 18:07:05 UTC
Stupid me, seems this is not the default behavior of mercurial, but is due to the fact that my .hgrc contains:

[diff]
git = True

So the code must be a little more clever to cope with this.

Comment 5 Al 2008-12-18 15:54:22 UTC
Hello,

A patch that works for me, whatever mercurial configuration I use:

--- meld-1.2.1.org/vcview.py	2008-10-02 23:34:54.000000000 +0200
+++ meld-1.2.1/vcview.py	2008-12-18 16:50:58.000000000 +0100
@@ -435,10 +435,12 @@
         tmpdir = tempfile.mkdtemp("-meld")
         self.tempdirs.append(tmpdir)
 
+        self.vc.PATCH_INDEX_RE = r"^diff (?:--git|-r) .+ (.+)$"
         regex = re.compile(self.vc.PATCH_INDEX_RE, re.M)
         files = [f.strip() for f in regex.findall(patch)]
         diffs = []
         for fname in files:
+            fname = fname.split('/')[-1]
             destfile = os.path.join(tmpdir,fname)
             destdir = os.path.dirname( destfile )

The REGEX should indeed go into meld-1.2.1/vc/mercurial.py

Best regards.
Comment 6 Vincent Legoll 2009-04-04 23:51:44 UTC
Created attachment 132103 [details] [review]
slightly different implementation, allow to easily test
Comment 7 Vincent Legoll 2009-04-11 22:54:26 UTC
r1342