Skip to content

Commit 7816d6b

Browse files
committed
Trivial: import changes in refresh.py
Import some specific names directly instead of importing parent modules. Signed-off-by: Peter Grayson <[email protected]>
1 parent f88cdbc commit 7816d6b

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

stgit/commands/refresh.py

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,15 @@
88

99
from stgit import argparse, utils
1010
from stgit.argparse import opt
11-
from stgit.commands import common
11+
from stgit.commands.common import (
12+
CmdException,
13+
DirectoryHasRepositoryLib,
14+
run_commit_msg_hook,
15+
)
1216
from stgit.config import config
13-
from stgit.lib import edit, transaction
17+
from stgit.lib.edit import auto_edit_patch, interactive_edit_patch
1418
from stgit.lib.git import CommitData, IndexAndWorktree
19+
from stgit.lib.transaction import StackTransaction, TransactionHalted
1520
from stgit.out import out
1621

1722
__copyright__ = """
@@ -124,19 +129,19 @@
124129
+ argparse.author_options()
125130
)
126131

127-
directory = common.DirectoryHasRepositoryLib()
132+
directory = DirectoryHasRepositoryLib()
128133

129134

130135
def get_patch(stack, given_patch):
131136
"""Get the name of the patch we are to refresh."""
132137
if given_patch:
133138
patch_name = given_patch
134139
if not stack.patches.exists(patch_name):
135-
raise common.CmdException('%s: no such patch' % patch_name)
140+
raise CmdException('%s: no such patch' % patch_name)
136141
return patch_name
137142
else:
138143
if not stack.patchorder.applied:
139-
raise common.CmdException(
144+
raise CmdException(
140145
'Cannot refresh top patch because no patches are applied')
141146
return stack.patchorder.applied[-1]
142147

@@ -197,8 +202,7 @@ def make_temp_patch(stack, patch_name, paths, temp_index):
197202
)
198203
)
199204
temp_name = utils.make_patch_name('refresh-temp', stack.patches.exists)
200-
trans = transaction.StackTransaction(stack,
201-
'refresh (create temporary patch)')
205+
trans = StackTransaction(stack, 'refresh (create temporary patch)')
202206
trans.patches[temp_name] = commit
203207
trans.applied.append(temp_name)
204208
return (
@@ -241,7 +245,7 @@ def absorb_applied(trans, iw, patch_name, temp_name, edit_fun):
241245
# Push back any patch we were forced to pop earlier.
242246
for pn in to_pop:
243247
trans.push_patch(pn, iw)
244-
except transaction.TransactionHalted:
248+
except TransactionHalted:
245249
pass
246250
return temp_absorbed
247251

@@ -295,7 +299,7 @@ def absorb(stack, patch_name, temp_name, edit_fun, annotate=None):
295299
log_msg = 'refresh\n\n' + annotate
296300
else:
297301
log_msg = 'refresh'
298-
trans = transaction.StackTransaction(stack, log_msg)
302+
trans = StackTransaction(stack, log_msg)
299303
iw = stack.repository.default_iw
300304
if patch_name in trans.applied:
301305
absorb_func = absorb_applied
@@ -319,19 +323,19 @@ def func(parser, options, args):
319323
# Catch illegal argument combinations.
320324
path_limiting = bool(args or options.update)
321325
if options.index and path_limiting:
322-
raise common.CmdException(
326+
raise CmdException(
323327
'Only full refresh is available with the --index option')
324328

325329
if options.index and options.force:
326-
raise common.CmdException(
330+
raise CmdException(
327331
'You cannot --force a full refresh when using --index mode')
328332

329333
if options.update and options.submodules:
330-
raise common.CmdException(
334+
raise CmdException(
331335
'--submodules is meaningless when only updating modified files')
332336

333337
if options.index and options.submodules:
334-
raise common.CmdException(
338+
raise CmdException(
335339
'--submodules is meaningless when keeping the current index')
336340

337341
# If submodules was not specified on the command line, infer a default
@@ -353,14 +357,13 @@ def func(parser, options, args):
353357
# Make sure there are no conflicts in the files we want to
354358
# refresh.
355359
if stack.repository.default_index.conflicts() & paths:
356-
raise common.CmdException(
357-
'Cannot refresh -- resolve conflicts first')
360+
raise CmdException('Cannot refresh -- resolve conflicts first')
358361

359362
# Make sure the index is clean before performing a full refresh
360363
if not options.index and not options.force:
361364
if not (stack.repository.default_index.is_clean(stack.head) or
362365
stack.repository.default_iw.worktree_clean()):
363-
raise common.CmdException(
366+
raise CmdException(
364367
'The index is dirty. Did you mean --index? '
365368
'To force a full refresh use --force.'
366369
)
@@ -373,7 +376,7 @@ def func(parser, options, args):
373376

374377
def edit_fun(cd):
375378
orig_msg = cd.message
376-
cd, failed_diff = edit.auto_edit_patch(
379+
cd, failed_diff = auto_edit_patch(
377380
stack.repository, cd,
378381
msg=(None if options.message is None else
379382
options.message.encode('utf-8')),
@@ -383,7 +386,7 @@ def edit_fun(cd):
383386
sign_str=options.sign_str)
384387
assert not failed_diff
385388
if options.edit:
386-
cd, failed_diff = edit.interactive_edit_patch(
389+
cd, failed_diff = interactive_edit_patch(
387390
stack.repository,
388391
cd,
389392
edit_diff=False,
@@ -392,7 +395,7 @@ def edit_fun(cd):
392395
)
393396
assert not failed_diff
394397
if not options.no_verify and (options.edit or cd.message != orig_msg):
395-
cd = common.run_commit_msg_hook(stack.repository, cd, options.edit)
398+
cd = run_commit_msg_hook(stack.repository, cd, options.edit)
396399
return cd
397400

398401
return absorb(stack, patch_name, temp_name, edit_fun,

0 commit comments

Comments
 (0)