[meld] Remove support for diff-style file+folder invocation, and error better
- From: Kai Willadsen <kaiw src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [meld] Remove support for diff-style file+folder invocation, and error better
- Date: Mon, 14 Oct 2013 21:10:41 +0000 (UTC)
commit 3d540542508d49be8e2d3de48daceefa43c816dd
Author: Kai Willadsen <kai willadsen gmail com>
Date: Mon Oct 7 14:10:45 2013 +1000
Remove support for diff-style file+folder invocation, and error better
meld/meldapp.py | 54 ++++++++++++++++++++++++++++++---------------------
meld/meldwindow.py | 21 +------------------
2 files changed, 34 insertions(+), 41 deletions(-)
---
diff --git a/meld/meldapp.py b/meld/meldapp.py
index 7eb7392..54eb4d4 100644
--- a/meld/meldapp.py
+++ b/meld/meldapp.py
@@ -170,15 +170,15 @@ class MeldApp(Gtk.Application):
parser.values.diff.append(diff_files_args)
def parse_args(self, rawargs):
- usages = [("", _("Start with an empty window")),
- ("<%s|%s>" % (_("file"), _("dir")),
- _("Start a version control comparison")),
- ("<%s> <%s> [<%s>]" % ((_("file"),) * 3),
- _("Start a 2- or 3-way file comparison")),
- ("<%s> <%s> [<%s>]" % ((_("dir"),) * 3),
- _("Start a 2- or 3-way directory comparison")),
- ("<%s> <%s>" % (_("file"), _("dir")),
- _("Start a comparison between file and dir/file"))]
+ usages = [
+ ("", _("Start with an empty window")),
+ ("<%s|%s>" % (_("file"), _("dir")),
+ _("Start a version control comparison")),
+ ("<%s> <%s> [<%s>]" % ((_("file"),) * 3),
+ _("Start a 2- or 3-way file comparison")),
+ ("<%s> <%s> [<%s>]" % ((_("dir"),) * 3),
+ _("Start a 2- or 3-way directory comparison")),
+ ]
pad_args_fmt = "%-" + str(max([len(s[0]) for s in usages])) + "s %s"
usage_lines = [" %prog " + pad_args_fmt % u for u in usages]
usage = "\n" + "\n".join(usage_lines)
@@ -216,9 +216,6 @@ class MeldApp(Gtk.Application):
elif options.auto_merge and any([os.path.isdir(f) for f in args]):
parser.error(_("can't auto-merge directories"))
- for files in options.diff:
- self.open_paths(files, new_tab=options.newtab)
-
if options.comparison_file or (len(args) == 1 and
args[0].endswith(".meldcmp")):
path = options.comparison_file or args[0]
@@ -228,18 +225,31 @@ class MeldApp(Gtk.Application):
tab = self.window.append_recent(gio_file.get_uri())
except (IOError, ValueError):
parser.error(_("Error reading saved comparison file"))
- elif args:
- tab = self.open_paths(
- args, auto_compare=options.auto_compare,
- auto_merge=options.auto_merge, new_tab=options.newtab)
- else:
- tab = None
+ return tab
+
+ error = None
+ comparisons = options.diff + [args]
+ for paths in comparisons:
+ try:
+ tab = self.open_paths(
+ paths, auto_compare=options.auto_compare,
+ auto_merge=options.auto_merge, new_tab=options.newtab)
+ except ValueError as err:
+ error = err
+
+ if options.label:
+ tab.set_labels(options.label)
+
+ if options.outfile and isinstance(tab, filediff.FileDiff):
+ tab.set_merge_output_file(options.outfile)
+
+ if error:
+ if not self.window.has_pages():
+ parser.error(error)
+ else:
+ print(error)
- if options.label and tab:
- tab.set_labels(options.label)
- if options.outfile and tab and isinstance(tab, filediff.FileDiff):
- tab.set_merge_output_file(options.outfile)
app = MeldApp()
diff --git a/meld/meldwindow.py b/meld/meldwindow.py
index 9b1a67e..6ea84ca 100644
--- a/meld/meldwindow.py
+++ b/meld/meldwindow.py
@@ -656,25 +656,8 @@ class MeldWindow(gnomeglade.Component):
dirslist = [p for p in paths if os.path.isdir(p)]
fileslist = [p for p in paths if os.path.isfile(p)]
if dirslist and fileslist:
- # Build the file list by appending filenames to directories,
- # reproducing a feature of diff. This should be reconsidered.
- lastfilename = fileslist[0]
- builtfilelist = []
- for elem in paths:
- if os.path.isdir(elem):
- builtfilename = os.path.join(elem, lastfilename)
- if os.path.isfile(builtfilename):
- elem = builtfilename
- else:
- misc.run_dialog(
- _("Cannot compare a mixture of files and "
- "directories.\n"),
- parent=self, buttonstype=Gtk.ButtonsType.OK)
- return
- else:
- lastfilename = os.path.basename(elem)
- builtfilelist.append(elem)
- return self.append_filediff(builtfilelist)
+ raise ValueError(
+ _("Cannot compare a mixture of files and directories"))
elif dirslist:
return self.append_dirdiff(paths, auto_compare)
elif auto_merge:
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]