~stefan-opener/+junk/replaybot

« back to all changes in this revision

Viewing changes to replaybot.py

  • Committer: Stefan Rijnhart
  • Date: 2013-01-31 22:37:58 UTC
  • Revision ID: stefan@therp.nl-20130131223758-rfggyxkc5dm99i75
[IMP] Replace hardcoded test parameters
[IMP] Allow for lp: urls

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
wt_directory = 'addons-6.1'
2
 
upstream_location = 'https://code.launchpad.net/~openerp/openobject-addons/6.1'
3
1
 
4
2
import sys
5
3
from os.path import isdir
13
11
    WorkingTreeRevisionRewriter,
14
12
    )
15
13
 
 
14
from bzrlib.plugins.launchpad.lp_directory import LaunchpadDirectory
 
15
 
 
16
if len(sys.argv[1:]) < 2:
 
17
    sys.exit('Usage: %s "local branch or checkout" "upstream branch 1" '
 
18
             '[upstream_branch 2] ...' % sys.argv[0])
 
19
 
 
20
wt_directory = sys.argv[1]
 
21
 
16
22
if not isdir(wt_directory):
17
 
    sys.stderr.write("%s is not a directory\n" % wt_directory)
18
 
    exit(1)
 
23
    sys.exit("%s is not a directory\n" % wt_directory)
19
24
 
20
 
wt = WorkingTree.open_containing(wt_directory)[0]
21
 
wt.lock_write()
22
 
try:
 
25
def replay_missing(wt, upstream_location):
23
26
    # Set up branches
24
27
    upstream = Branch.open_containing(upstream_location)[0]
25
28
    upstream_repository = upstream.repository
29
32
 
30
33
    # Get missing revisions in both branches
31
34
    repo_graph = wt.branch.repository.get_graph()
 
35
    print "Searching for missing revisions on %s" % upstream_location
32
36
    our_new, todo_set = repo_graph.find_difference(wt_revision, upstream_revision)
33
37
    parent_map = repo_graph.get_parent_map(todo_set)
34
38
    ordered_set = topo_sort(parent_map)
61
65
        newrevid = regenerate_default_revid(wt.branch.repository, revid)
62
66
        replayer(revid, newrevid, [wt.last_revision()])
63
67
 
 
68
directory = LaunchpadDirectory()
 
69
wt = WorkingTree.open_containing(wt_directory)[0]
 
70
wt.lock_write()
 
71
 
 
72
try:
 
73
    if wt.branch.get_master_branch():
 
74
        wt.branch.update()
 
75
 
 
76
    for upstream_location in sys.argv[2:]:
 
77
        if upstream_location.startswith('lp:'):
 
78
            upstream_location = directory.look_up(None, upstream_location)
 
79
    replay_missing(wt, upstream_location)
64
80
finally:
65
81
    wt.unlock()
 
82