60 changectx: read-only context that is already present in the repo, |
60 changectx: read-only context that is already present in the repo, |
61 workingctx: a context that represents the working directory and can |
61 workingctx: a context that represents the working directory and can |
62 be committed, |
62 be committed, |
63 memctx: a context that represents changes in-memory and can also |
63 memctx: a context that represents changes in-memory and can also |
64 be committed.""" |
64 be committed.""" |
65 def __new__(cls, repo, changeid='', *args, **kwargs): |
|
66 if isinstance(changeid, basectx): |
|
67 return changeid |
|
68 |
|
69 return super(basectx, cls).__new__(cls) |
|
70 |
65 |
71 def __bytes__(self): |
66 def __bytes__(self): |
72 return short(self.node()) |
67 return short(self.node()) |
73 |
68 |
74 __str__ = encoding.strmethod(__bytes__) |
69 __str__ = encoding.strmethod(__bytes__) |
409 """A changecontext object makes access to data related to a particular |
404 """A changecontext object makes access to data related to a particular |
410 changeset convenient. It represents a read-only context already present in |
405 changeset convenient. It represents a read-only context already present in |
411 the repo.""" |
406 the repo.""" |
412 def __init__(self, repo, changeid='.'): |
407 def __init__(self, repo, changeid='.'): |
413 """changeid is a revision number, node, or tag""" |
408 """changeid is a revision number, node, or tag""" |
414 |
|
415 # since basectx.__new__ already took care of copying the object, we |
|
416 # don't need to do anything in __init__, so we just exit here |
|
417 if isinstance(changeid, basectx): |
|
418 return |
|
419 |
409 |
420 if changeid == '': |
410 if changeid == '': |
421 changeid = '.' |
411 changeid = '.' |
422 self._repo = repo |
412 self._repo = repo |
423 |
413 |
2484 user receives the committer name and defaults to current repository |
2474 user receives the committer name and defaults to current repository |
2485 username, date is the commit date in any format supported by |
2475 username, date is the commit date in any format supported by |
2486 dateutil.parsedate() and defaults to current date, extra is a dictionary of |
2476 dateutil.parsedate() and defaults to current date, extra is a dictionary of |
2487 metadata or is left empty. |
2477 metadata or is left empty. |
2488 """ |
2478 """ |
2489 def __new__(cls, repo, originalctx, *args, **kwargs): |
|
2490 return super(metadataonlyctx, cls).__new__(cls, repo) |
|
2491 |
|
2492 def __init__(self, repo, originalctx, parents=None, text=None, user=None, |
2479 def __init__(self, repo, originalctx, parents=None, text=None, user=None, |
2493 date=None, extra=None, editor=False): |
2480 date=None, extra=None, editor=False): |
2494 if text is None: |
2481 if text is None: |
2495 text = originalctx.description() |
2482 text = originalctx.description() |
2496 super(metadataonlyctx, self).__init__(repo, text, user, date, extra) |
2483 super(metadataonlyctx, self).__init__(repo, text, user, date, extra) |