/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to __init__.py

  • Committer: Parth Malwankar
  • Date: 2010-02-27 02:55:47 UTC
  • mto: (0.44.2 grep) (6531.3.1 merge-grep)
  • mto: This revision was merged to the branch mainline in revision 6555.
  • Revision ID: parth.malwankar@gmail.com-20100227025547-09kfurm3pi27cgil
used try - finally instead of add_cleanup to get plugin to work with 2.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
101
101
        rev = start_rev
102
102
 
103
103
        wt.lock_read()
104
 
        self.add_cleanup(wt.unlock)
105
 
        for path in path_list:
106
 
            tree = rev.as_tree(wt.branch)
107
 
            revid = rev.as_revision_id(wt.branch)
108
 
            try:
109
 
                revno = ".".join([str(n) for n in id_to_revno[revid]])
110
 
            except KeyError, e:
111
 
                trace.warning("warning: file '%s' is not versioned." % path)
112
 
                continue
113
 
 
114
 
            if osutils.isdir(path):
115
 
                self._grep_dir(tree, relpath, recursive, line_number,
116
 
                    patternc, from_root, eol_marker, revno, print_revno)
117
 
            else:
118
 
                id = tree.path2id(path)
119
 
                if not id:
 
104
        try:
 
105
            for path in path_list:
 
106
                tree = rev.as_tree(wt.branch)
 
107
                revid = rev.as_revision_id(wt.branch)
 
108
                try:
 
109
                    revno = ".".join([str(n) for n in id_to_revno[revid]])
 
110
                except KeyError, e:
120
111
                    trace.warning("warning: file '%s' is not versioned." % path)
121
112
                    continue
122
 
                tree.lock_read()
123
 
                try:
124
 
                    grep.file_grep(tree, id, '.', path, patternc, eol_marker,
125
 
                        self.outf, line_number, revno, print_revno)
126
 
                finally:
127
 
                    tree.unlock()
 
113
 
 
114
                if osutils.isdir(path):
 
115
                    self._grep_dir(tree, relpath, recursive, line_number,
 
116
                        patternc, from_root, eol_marker, revno, print_revno)
 
117
                else:
 
118
                    id = tree.path2id(path)
 
119
                    if not id:
 
120
                        trace.warning("warning: file '%s' is not versioned." % path)
 
121
                        continue
 
122
                    tree.lock_read()
 
123
                    try:
 
124
                        grep.file_grep(tree, id, '.', path, patternc, eol_marker,
 
125
                            self.outf, line_number, revno, print_revno)
 
126
                    finally:
 
127
                        tree.unlock()
 
128
        finally:
 
129
            wt.unlock()
128
130
 
129
131
    def _grep_dir(self, tree, relpath, recursive, line_number, compiled_pattern,
130
132
        from_root, eol_marker, revno, print_revno):