1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
|
# Copyright 2009-2011 Canonical Ltd. This software is licensed under the
# GNU Affero General Public License version 3 (see the file LICENSE).
"""Enumerations used in the lp/code modules."""
__metaclass__ = type
__all__ = [
'BranchLifecycleStatus',
'BranchLifecycleStatusFilter',
'BranchMergeProposalStatus',
'BranchSubscriptionDiffSize',
'BranchSubscriptionNotificationLevel',
'BranchType',
'BranchVisibilityRule',
'CodeImportEventDataType',
'CodeImportEventType',
'CodeImportJobState',
'CodeImportMachineOfflineReason',
'CodeImportMachineState',
'CodeImportResultStatus',
'CodeImportReviewStatus',
'CodeReviewNotificationLevel',
'CodeReviewVote',
'RevisionControlSystems',
'TeamBranchVisibilityRule',
'UICreatableBranchType',
]
from lazr.enum import (
DBEnumeratedType,
DBItem,
EnumeratedType,
Item,
use_template,
)
class BranchLifecycleStatus(DBEnumeratedType):
"""Branch Lifecycle Status
This indicates the status of the branch, as part of an overall
"lifecycle". The idea is to indicate to other people how mature this
branch is, or whether or not the code in the branch has been deprecated.
Essentially, this tells us what the author of the branch thinks of the
code in the branch.
"""
EXPERIMENTAL = DBItem(10, """
Experimental
Still under active development, and not suitable for merging into
release branches.
""")
DEVELOPMENT = DBItem(30, """
Development
Shaping up nicely, but incomplete or untested, and not yet ready for
merging or production use.
""")
MATURE = DBItem(50, """
Mature
Completely addresses the issues it is supposed to, tested, and stable
enough for merging into other branches.
""")
MERGED = DBItem(70, """
Merged
Successfully merged into its target branch(es). No further development
is anticipated.
""")
ABANDONED = DBItem(80, "Abandoned")
class BranchType(DBEnumeratedType):
"""Branch Type
The type of a branch determins the branch interaction with a number
of other subsystems.
"""
HOSTED = DBItem(1, """
Hosted
Launchpad is the primary location of this branch.
""")
MIRRORED = DBItem(2, """
Mirrored
Primarily hosted elsewhere and is periodically mirrored
from the external location into Launchpad.
""")
IMPORTED = DBItem(3, """
Imported
Branches that have been imported from an externally hosted
branch in bzr or another VCS and are made available through Launchpad.
""")
REMOTE = DBItem(4, """
Remote
Registered in Launchpad with an external location,
but is not to be mirrored, nor available through Launchpad.
""")
class UICreatableBranchType(EnumeratedType):
"""The types of branches that can be created through the web UI."""
use_template(BranchType, exclude='IMPORTED')
class BranchLifecycleStatusFilter(EnumeratedType):
"""Branch Lifecycle Status Filter
Used to populate the branch lifecycle status filter widget.
UI only.
"""
use_template(BranchLifecycleStatus)
sort_order = (
'CURRENT', 'ALL', 'EXPERIMENTAL', 'DEVELOPMENT', 'MATURE',
'MERGED', 'ABANDONED')
CURRENT = Item("""
Any active status
Show the currently active branches.
""")
ALL = Item("""
Any status
Show all the branches.
""")
class BranchMergeProposalStatus(DBEnumeratedType):
"""Branch Merge Proposal Status
The current state of a proposal to merge.
"""
WORK_IN_PROGRESS = DBItem(1, """
Work in progress
The source branch is actively being worked on.
""")
NEEDS_REVIEW = DBItem(2, """
Needs review
A review of the changes has been requested.
""")
CODE_APPROVED = DBItem(3, """
Approved
The changes have been approved for merging.
""")
REJECTED = DBItem(4, """
Rejected
The changes have been rejected and will not be merged in their
current state.
""")
MERGED = DBItem(5, """
Merged
The changes from the source branch were merged into the target
branch.
""")
MERGE_FAILED = DBItem(6, """
Code failed to merge
The changes from the source branch failed to merge into the
target branch for some reason.
""")
QUEUED = DBItem(7, """
Queued
The changes from the source branch are queued to be merged into the
target branch.
""")
SUPERSEDED = DBItem(10, """
Superseded
This proposal has been superseded by anther proposal to merge.
""")
class BranchSubscriptionDiffSize(DBEnumeratedType):
"""Branch Subscription Diff Size
When getting branch revision notifications, the person can set a size
limit of the diff to send out. If the generated diff is greater than
the specified number of lines, then it is omitted from the email.
This enumerated type defines the number of lines as a choice
so we can sensibly limit the user to a number of size choices.
"""
NODIFF = DBItem(0, """
Don't send diffs
Don't send generated diffs with the revision notifications.
""")
HALFKLINES = DBItem(500, """
500 lines
Limit the generated diff to 500 lines.
""")
ONEKLINES = DBItem(1000, """
1000 lines
Limit the generated diff to 1000 lines.
""")
FIVEKLINES = DBItem(5000, """
5000 lines
Limit the generated diff to 5000 lines.
""")
WHOLEDIFF = DBItem(-1, """
Send entire diff
Don't limit the size of the diff.
""")
class BranchSubscriptionNotificationLevel(DBEnumeratedType):
"""Branch Subscription Notification Level
The notification level is used to control the amount and content
of the email notifications send with respect to modifications
to branches whether it be to branch attributes in the UI, or
to the contents of the branch found by the branch scanner.
"""
NOEMAIL = DBItem(0, """
No email
Do not send any email about changes to this branch.
""")
ATTRIBUTEONLY = DBItem(1, """
Branch attribute notifications only
Only send notifications for branch attribute changes such
as name, description and whiteboard.
""")
DIFFSONLY = DBItem(2, """
Branch revision notifications only
Only send notifications about new revisions added to this
branch.
""")
FULL = DBItem(3, """
Branch attribute and revision notifications
Send notifications for both branch attribute updates
and new revisions added to the branch.
""")
class CodeReviewNotificationLevel(DBEnumeratedType):
"""Code Review Notification Level
The notification level is used to control the amount and content
of the email notifications send with respect to code reviews related
to this branch.
"""
NOEMAIL = DBItem(0, """
No email
Do not send any email about code review for this branch.
""")
STATUS = DBItem(1, """
Status changes only
Send email when votes are cast or status is changed.
""")
FULL = DBItem(2, """
Email about all changes
Send email about any code review activity for this branch.
""")
class BranchVisibilityRule(DBEnumeratedType):
"""Branch Visibility Rules for defining branch visibility policy."""
PUBLIC = DBItem(1, """
Public
Branches are public by default.
""")
PRIVATE = DBItem(2, """
Private
Branches are private by default.
""")
PRIVATE_ONLY = DBItem(3, """
Private only
Branches are private by default. Branch owners are not able
to change the visibility of the branches to public.
""")
FORBIDDEN = DBItem(4, """
Forbidden
Users are not able to create branches in the context.
""")
class TeamBranchVisibilityRule(EnumeratedType):
"""The valid policy rules for teams."""
use_template(BranchVisibilityRule, exclude='FORBIDDEN')
class RevisionControlSystems(DBEnumeratedType):
"""Revision Control Systems
Bazaar brings code from a variety of upstream revision control
systems into bzr. This schema documents the known and supported
revision control systems.
"""
CVS = DBItem(1, """
Concurrent Versions System
Imports from CVS via CSCVS.
""")
SVN = DBItem(2, """
Subversion via CSCVS
Imports from SVN using CSCVS.
""")
BZR_SVN = DBItem(3, """
Subversion via bzr-svn
Imports from SVN using bzr-svn.
""")
GIT = DBItem(4, """
Git
Imports from Git using bzr-git.
""")
HG = DBItem(5, """
Mercurial
Imports from Mercurial using bzr-hg.
""")
BZR = DBItem(6, """
Bazaar
Mirror of a Bazaar branch.
""")
class CodeImportReviewStatus(DBEnumeratedType):
"""CodeImport review status.
Before a code import is performed, it is reviewed. Only reviewed imports
are processed.
"""
NEW = DBItem(1, """Pending Review
This code import request has recently been filed and has not
been reviewed yet.
""")
INVALID = DBItem(10, """Invalid
This code import will not be processed.
""")
REVIEWED = DBItem(20, """Reviewed
This code import has been approved and will be processed.
""")
SUSPENDED = DBItem(30, """Suspended
This code import has been approved, but it has been suspended
and is not processed.""")
FAILING = DBItem(40, """Failed
The code import is failing for some reason and is no longer being
attempted.""")
class CodeImportEventType(DBEnumeratedType):
"""CodeImportEvent type.
Event types identify all the events that are significant to the code
import system. Either user-driven events, or events recording the
operation of unattended systems.
"""
# Event types are named so that "a FOO event" sounds natural. For example,
# MODIFY because "a MODIFIED event" sounds confusing and "a MODIFICATION
# event" is awkward.
# Code import life cycle.
CREATE = DBItem(110, """
Import Created
A CodeImport object was created.
""")
MODIFY = DBItem(120, """
Import Modified
A code import was modified. Either the CodeImport object, or an
associated object, was modified.
""")
DELETE = DBItem(130, """
Import Deleted
A CodeImport object was deleted.
""")
# Code import job events.
START = DBItem(210, """
Job Started
An import job was started.
""")
FINISH = DBItem(220, """
Job Finished
An import job finished, either successfully or by a failure.
""")
PUBLISH = DBItem(230, """
Import First Published
A code import has completed for the first time and was published.
""")
RECLAIM = DBItem(240, """
Job Reclaimed Automatically
A code import job has not finished, but has probably crashed and is
allowed to run again.
""")
# Code import job control events.
REQUEST = DBItem(310, """
Update Requested
A user requested that an import job be run immediately.
""")
KILL = DBItem(320, """
Termination Requested
A user requested that a running import job be aborted.
""")
# Code import machine events.
ONLINE = DBItem(410, """
Machine Online
A code-import-controller daemon has started, and is now accepting
jobs.
""")
OFFLINE = DBItem(420, """
Machine Offline
A code-import-controller daemon has finished, or crashed is and no
longer running.
""")
QUIESCE = DBItem(430, """
Quiescing Requested
A code-import-controller daemon has been requested to shut down. It
will no longer accept jobs, and will terminate once the last running
job finishes.
""")
class CodeImportEventDataType(DBEnumeratedType):
"""CodeImportEventData type.
CodeImportEvent objects record unstructured additional data. Each data
item associated to an event has a type from this enumeration.
"""
# Generic data
MESSAGE = DBItem(10, """Message
User-provided message.
""")
# CodeImport attributes
CODE_IMPORT = DBItem(110, """
Code Import
Database id of the CodeImport, useful to collate events associated to
deleted CodeImport objects.
""")
OWNER = DBItem(120, """
Code Import Owner
Value of CodeImport.owner. Useful to record ownership changes.
""")
OLD_OWNER = DBItem(121, """
Previous Owner
Previous value of CodeImport.owner, when recording an ownership
change.
""")
REVIEW_STATUS = DBItem(130, """
Review Status
Value of CodeImport.review_status. Useful to understand the review
life cycle of a code import.
""")
OLD_REVIEW_STATUS = DBItem(131, """
Previous Review Status
Previous value of CodeImport.review_status, when recording a status
change.
""")
ASSIGNEE = DBItem(140, """
Code Import Assignee
Value of CodeImport.assignee. Useful to understand the review life
cycle of a code import.
""")
OLD_ASSIGNEE = DBItem(141, """
Previous Assignee
Previous value of CodeImport.assignee, when recording an assignee
change.
""")
# CodeImport attributes related to the import source
UPDATE_INTERVAL = DBItem(210, """
Update Interval
User-specified interval between updates of the code import.
""")
OLD_UPDATE_INTERVAL = DBItem(211, """
Previous Update Interval
Previous user-specified update interval, when recording an interval
change.
""")
CVS_ROOT = DBItem(220, """
CVSROOT
Location and access method of the CVS repository.
""")
CVS_MODULE = DBItem(221, """
CVS module
Path to import within the CVSROOT.
""")
OLD_CVS_ROOT = DBItem(222, """
Previous CVSROOT
Previous CVSROOT, when recording an import source change.
""")
OLD_CVS_MODULE = DBItem(223, """
Previous CVS module
Previous CVS module, when recording an import source change.
""")
SVN_BRANCH_URL = DBItem(230, """
Subversion URL
Location of the Subversion branch to import.
""")
OLD_SVN_BRANCH_URL = DBItem(231, """
Previous Subversion URL
Previous Subversion URL, when recording an import source change.
""")
GIT_REPO_URL = DBItem(237, """
Git repo URL
Location of the Git repo to import.
""")
OLD_GIT_REPO_URL = DBItem(238, """
Previous Git repo URL
Previous Git repo URL, when recording on import source change.
""")
URL = DBItem(240, """
Foreign VCS branch URL
Location of the foreign VCS branch to import.
""")
OLD_URL = DBItem(241, """
Previous foreign VCS branch URL
Previous foreign VCS branch location, when recording an import source
change.
""")
# Data related to machine events
OFFLINE_REASON = DBItem(410, """Offline Reason
Reason why a code import machine went offline.
""")
# Data related to reclaim events
RECLAIMED_JOB_ID = DBItem(510, """Reclaimed Job Id
The database id of the reclaimed code import job.
""")
class CodeImportJobState(DBEnumeratedType):
"""Values that ICodeImportJob.state can take."""
PENDING = DBItem(10, """
Pending
The job has a time when it is due to run, and will wait until
that time or an explicit update request is made.
""")
SCHEDULED = DBItem(20, """
Scheduled
The job is due to be run.
""")
RUNNING = DBItem(30, """
Running
The job is running.
""")
class CodeImportMachineState(DBEnumeratedType):
"""CodeImportMachine State
The operational state of the code-import-controller daemon on a given
machine.
"""
OFFLINE = DBItem(10, """
Offline
The code-import-controller daemon is not running on this machine.
""")
ONLINE = DBItem(20, """
Online
The code-import-controller daemon is running on this machine and
accepting new jobs.
""")
QUIESCING = DBItem(30, """
Quiescing
The code-import-controller daemon is running on this machine, but has
been requested to shut down and will not accept any new job.
""")
class CodeImportMachineOfflineReason(DBEnumeratedType):
"""Reason why a CodeImportMachine is offline.
A machine goes offline when a code-import-controller daemon process shuts
down, or appears to have crashed. Recording the reason a machine went
offline provides useful diagnostic information.
"""
# Daemon termination
STOPPED = DBItem(110, """
Stopped
The code-import-controller daemon was shut-down, interrupting running
jobs.
""")
QUIESCED = DBItem(120, """
Quiesced
The code-import-controller daemon has shut down after completing
any running jobs.
""")
# Crash recovery
WATCHDOG = DBItem(210, """
Watchdog
The watchdog has detected that the machine's heartbeat has not been
updated recently.
""")
class CodeImportResultStatus(DBEnumeratedType):
"""Values for ICodeImportResult.status.
How did a code import job complete? Was it successful, did it fail
when trying to checkout or update the source tree, in the
conversion step, or in one of the internal house-keeping steps?
"""
SUCCESS = DBItem(100, """
Success
Import job completed successfully.
""")
SUCCESS_NOCHANGE = DBItem(110, """
Success with no changes
Import job completed successfully, but there were no new revisions to
import.
""")
SUCCESS_PARTIAL = DBItem(120, """
Partial Success
Import job successfully imported some but not all of the foreign
revisions.
""")
FAILURE = DBItem(200, """
Failure
Import job failed.
""")
INTERNAL_FAILURE = DBItem(210, """
Internal Failure
An internal error occurred. This is a problem with Launchpad.
""")
FAILURE_INVALID = DBItem(220, """
Foreign branch invalid
The import failed because the foreign branch did not exist or
was not accessible.
""")
FAILURE_UNSUPPORTED_FEATURE = DBItem(230, """
Unsupported feature
The import failed because of missing feature support in
Bazaar or the Bazaar foreign branch support.
""")
FAILURE_FORBIDDEN = DBItem(240, """
Forbidden URL
The import failed because the URL of the branch that is imported
or the URL of one of the branches that it references is blacklisted.
""")
FAILURE_REMOTE_BROKEN = DBItem(250, """
Broken remote branch
The remote branch exists but is corrupted in some way
""")
RECLAIMED = DBItem(310, """
Job reclaimed
The job apparently crashed and was automatically marked as
complete to allow further jobs to run for this code import.
""")
KILLED = DBItem(320, """
Job killed
A user action caused this job to be killed before it
completed. It could have been an explicit request to kill the
job, or the deletion of a CodeImport which had a running job.
""")
successes = [SUCCESS, SUCCESS_NOCHANGE, SUCCESS_PARTIAL]
class CodeReviewVote(DBEnumeratedType):
"""Code Review Votes
Responses from the reviews to the code author.
"""
sort_order = ('APPROVE',
'NEEDS_FIXING',
'NEEDS_INFO',
'ABSTAIN',
'DISAPPROVE',
'RESUBMIT',
)
DISAPPROVE = DBItem(1, """
Disapprove
Reviewer does not want the proposed merge to happen.
""")
ABSTAIN = DBItem(2, """
Abstain
Reviewer cannot or does not want to decide whether the proposed merge
should happen.
""")
APPROVE = DBItem(3, """
Approve
Reviewer wants the proposed merge to happen.
""")
RESUBMIT = DBItem(4, """
Resubmit
Reviewer thinks that the idea might be sound but the implementation
needs significant rework.
""")
NEEDS_FIXING = DBItem(5, """
Needs Fixing
Reviewer thinks that some fixing is needed before they can approve it.
""")
NEEDS_INFO = DBItem(6, """
Needs Information
The reviewer needs more information before making a decision.
""")
|