def findoutgoing(self, parent): '''Return the base set of outgoing nodes. A caching wrapper around mercurial.localrepo.findoutgoing(). Complains (to the user), if the parent workspace is non-existent or inaccessible''' self.ui.pushbuffer() try: try: ui = self.ui if hasattr(cmdutil, 'remoteui'): ui = cmdutil.remoteui(ui, {}) pws = hg.repository(ui, parent) if Version.at_least("1.6"): return discovery.findoutgoing(self.repo, pws) else: return self.repo.findoutgoing(pws) except error.RepoError: self.ui.warn("Warning: Parent workspace '%s' is not " "accessible\n" "active list will be incomplete\n\n" % parent) return [] finally: self.ui.popbuffer()
def _changed_file(self, path): '''Compare the parent and local versions of a given file. Return True if file changed, False otherwise. Note that this compares the given path in both versions, not the given entry; renamed and copied files are compared by name, not history. The fast path compares file metadata, slow path is a real comparison of file content.''' if ((path in self.parenttip) != (path in self.localtip)): return True parentfile = self.parenttip.filectx(path) localfile = self.localtip.filectx(path) # # NB: Keep these ordered such as to make every attempt # to short-circuit the more time consuming checks. # if parentfile.size() != localfile.size(): return True if parentfile.flags() != localfile.flags(): return True if Version.at_least("1.7"): if parentfile.cmp(localfile): return True else: if parentfile.cmp(localfile.data()): return True
def diff(self, node1=None, node2=None, match=None, opts=None): ret = cStringIO.StringIO() try: for chunk in patch.diff(self.repo, node1, node2, match=match, opts=opts): ret.write(chunk) finally: # Workaround Hg bug 1651 if not Version.at_least("1.3"): self.repo.dirstate.invalidate() return ret.getvalue()
def reposetup(ui, repo): if repo.local() and repo not in wslist: wslist[repo] = WorkSpace(repo) if Version.at_least("1.3"): interactive = ui.interactive() else: interactive = ui.interactive if interactive and sys.stdin.isatty(): ui.setconfig('hooks', 'preoutgoing.cdm_pbconfirm', 'python:hgext_cdm.pbconfirm')
def yes_no(ui, msg, default): if default: prompt = ' [Y/n]:' defanswer = 'y' else: prompt = ' [y/N]:' defanswer = 'n' if Version.at_least("1.4"): index = ui.promptchoice(msg + prompt, ['&yes', '&no'], default=['y', 'n'].index(defanswer)) resp = ('y', 'n')[index] else: resp = ui.prompt(msg + prompt, ['&yes', '&no'], default=defanswer) return resp[0] in ('Y', 'y')
def yes_no(ui, msg, default): if default: prompt = ' [Y/n]:' defanswer = 'y' else: prompt = ' [y/N]:' defanswer = 'n' if Version.at_least("1.3.0"): resp = ui.prompt(msg + prompt, ['&yes', '&no'], default=defanswer) else: resp = ui.prompt(msg + prompt, r'([Yy(es)?|[Nn]o?)?', default=defanswer) return resp[0] in ('Y', 'y')
# time.sleep(1) files = {} try: diff = self.bu.backupfile('diff') try: fuzz = patch.patch(diff, self.ws.ui, strip=1, cwd=self.ws.repo.root, files=files) if fuzz: raise util.Abort('working copy diff applied with fuzz') except Exception, e: raise util.Abort("couldn't apply working copy diff: %s\n" " %s" % (diff, e)) finally: if Version.at_least("1.7"): cmdutil.updatedir(self.ws.ui, self.ws.repo, files) else: patch.updatedir(self.ws.ui, self.ws.repo, files) if not self.bu.exists('renames'): return # # We need to re-apply name changes where the new name # (rename/copy destination) is an already versioned file, as # Hg would otherwise ignore them. # try: fp = self.bu.open('renames') for line in fp:
# important bit here (in that if it is incorrect, everything else will # be as incorrect, or more) # import cStringIO import os from mercurial import cmdutil, context, hg, node, patch, repair, util from hgext import mq from onbld.Scm import Version # # Mercurial >= 1.2 has its exception types in a mercurial.error # module, prior versions had them in their associated modules. # if Version.at_least("1.2"): from mercurial import error HgRepoError = error.RepoError HgLookupError = error.LookupError else: from mercurial import repo, revlog HgRepoError = repo.RepoError HgLookupError = revlog.LookupError class ActiveEntry(object): '''Representation of the changes made to a single file. MODIFIED - Contents changed, but no other changes were made ADDED - File is newly created REMOVED - File is being removed
except EnvironmentError, e: raise util.Abort('Could not create backup directory %s: %s' % (self.backupdir, e)) self.generation += 1 self.create_gen(self.generation) try: for x in self.modules: x.backup() except Exception, e: if isinstance(e, KeyboardInterrupt): self.ws.ui.warn("Interrupted\n") else: self.ws.ui.warn("Error: %s\n" % e) if Version.at_least("1.3.0"): show_traceback = self.ws.ui.configbool( 'ui', 'traceback', False) else: show_traceback = self.ws.ui.traceback # # If it's not a 'normal' error, we want to print a stack # trace now in case the attempt to remove the partial # backup also fails, and raises a second exception. # if (not isinstance(e, (EnvironmentError, util.Abort)) or show_traceback): traceback.print_exc() for x in self.modules:
if not source: append_new_parent(parent) return else: path, target = source.rsplit(':', 1) if path != repo.join('hgrc'): raise util.Abort( "Cannot edit path specification not in repo hgrc\n" "default path is from: %s" % source) update_parent(path, int(target), parent) if Version.at_least("1.3"): cdm_reparent = cdm_reparent_13 else: cdm_reparent = cdm_reparent_11 def backup_name(fullpath): '''Create a backup directory name based on the specified path. In most cases this is the basename of the path specified, but certain cases are handled specially to create meaningful names''' special = ['usr/closed'] fullpath = fullpath.rstrip(os.path.sep).split(os.path.sep)
# present the entire change in workspace state between a parent and # its child and is the important bit here (in that if it is incorrect, # everything else will be as incorrect, or more) # import cStringIO import os from mercurial import cmdutil, context, error, hg, node, patch, repair, util from hgext import mq from onbld.Scm import Version # # Mercurial 1.6 moves findoutgoing into a discover module # if Version.at_least("1.6"): from mercurial import discovery class ActiveEntry(object): '''Representation of the changes made to a single file. MODIFIED - Contents changed, but no other changes were made ADDED - File is newly created REMOVED - File is being removed Copies are represented by an Entry whose .parentname is non-nil Truly copied files have non-nil .parentname and .renamed = False Renames have non-nil .parentname and .renamed = True
# its child and is the important bit here (in that if it is incorrect, # everything else will be as incorrect, or more) # import cStringIO import os from mercurial import cmdutil, context, error, hg, node, patch, repair, util from hgext import mq from onbld.Scm import Version # # Mercurial 1.6 moves findoutgoing into a discover module # if Version.at_least("1.6"): from mercurial import discovery class ActiveEntry(object): '''Representation of the changes made to a single file. MODIFIED - Contents changed, but no other changes were made ADDED - File is newly created REMOVED - File is being removed Copies are represented by an Entry whose .parentname is non-nil Truly copied files have non-nil .parentname and .renamed = False Renames have non-nil .parentname and .renamed = True