[meld] vc: Fix "meld <file>" operation



commit 5eba0fea9ad7d9d31f3d2619883298bf66326e4b
Author: Peter Tyser <ptyser gmail com>
Date:   Sat Dec 14 11:50:08 2013 -0600

    vc: Fix "meld <file>" operation
    
    Add a check to choose_vc() to make sure it always checks if a directory
    supports version control.  Previously it would check if a file supported
    version control.  Version control is always supported on a directory
    basis, and the underlying meld version control support doesn't support
    checking if a specific file is under version control which would lead to
    a runtime error similar to:
    
    Traceback (most recent call last):
      File "/home/user/meld/meld/meldapp.py", line 81, in do_command_line
        self.parse_args(command_line.get_arguments()[1:])
      File "/home/user/meld/meld/meldapp.py", line 205, in parse_args
        auto_merge=options.auto_merge, new_tab=options.newtab)
      File "/home/user/meld/meld/meldapp.py", line 120, in open_paths
        return self.window.open_paths(paths, **kwargs)
      File "/home/user/meld/meld/meldwindow.py", line 713, in open_paths
        self._single_file_open(a)
      File "/home/user/meld/meld/meldwindow.py", line 703, in _single_file_open
        doc.set_location(path)
      File "/home/user/meld/NEWS", line 356, in set_location
        self.choose_vc(location)
      File "/home/user/meld/NEWS", line 304, in choose_vc
        elif not avc.valid_repo(location):
      File "/home/user/meld/meld/vc/git.py", line 263, in valid_repo
        return not _vc.call([cls.CMD, "branch"], cwd=path)
      File "/home/user/meld/meld/vc/_vc.py", line 338, in call
        return subprocess.call(cmd, cwd=cwd, stdout=NULL, stderr=NULL)
      File "/usr/lib/python2.7/subprocess.py", line 522, in call
        return Popen(*popenargs, **kwargs).wait()
      File "/usr/lib/python2.7/subprocess.py", line 709, in __init__
        errread, errwrite)
      File "/usr/lib/python2.7/subprocess.py", line 1326, in _execute_child
        raise child_exception
    OSError: [Errno 20] Not a directory: '/home/user/meld/NEWS'
    
    Signed-off-by: Peter Tyser <ptyser gmail com>

 meld/vcview.py |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
---
diff --git a/meld/vcview.py b/meld/vcview.py
index 5b4be8c..14c41d8 100644
--- a/meld/vcview.py
+++ b/meld/vcview.py
@@ -282,6 +282,11 @@ class VcView(melddoc.MeldDoc, gnomeglade.Component):
         default_active = -1
         valid_vcs = []
         location = os.path.abspath(location or ".")
+
+        # VC systems work at the directory level, so make sure we're checking
+        # for VC support there instead of on a specific file.
+        if os.path.isfile(location):
+            location = os.path.dirname(location)
         vcs = vc.get_vcs(location)
         # Try to keep the same VC plugin active on refresh()
         for idx, avc in enumerate(vcs):


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]