Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/ui.py @ 30835:bcad61a1f9a7
ui: add a parameter to set the temporary directory for edit
Until callsites are updated, this will have no effect. Once callsites
are updated, specifying experimental.editortmpinhg will create editor
temporary files in a subdirectory of .hg, which will make it easier
for tool integrations to determine what repository is in play when
they're asked to edit an hg-related file.
author | Sean Farley <sean@farley.io> |
---|---|
date | Mon, 16 Jan 2017 21:05:22 -0800 |
parents | da5fa0f13a41 |
children | 7080652af6e6 |
comparison
equal
deleted
inserted
replaced
30834:64a9160bf150 | 30835:bcad61a1f9a7 |
---|---|
1019 ''' | 1019 ''' |
1020 if self.debugflag: | 1020 if self.debugflag: |
1021 opts['label'] = opts.get('label', '') + ' ui.debug' | 1021 opts['label'] = opts.get('label', '') + ' ui.debug' |
1022 self.write(*msg, **opts) | 1022 self.write(*msg, **opts) |
1023 | 1023 |
1024 def edit(self, text, user, extra=None, editform=None, pending=None): | 1024 def edit(self, text, user, extra=None, editform=None, pending=None, |
1025 tmpdir=None): | |
1025 extra_defaults = { | 1026 extra_defaults = { |
1026 'prefix': 'editor', | 1027 'prefix': 'editor', |
1027 'suffix': '.txt', | 1028 'suffix': '.txt', |
1028 } | 1029 } |
1029 if extra is not None: | 1030 if extra is not None: |
1030 extra_defaults.update(extra) | 1031 extra_defaults.update(extra) |
1031 extra = extra_defaults | 1032 extra = extra_defaults |
1033 | |
1034 tdir = None | |
1035 if self.configbool('experimental', 'editortmpinhg'): | |
1036 tdir = tmpdir | |
1032 (fd, name) = tempfile.mkstemp(prefix='hg-' + extra['prefix'] + '-', | 1037 (fd, name) = tempfile.mkstemp(prefix='hg-' + extra['prefix'] + '-', |
1033 suffix=extra['suffix'], text=True) | 1038 suffix=extra['suffix'], text=True, |
1039 dir=tdir) | |
1034 try: | 1040 try: |
1035 f = os.fdopen(fd, "w") | 1041 f = os.fdopen(fd, "w") |
1036 f.write(text) | 1042 f.write(text) |
1037 f.close() | 1043 f.close() |
1038 | 1044 |