~ubuntu-branches/ubuntu/lucid/meld/lucid

« back to all changes in this revision

Viewing changes to vc/mercurial.py

  • Committer: Bazaar Package Importer
  • Author(s): Ross Burton
  • Date: 2009-06-02 10:00:20 UTC
  • mfrom: (1.2.9 upstream) (2.1.5 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090602100020-jb5wlixbu8xws29a
Tags: 1.3.0-1
* New upstream release (Closes: #528327)
  - Copy/paste behaviour fixes (Closes: #523576)
  - Dotfiles and removals handled in darcs (Closes: #509069)
  - Can handle Mercurial repos (Closes: #428843)
  - Up/Down patch used to skip changes (Closes: #511027)
  - Handle last line when highlighting properly (Closes: #465804)
* Update message and depends for new python-gtksourceview2 package
* Resync makefile.patch
* Remove python-gnome dependency

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
    CMD = "hg"
31
31
    NAME = "Mercurial"
 
32
    VC_DIR = ".hg"
32
33
    PATCH_STRIP_NUM = 1
33
 
    PATCH_INDEX_RE = "^diff -r \w+ (.*)$"
34
 
 
35
 
    def __init__(self, location):
36
 
        while location != "/":
37
 
            if os.path.isdir( "%s/.hg" % location):
38
 
                self.root = location
39
 
                return
40
 
            location = os.path.dirname(location)
41
 
        raise ValueError()
 
34
    # Mercurial diffs can be run in "git" mode
 
35
    PATCH_INDEX_RE = "^diff (?:-r \w+ |--git a/.* b/)(.*)$"
 
36
    DIFF_GIT_MODE = False
42
37
 
43
38
    def commit_command(self, message):
44
39
        return [self.CMD,"commit","-m",message]
45
40
    def diff_command(self):
46
 
        return [self.CMD,"diff"]
 
41
        ret = [self.CMD,"diff"]
 
42
        if self.DIFF_GIT_MODE:
 
43
            ret.append("--git")
 
44
        return ret
47
45
    def update_command(self):
48
46
        return [self.CMD,"update"]
49
47
    def add_command(self, binary=0):
59
57
 
60
58
        while 1:
61
59
            try:
62
 
                entries = os.popen('cd "%s" && hg status -A .'%directory).read().split("\n")[:-1]
 
60
                entries = os.popen('cd "%s" && %s status -A .' % (directory, self.CMD)).read().split("\n")[:-1]
63
61
                break
64
62
            except OSError, e:
65
63
                if e.errno != errno.EAGAIN:
78
76
        hgfiles = {}
79
77
        for statekey, name in [ (entry[0], entry[2:]) for entry in entries if entry.find("/")==-1 ]:
80
78
            path = os.path.join(directory, name)
81
 
            rev, date, options, tag = "","","",""
 
79
            rev, options, tag = "","",""
82
80
            state = statemap.get(statekey, _vc.STATE_NONE)
83
81
            retfiles.append( _vc.File(path, name, state, rev, tag, options) )
84
82
            hgfiles[name] = 1
94
92
                retdirs.append( _vc.Dir(path, d, state) )
95
93
 
96
94
        return retdirs, retfiles
97
 
 
98