diff options
author | W. Trevor King <wking@drexel.edu> | 2009-12-15 06:44:20 -0500 |
---|---|---|
committer | W. Trevor King <wking@drexel.edu> | 2009-12-15 06:44:20 -0500 |
commit | 89b7a1411e4658e831f5d635534b24355dbb941d (patch) | |
tree | 77f84979931ac4bf8bcf14d293154fe29e8491bc /libbe/command/diff.py | |
parent | 380889988b6d7881c4e0b5968053f85676d27211 (diff) | |
download | bugseverywhere-89b7a1411e4658e831f5d635534b24355dbb941d.tar.gz |
Fixed libbe.command.diff + ugly BugDir.duplicate_bugdir implementation
duplicate_bugdir() works, but for the vcs backends, it could require
shelling out for _every_ file read. This could, and probably will, be
horribly slow. Still it works ;).
I'm not sure what a better implementation would be. The old
implementation checked out the entire earlier state into a temporary
directory
pros: single shell out, simple upgrade implementation
cons: wouldn't work well for HTTP backens
I think a good solution would run along the lines of the currently
commented out code in duplicate_bugdir(), where a
VersionedStorage.changed_since(revision)
call would give you a list of changed files. diff could work off of
that directly, without the need to generate a whole duplicate bugdir.
I'm stuck on how to handle upgrades though...
Also removed trailing whitespace from all python files.
Diffstat (limited to 'libbe/command/diff.py')
-rw-r--r-- | libbe/command/diff.py | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/libbe/command/diff.py b/libbe/command/diff.py index c8b5777..d945f96 100644 --- a/libbe/command/diff.py +++ b/libbe/command/diff.py @@ -29,7 +29,7 @@ class Diff (libbe.command.Command): >>> import sys >>> import libbe.bugdir - >>> bd = libbe.bugdir.SimpleBugDir(memory=False) + >>> bd = libbe.bugdir.SimpleBugDir(memory=False, versioned=True) >>> cmd = Diff() >>> cmd._storage = bd.storage >>> cmd._setup_io = lambda i_enc,o_enc : None @@ -39,23 +39,15 @@ class Diff (libbe.command.Command): >>> bug = bd.bug_from_uuid('a') >>> bug.status = 'closed' >>> changed = bd.storage.commit('Closed bug a') - >>> if bd.storage.versioned == True: - ... ret = cmd.run(args=[original]) - ... else: - ... print 'Modified bugs:\\n a:cm: Bug A\\n Changed bug settings:\\n status: open -> closed' + >>> ret = cmd.run(args=[original]) Modified bugs: - a:cm: Bug A + abc/a:cm: Bug A Changed bug settings: status: open -> closed - >>> if bd.storage.versioned == True: - ... ret = cmd.run({'subscribe':'%(bugdir_id)s:mod', 'uuids':True}, [original]) - ... else: - ... print 'a' + >>> ret = cmd.run({'subscribe':'%(bugdir_id)s:mod', 'uuids':True}, [original]) a - >>> if bd.storage.versioned == False: - ... ret = cmd.run(args=[original]) - ... else: - ... raise libbe.command.UserError('This repository not revision-controlled.') + >>> bd.storage.versioned = False + >>> ret = cmd.run(args=[original]) Traceback (most recent call last): ... UserError: This repository is not revision-controlled. @@ -101,7 +93,7 @@ class Diff (libbe.command.Command): if params['repo'] == None: if params['revision'] == None: # get the most recent revision params['revision'] = bugdir.storage.revision_id(-1) - old_bd = bugdir.duplicate_bugdir(params['revision']) # TODO + old_bd = bugdir.duplicate_bugdir(params['revision']) else: old_storage = libbe.storage.get_storage(params['repo']) old_storage.connect() @@ -113,8 +105,8 @@ class Diff (libbe.command.Command): raise libbe.command.UserError( '%s is not revision-controlled.' % storage.repo) - old_bd = old_bd_current.duplicate_bugdir(revision) # TODO - d = libbe.diff.Diff(old_bd, bugir) + old_bd = old_bd_current.duplicate_bugdir(revision) + d = libbe.diff.Diff(old_bd, bugdir) tree = d.report_tree(subscriptions) if params['uuids'] == True: |