Merge lp:~anj/bzr-keywords/handle-exceptions into lp:bzr-keywords

Proposed by Andrew Johnson
Status: Work in progress
Proposed branch: lp:~anj/bzr-keywords/handle-exceptions
Merge into: lp:bzr-keywords
Diff against target: 30 lines (+12/-1)
1 file modified
keywords.py (+12/-1)
To merge this branch: bzr merge lp:~anj/bzr-keywords/handle-exceptions
Reviewer Review Type Date Requested Status
Jelmer Vernooij (community) Needs Fixing
Review via email: mp+101141@code.launchpad.net

Description of the change

Various repository operations (e.g. rebasing or of merging two branches where one has deleted files in it) can generate exceptions during keyword expansion which prevent the operation from working. This branch adds code to handle those exceptions and thus permit the merge to complete normally.

I haven't checked whether this resolves bug #697260, but it might.

To post a comment you must log in.
Revision history for this message
Jelmer Vernooij (jelmer) wrote :

It seems a bit strange to catch NotImplementedError here - that should never occur here. When did you hit this?

Revision history for this message
Andrew Johnson (anj) wrote :

It's quite a while since I developed this patch and I don't remember the details of that one now, so it's possible that catch is not actually needed. The other one definitely is though, I can provide .bzr.log file entries for crashes that generated that.

Revision history for this message
Andrew Johnson (anj) wrote :
Download full text (4.1 KiB)

I lied, my home machine has that error logged:

Mon 2010-10-04 00:16:56 -0500
0.049 bazaar version: 2.1.1
0.049 bzr arguments: [u'unshelve']
0.066 looking for plugins in /home/anj/.bazaar/plugins
0.144 looking for plugins in /usr/lib/python2.6/dist-packages/bzrlib/plugins
0.145 Plugin name bzrtools already loaded
0.187 encoding stdout as sys.stdout encoding 'UTF-8'
0.255 opening working tree '/home/anj/Software/epics/mirror-3.14'
[ 3635] 2010-10-04 00:16:56.601 INFO: Using changes with id "1".
1.594 Traceback (most recent call last):
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 853, in exception_to_return_code
    return the_callable(*args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 1055, in run_bzr
    ret = run(*run_argv)
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 661, in run_argv_aliases
    return self.run_direct(**all_cmd_args)
  File "/usr/lib/python2.6/dist-packages/bzrlib/commands.py", line 665, in run_direct
    return self._operation.run_simple(*args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/cleanup.py", line 122, in run_simple
    self.cleanups, self.func, *args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/cleanup.py", line 156, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/builtins.py", line 5820, in run
    unshelver.run()
  File "/usr/lib/python2.6/dist-packages/bzrlib/shelf_ui.py", line 479, in run
    merger.do_merge()
  File "/usr/lib/python2.6/dist-packages/bzrlib/merge.py", line 658, in do_merge
    merge = operation.run_simple()
  File "/usr/lib/python2.6/dist-packages/bzrlib/cleanup.py", line 122, in run_simple
    self.cleanups, self.func, *args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/cleanup.py", line 156, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/merge.py", line 629, in _do_merge_to
    merge.do_merge()
  File "/usr/lib/python2.6/dist-packages/bzrlib/merge.py", line 766, in do_merge
    operation.run()
  File "/usr/lib/python2.6/dist-packages/bzrlib/cleanup.py", line 118, in run
    self.cleanups, self.func, self, *args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/cleanup.py", line 156, in _do_with_cleanups
    result = func(*args, **kwargs)
  File "/usr/lib/python2.6/dist-packages/bzrlib/merge.py", line 772, in _do_merge
    self._compute_transform()
  File "/usr/lib/python2.6/dist-packages/bzrlib/merge.py", line 814, in _compute_transform
    file_status = self._do_merge_contents(file_id)
  File "/usr/lib/python2.6/dist-packages/bzrlib/merge.py", line 1302, in _do_merge_contents
    hook_status, lines = hook.merge_contents(params)
  File "/usr/lib/python2.6/dist-packages/bzrlib/merge.py", line 1386, in merge_contents
    return self._default_other_winner_merge(merge_hook_params)
  File "/usr/lib/python2.6/dist-packages/bzrlib/merge.py", line 1369, in _default_other_winner_merge
    filter_tree_path=filter_tree_path)
  File "/usr/lib/python2.6/dist-packages/bzrlib/transform.py", line 2534, in create_from_tree
    ContentFilterContext(filter_tree_path,...

Read more...

Revision history for this message
Jelmer Vernooij (jelmer) wrote :

This looks alright. It would be great to have a test for this which reproduces the problematic situation this is supposed to handle.

review: Needs Fixing
21. By Andrew Johnson

Merged changes from official branch

Unmerged revisions

21. By Andrew Johnson

Merged changes from official branch

20. By Andrew Johnson

Handle various exceptions during keyword processing.

These tend to occur during merges or rebasing, when
one side or other has delted files in the tree.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'keywords.py'
2--- keywords.py 2011-03-02 12:31:59 +0000
3+++ keywords.py 2015-05-14 16:58:38 +0000
4@@ -17,6 +17,7 @@
5 import re, time
6 from bzrlib import (
7 debug,
8+ errors,
9 osutils,
10 registry,
11 trace,
12@@ -204,7 +205,17 @@
13 if 'error' in debug.debug_flags:
14 trace.note("error evaluating %s for keyword %s: %s",
15 expansion, keyword, err)
16- expansion = "(evaluation error)"
17+ expansion = None
18+ except NotImplementedError, err:
19+ if 'error' in debug.debug_flags:
20+ trace.note("Can't evaluate %s for keyword %s: %s",
21+ expansion, keyword, err)
22+ expansion = None
23+ except errors.NoSuchId, err:
24+ if 'error' in debug.debug_flags:
25+ trace.note("Can't evaluate %s for keyword %s: %s",
26+ expansion, keyword, err)
27+ expansion = None
28 if expansion is None:
29 # Unknown expansion - leave as is
30 result += match.group(0)

Subscribers

People subscribed via source and target branches