1100 |
1100 |
1101 class committablectx(basectx): |
1101 class committablectx(basectx): |
1102 """A committablectx object provides common functionality for a context that |
1102 """A committablectx object provides common functionality for a context that |
1103 wants the ability to commit, e.g. workingctx or memctx.""" |
1103 wants the ability to commit, e.g. workingctx or memctx.""" |
1104 def __init__(self, repo, text="", user=None, date=None, extra=None, |
1104 def __init__(self, repo, text="", user=None, date=None, extra=None, |
1105 changes=None): |
1105 changes=None, branch=None): |
1106 super(committablectx, self).__init__(repo) |
1106 super(committablectx, self).__init__(repo) |
1107 self._rev = None |
1107 self._rev = None |
1108 self._node = None |
1108 self._node = None |
1109 self._text = text |
1109 self._text = text |
1110 if date: |
1110 if date: |
1115 self._status = changes |
1115 self._status = changes |
1116 |
1116 |
1117 self._extra = {} |
1117 self._extra = {} |
1118 if extra: |
1118 if extra: |
1119 self._extra = extra.copy() |
1119 self._extra = extra.copy() |
1120 if 'branch' not in self._extra: |
1120 if branch is not None: |
|
1121 self._extra['branch'] = encoding.fromlocal(branch) |
|
1122 elif 'branch' not in self._extra: |
1121 try: |
1123 try: |
1122 branch = encoding.fromlocal(self._repo.dirstate.branch()) |
1124 branch = encoding.fromlocal(self._repo.dirstate.branch()) |
1123 except UnicodeDecodeError: |
1125 except UnicodeDecodeError: |
1124 raise error.Abort(_('branch name not in UTF-8!')) |
1126 raise error.Abort(_('branch name not in UTF-8!')) |
1125 self._extra['branch'] = branch |
1127 self._extra['branch'] = branch |
2306 # this field to determine what to do in filectxfn. |
2308 # this field to determine what to do in filectxfn. |
2307 _returnnoneformissingfiles = True |
2309 _returnnoneformissingfiles = True |
2308 |
2310 |
2309 def __init__(self, repo, parents, text, files, filectxfn, user=None, |
2311 def __init__(self, repo, parents, text, files, filectxfn, user=None, |
2310 date=None, extra=None, branch=None, editor=False): |
2312 date=None, extra=None, branch=None, editor=False): |
2311 super(memctx, self).__init__(repo, text, user, date, extra) |
2313 super(memctx, self).__init__(repo, text, user, date, extra, |
|
2314 branch=branch) |
2312 self._rev = None |
2315 self._rev = None |
2313 self._node = None |
2316 self._node = None |
2314 parents = [(p or nullid) for p in parents] |
2317 parents = [(p or nullid) for p in parents] |
2315 p1, p2 = parents |
2318 p1, p2 = parents |
2316 self._parents = [self._repo[p] for p in (p1, p2)] |
2319 self._parents = [self._repo[p] for p in (p1, p2)] |
2317 files = sorted(set(files)) |
2320 files = sorted(set(files)) |
2318 self._files = files |
2321 self._files = files |
2319 if branch is not None: |
|
2320 self._extra['branch'] = encoding.fromlocal(branch) |
|
2321 self.substate = {} |
2322 self.substate = {} |
2322 |
2323 |
2323 if isinstance(filectxfn, patch.filestore): |
2324 if isinstance(filectxfn, patch.filestore): |
2324 filectxfn = memfilefrompatch(filectxfn) |
2325 filectxfn = memfilefrompatch(filectxfn) |
2325 elif not callable(filectxfn): |
2326 elif not callable(filectxfn): |