Mercurial > public > mercurial-scm > hg-stable
comparison mercurial/cmdutil.py @ 25310:c1f5ef76d1c2
record: add an operation arguments to customize recording ui
This patch is part of a series of patches to change the recording ui to reflect
the operation currently running (commit, shelve, revert ...).
This patch adds a new argument to the recording function to reflect in the UI
what operation we are running.
author | Laurent Charignon <lcharignon@fb.com> |
---|---|
date | Wed, 27 May 2015 15:49:24 -0700 |
parents | 8e0e334bad42 |
children | 31f3636e9296 |
comparison
equal
deleted
inserted
replaced
25309:b333ca94403d | 25310:c1f5ef76d1c2 |
---|---|
43 def wrap(*args, **kwargs): | 43 def wrap(*args, **kwargs): |
44 return wrapwrite(oldwrite, *args, **kwargs) | 44 return wrapwrite(oldwrite, *args, **kwargs) |
45 setattr(ui, 'write', wrap) | 45 setattr(ui, 'write', wrap) |
46 return oldwrite | 46 return oldwrite |
47 | 47 |
48 def filterchunks(ui, originalhunks, usecurses, testfile): | 48 def filterchunks(ui, originalhunks, usecurses, testfile, operation=None): |
49 if usecurses: | 49 if usecurses: |
50 if testfile: | 50 if testfile: |
51 recordfn = crecordmod.testdecorator(testfile, | 51 recordfn = crecordmod.testdecorator(testfile, |
52 crecordmod.testchunkselector) | 52 crecordmod.testchunkselector) |
53 else: | 53 else: |
54 recordfn = crecordmod.chunkselector | 54 recordfn = crecordmod.chunkselector |
55 | 55 |
56 return crecordmod.filterpatch(ui, originalhunks, recordfn) | 56 return crecordmod.filterpatch(ui, originalhunks, recordfn, operation) |
57 | 57 |
58 else: | 58 else: |
59 return patch.filterpatch(ui, originalhunks) | 59 return patch.filterpatch(ui, originalhunks, operation) |
60 | 60 |
61 def recordfilter(ui, originalhunks): | 61 def recordfilter(ui, originalhunks, operation=None): |
62 """ Prompts the user to filter the originalhunks and return a list of | |
63 selected hunks. | |
64 *operation* is used for ui purposes to indicate the user | |
65 what kind of filtering they are doing: reverting, commiting, shelving, etc. | |
66 """ | |
62 usecurses = ui.configbool('experimental', 'crecord', False) | 67 usecurses = ui.configbool('experimental', 'crecord', False) |
63 testfile = ui.config('experimental', 'crecordtest', None) | 68 testfile = ui.config('experimental', 'crecordtest', None) |
64 oldwrite = setupwrapcolorwrite(ui) | 69 oldwrite = setupwrapcolorwrite(ui) |
65 try: | 70 try: |
66 newchunks = filterchunks(ui, originalhunks, usecurses, testfile) | 71 newchunks = filterchunks(ui, originalhunks, usecurses, testfile, |
72 operation) | |
67 finally: | 73 finally: |
68 ui.write = oldwrite | 74 ui.write = oldwrite |
69 return newchunks | 75 return newchunks |
70 | 76 |
71 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall, | 77 def dorecord(ui, repo, commitfunc, cmdsuggest, backupall, |