#
# old_revision [65cc6f5a3ee53454c0232be02a6d63ba5c973fdb]
#
# patch "tracmtn/backend.py"
# from [d1ea39556f9842df75cb1502b4f227297ae35679]
# to [3509a4ab43f67c6d8077f29e4cd86be8f25de7ea]
#
============================================================
|
|
|
|
| 133 | 133 | dir. |
| 134 | 134 | """ |
| 135 | 135 | self.lock.acquire() |
| | 136 | |
| | 137 | tok = path.split(':', 1) |
| | 138 | if len(tok) == 2: |
| | 139 | sel = tok[1] |
| | 140 | path = tok[0] |
| | 141 | else: |
| | 142 | sel = None |
| | 143 | |
| 136 | 144 | try: |
| 137 | 145 | # note: we don't use type or authname, therefore we can always |
| 138 | 146 | # return the same Repository object for the same database path |
| … |
… |
|
| 141 | 149 | except KeyError: |
| 142 | 150 | mtn = MTN(path, self.log, self.mtn_binary) |
| 143 | 151 | self.mtn_procs[path] = mtn |
| | 152 | |
| 144 | 153 | repos = MonotoneRepository( |
| 145 | | mtn, path, self.log, self.cachespec, self.get_revprops()) |
| | 154 | mtn, path, sel, self.log, self.cachespec, |
| | 155 | self.get_revprops()) |
| 146 | 156 | |
| 147 | 157 | # this is the main entry point for users of this plugin, so let's set |
| 148 | 158 | # version information here |
| … |
… |
|
| 210 | 220 | |
| 211 | 221 | def match_property(self, name, mode): |
| 212 | 222 | if mode == 'revprop' and name in ('Parents', 'Children', |
| 213 | | 'Branches', 'Tags'): |
| | 223 | 'Branches', 'Tags', 'Repository'): |
| 214 | 224 | return 4 |
| 215 | 225 | return 0 |
| 216 | 226 | |
| 217 | 227 | def render_property(self, name, mode, context, props): |
| 218 | 228 | fragments = [] |
| 219 | | repos = self.env.get_repository() |
| | 229 | repos = props['Repository'][0] |
| | 230 | if name == 'Repository': |
| | 231 | return |
| 220 | 232 | for val in props[name]: |
| 221 | 233 | if name in ('Branches', 'Tags'): |
| 222 | 234 | # don't create links here |
| 223 | 235 | fragments.append(tag(val)) |
| 224 | 236 | else: |
| 225 | 237 | changeset = repos.get_changeset(val) |
| 226 | | fragments.append(tag.a(val, class_="changeset", |
| 227 | | title=shorten_line(changeset.message), |
| 228 | | href=context.href.changeset(val))) |
| | 238 | if repos.reponame: |
| | 239 | fragments.append(tag.a(val, class_="changeset", |
| | 240 | title=shorten_line(changeset.message), |
| | 241 | href=context.href.changeset(val + '/' + repos.reponame))) |
| | 242 | else: |
| | 243 | fragments.append(tag.a(val, class_="changeset", |
| | 244 | title=shorten_line(changeset.message), |
| | 245 | href=context.href.changeset(val))) |
| 229 | 246 | return tag([tag(f, ', ') for f in fragments[:-1]], fragments[-1]) |
| 230 | 247 | |
| 231 | 248 | |
| … |
… |
|
| 307 | 324 | Represents a Monotone repository. |
| 308 | 325 | """ |
| 309 | 326 | |
| 310 | | def __init__(self, mtn, path, log, cachespec, revpropspec = None): |
| | 327 | def __init__(self, mtn, path, sel, log, cachespec, revpropspec = None): |
| 311 | 328 | Repository.__init__(self, 'mtn:%s' % path, None, log) |
| 312 | 329 | self.mtn = CachedMTN(mtn, cachespec) |
| | 330 | self.selector = sel |
| | 331 | self.path = path |
| | 332 | self.reponame = None |
| 313 | 333 | self.revpropspec = revpropspec or {} |
| 314 | 334 | |
| 315 | 335 | def close(self): |
| … |
… |
|
| 329 | 349 | Like get_changeset, but skips the revision normalization. |
| 330 | 350 | """ |
| 331 | 351 | try: |
| 332 | | return MonotoneChangeset(self.mtn, rev, self.revpropspec) |
| | 352 | return MonotoneChangeset(self, self.mtn, rev, self.revpropspec) |
| 333 | 353 | except AutomateException: |
| 334 | 354 | raise NoSuchChangeset(rev) |
| 335 | 355 | |
| … |
… |
|
| 337 | 357 | """ |
| 338 | 358 | Generate Changesets belonging to the given time period (start, stop). |
| 339 | 359 | """ |
| 340 | | for rev in self.mtn.select('l:%s/e:%s' % |
| 341 | | (format_datetime(start), format_datetime(stop))): |
| | 360 | selector = ('l:%s/e:%s' % |
| | 361 | (format_datetime(start), format_datetime(stop))) |
| | 362 | if self.selector != None: |
| | 363 | selector += '/' + self.selector |
| | 364 | for rev in self.mtn.select(selector): |
| 342 | 365 | yield self._get_changeset(rev) |
| 343 | 366 | |
| 344 | 367 | def get_node(self, path, rev=None): |
| … |
… |
|
| 356 | 379 | rev = self.normalize_rev(rev) |
| 357 | 380 | path = self.normalize_path(path) |
| 358 | 381 | try: |
| 359 | | return MonotoneNode(self.mtn, rev, path) |
| | 382 | return MonotoneNode(self, self.mtn, rev, path) |
| 360 | 383 | except AutomateException: |
| 361 | 384 | raise NoSuchChangeset(rev) |
| 362 | 385 | |
| … |
… |
|
| 498 | 521 | `rev` might be needed in order to retrieve the branches, but |
| 499 | 522 | in general it's best to produce all known branches. |
| 500 | 523 | """ |
| 501 | | return self.mtn.non_merged_branches() |
| | 524 | return self.mtn.branches() |
| 502 | 525 | |
| 503 | 526 | def get_quickjump_entries(self, from_rev): |
| 504 | 527 | """ |
| … |
… |
|
| 540 | 563 | revision. |
| 541 | 564 | """ |
| 542 | 565 | |
| 543 | | def __init__(self, mtn, rev, path, manifest = None): |
| | 566 | def __init__(self, repos, mtn, rev, path, manifest = None): |
| | 567 | self.repos = repos |
| | 568 | self.selector = repos.selector |
| 544 | 569 | self.mtn = mtn |
| 545 | 570 | self.manifest = manifest or self.mtn.manifest(rev) |
| 546 | 571 | |
| … |
… |
|
| 593 | 618 | return get_parent(path) == self.path |
| 594 | 619 | |
| 595 | 620 | for path in filter(ischild, self.manifest.keys()): # IGNORE:W0141 |
| 596 | | yield MonotoneNode(self.mtn, self.rev, path, self.manifest) |
| | 621 | yield MonotoneNode(self.repos, self.mtn, self.rev, path, self.manifest) |
| 597 | 622 | |
| 598 | 623 | def get_history(self, limit=None): |
| 599 | 624 | """ |
| … |
… |
|
| 604 | 629 | first element of the tuple (i.e. the path) changing. Starts |
| 605 | 630 | with an entry for the current revision. |
| 606 | 631 | """ |
| 607 | | # FIXME: this is only a stub |
| 608 | | yield (self.path, self.rev, None) |
| | 632 | # Use selector, if exists, otherwise just return all revisions for |
| | 633 | # the (entire?!) repository. |
| 609 | 634 | |
| | 635 | if self.selector == None: |
| | 636 | revs = self.mtn.all_revs() |
| | 637 | topo = reversed(self.mtn.toposort(revs)) |
| | 638 | for i in topo: |
| | 639 | yield (self.path, i, None) |
| | 640 | else: |
| | 641 | revs = self.mtn.select(self.selector) |
| | 642 | topo = reversed(self.mtn.toposort(revs)) |
| | 643 | for i in topo: |
| | 644 | yield (self.path, i, None) |
| | 645 | |
| 610 | 646 | def get_properties(self): |
| 611 | 647 | """ |
| 612 | 648 | Returns a dictionary containing the properties (meta-data) of |
| … |
… |
|
| 635 | 671 | Represents the set of changes in one revision. |
| 636 | 672 | """ |
| 637 | 673 | # changesets are retrieved via MonotoneRepository.get_changeset() |
| 638 | | def __init__(self, mtn, rev, revpropspec = None): |
| | 674 | def __init__(self, repos, mtn, rev, revpropspec = None): |
| | 675 | self.repos = repos |
| 639 | 676 | self.certs = mtn.certs(rev) |
| 640 | 677 | self.messages = self.certs.get('changelog', ['-']) |
| 641 | 678 | self.authors = self.certs.get('author', ['-']) |
| … |
… |
|
| 707 | 744 | if self.tags: |
| 708 | 745 | properties['Tags'] = self.tags |
| 709 | 746 | # FIXME: add user-defined revision properties |
| | 747 | properties['Repository'] = (self.repos, self.rev) |
| 710 | 748 | return properties |
| 711 | 749 | |
| 712 | 750 | else: # legacy |